diff options
| author | Dan McDonald <danmcd@joyent.com> | 2021-08-18 11:32:58 -0400 |
|---|---|---|
| committer | Dan McDonald <danmcd@joyent.com> | 2021-08-18 11:32:58 -0400 |
| commit | 7592d4373f888df2586fe68fed485e6911bc1bed (patch) | |
| tree | b01a0b0779f9fc0c1f459020bc2dee9655ec42bc /usr/src/lib/libproc/common/Psymtab.c | |
| parent | f3fe11ae4095c266424f0708a6bd1672584fa999 (diff) | |
| parent | 4772ec9f4bc326d705888dcda49bcc395df74999 (diff) | |
| download | illumos-joyent-7592d4373f888df2586fe68fed485e6911bc1bed.tar.gz | |
[illumos-gate merge]
commit 4772ec9f4bc326d705888dcda49bcc395df74999
13983 onu could support updating on Helios
commit 998cfd7bd13f4dffec51769e903ceec265afce6f
13988 libproc leaks zoneroot
commit 9148a91fab5cca2666b01bab18514159f4480f9e
13989 libproc can leak core CTF data
commit 50d4d24e9f62b588d2123e06f654ecb230e4857c
13987 libproc could use standard lists
Conflicts:
manifest
Diffstat (limited to 'usr/src/lib/libproc/common/Psymtab.c')
| -rw-r--r-- | usr/src/lib/libproc/common/Psymtab.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/usr/src/lib/libproc/common/Psymtab.c b/usr/src/lib/libproc/common/Psymtab.c index 4d89eba672..7527c7e10c 100644 --- a/usr/src/lib/libproc/common/Psymtab.c +++ b/usr/src/lib/libproc/common/Psymtab.c @@ -23,6 +23,7 @@ * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2016 Joyent, Inc. * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2021 Oxide Computer Company */ #include <assert.h> @@ -197,7 +198,7 @@ file_info_new(struct ps_prochandle *P, map_info_t *mptr) if ((fptr = calloc(1, sizeof (file_info_t))) == NULL) return (NULL); - list_link(fptr, &P->file_head); + list_insert_tail(&P->file_head, fptr); (void) strcpy(fptr->file_pname, mptr->map_pmap.pr_mapname); mptr->map_file = fptr; fptr->file_ref = 1; @@ -262,7 +263,7 @@ static void file_info_free(struct ps_prochandle *P, file_info_t *fptr) { if (--fptr->file_ref == 0) { - list_unlink(fptr); + list_remove(&P->file_head, fptr); if (fptr->file_symtab.sym_elf) { (void) elf_end(fptr->file_symtab.sym_elf); free(fptr->file_symtab.sym_elfmem); @@ -297,10 +298,8 @@ file_info_free(struct ps_prochandle *P, file_info_t *fptr) (void) elf_end(fptr->file_dbgelf); if (fptr->file_dbgfile >= 0) (void) close(fptr->file_dbgfile); - if (fptr->file_ctfp) { - ctf_close(fptr->file_ctfp); - free(fptr->file_ctf_buf); - } + ctf_close(fptr->file_ctfp); + free(fptr->file_ctf_buf); if (fptr->file_saddrs) free(fptr->file_saddrs); free(fptr); @@ -591,12 +590,11 @@ void Pupdate_syms(struct ps_prochandle *P) { file_info_t *fptr; - int i; Pupdate_maps(P); - for (i = 0, fptr = list_next(&P->file_head); i < P->num_files; - i++, fptr = list_next(fptr)) { + for (fptr = list_head(&P->file_head); fptr != NULL; + fptr = list_next(&P->file_head, fptr)) { Pbuild_file_symtab(P, fptr); (void) Pbuild_file_ctf(P, fptr); } @@ -916,7 +914,7 @@ Plmid_to_ctf(struct ps_prochandle *P, Lmid_t lmid, const char *name) */ if (P->state == PS_IDLE && name == PR_OBJ_EXEC && P->info_valid == 1 && P->num_files == 1 && P->mappings == NULL) { - fptr = list_next(&P->file_head); + fptr = list_head(&P->file_head); } if (fptr == NULL) { @@ -1050,7 +1048,6 @@ build_map_symtab(struct ps_prochandle *P, map_info_t *mptr) { prmap_t *pmap = &mptr->map_pmap; file_info_t *fptr; - uint_t i; if ((fptr = mptr->map_file) != NULL) { Pbuild_file_symtab(P, fptr); @@ -1064,8 +1061,8 @@ build_map_symtab(struct ps_prochandle *P, map_info_t *mptr) * Attempt to find a matching file. * (A file can be mapped at several different addresses.) */ - for (i = 0, fptr = list_next(&P->file_head); i < P->num_files; - i++, fptr = list_next(fptr)) { + for (fptr = list_head(&P->file_head); fptr != NULL; + fptr = list_next(&P->file_head, fptr)) { if (strcmp(fptr->file_pname, pmap->pr_mapname) == 0 && fptr->file_lo && is_mapping_in_file(P, mptr, fptr)) { mptr->map_file = fptr; @@ -2967,7 +2964,7 @@ Pxlookup_by_name( /* create all the file_info_t's for all the mappings */ (void) Prd_agent(P); cnt = P->num_files; - fptr = list_next(&P->file_head); + fptr = list_head(&P->file_head); } else { cnt = 1; if ((mptr = object_name_to_map(P, lmid, oname)) == NULL || @@ -2982,7 +2979,7 @@ Pxlookup_by_name( * This means that a name such as "puts" will match the puts function * in libc instead of matching the puts PLT entry in the a.out file. */ - for (; cnt > 0; cnt--, fptr = list_next(fptr)) { + for (; cnt > 0; cnt--, fptr = list_next(&P->file_head, fptr)) { Pbuild_file_symtab(P, fptr); if (fptr->file_elf == NULL) @@ -3100,14 +3097,13 @@ i_Pobject_iter(struct ps_prochandle *P, boolean_t lmresolve, { map_info_t *mptr; file_info_t *fptr; - uint_t cnt; int rc = 0; (void) Prd_agent(P); /* create file_info_t's for all the mappings */ Pupdate_maps(P); - for (cnt = P->num_files, fptr = list_next(&P->file_head); - cnt; cnt--, fptr = list_next(fptr)) { + for (fptr = list_head(&P->file_head); fptr != NULL; + fptr = list_next(&P->file_head, fptr)) { const char *lname; if (lmresolve && (fptr->file_rname != NULL)) @@ -3414,7 +3410,8 @@ void Pinitsym(struct ps_prochandle *P) { P->num_files = 0; - list_link(&P->file_head, NULL); + list_create(&P->file_head, sizeof (file_info_t), + offsetof(file_info_t, file_list)); } /* |
