Mercurial > illumos > illumos-gate
changeset 13530:4762b52cedff
1803 appcert's symbol hash insert is needlessly baroque
Reviewed by: Garrett D'Amore <garrett@nexenta.com>
Reviewed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>
Reviewed by: Joshua M. Clulow <josh@sysmgr.org>
Approved by: Gordon Ross <gwr@nexenta.com>
author | Dan McDonald <danmcd@nexenta.com> |
---|---|
date | Fri, 18 Nov 2011 20:48:37 +0000 |
parents | 36f298df0acc |
children | 95e596551b5c |
files | usr/src/cmd/abi/appcert/static_prof/static_prof.c |
diffstat | 1 files changed, 19 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/abi/appcert/static_prof/static_prof.c Thu Nov 24 16:26:07 2011 -0500 +++ b/usr/src/cmd/abi/appcert/static_prof/static_prof.c Fri Nov 18 20:48:37 2011 +0000 @@ -28,7 +28,7 @@ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright 2011 Nexenta Systems, Inc. All rights reserved. */ /* ------------------------------------------------------------------------ */ @@ -100,42 +100,27 @@ { unsigned long bktno; unsigned long orig_bktno; - int table_full = FALSE; - int i; bktno = my_elf_hash(bind->sym) % DEFBKTS; orig_bktno = bktno; - if (!bkts[bktno].sym) { - bkts[bktno].sym = bind->sym; - bkts[bktno].obj = bind->obj; - bkts[bktno].ref_lib = bind->ref_lib; - bkts[bktno].def_lib = bind->def_lib; - bkts[bktno].section = bind->section; - bkts[bktno].stbind = bind->stbind; - bkts[bktno].sttype = bind->sttype; - } else { + while (bkts[bktno].sym != NULL) { bktno = (bktno + 1) % DEFBKTS; - for (i = bktno; i < DEFBKTS; i = (i + 1) % DEFBKTS) { - if (i == orig_bktno) { - table_full = TRUE; - exit(1); - } - if (!bkts[i].sym) - break; - } - if ((!bkts[i].sym) && (table_full != TRUE)) { - bkts[i].sym = bind->sym; - bkts[i].obj = bind->obj; - bkts[i].ref_lib = bind->ref_lib; - bkts[i].def_lib = bind->def_lib; - bkts[i].section = bind->section; - bkts[i].stbind = bind->stbind; - bkts[i].sttype = bind->sttype; - } + + if (bktno == orig_bktno) + exit(1); } + + bkts[bktno].sym = bind->sym; + bkts[bktno].obj = bind->obj; + bkts[bktno].ref_lib = bind->ref_lib; + bkts[bktno].def_lib = bind->def_lib; + bkts[bktno].section = bind->section; + bkts[bktno].stbind = bind->stbind; + bkts[bktno].sttype = bind->sttype; } + /* ========== check_store_binding ========================================= */ /* * DESCRIPTION: @@ -1023,8 +1008,7 @@ binding_bucket *binding; /* look only at .text section symbols */ if (!is_text_section(symtab_entry->st_shndx, - c->obj->elf, - c->obj->ehdr)) + c->obj->elf, c->obj->ehdr)) continue; /* look only at weak and global symbols */ @@ -1049,7 +1033,7 @@ } sym_name = buf + symtab_entry->st_name; binding = (struct binding_bucket *) - malloc(sizeof (binding_bucket)); + malloc(sizeof (binding_bucket)); binding->sym = sym_name; binding->obj = c->obj->ename; binding->section = "TEXT"; @@ -1206,7 +1190,7 @@ c = (obj_list *) malloc(sizeof (obj_list)); c->obj = (obj_com *) malloc(sizeof (obj_com)); fullname = (char *)malloc(strlen(com->obj->ename) - + strlen(filename) + 2); + + strlen(filename) + 2); (void *) strcpy(fullname, com->obj->ename); (void *) strcat(fullname, "("); (void *) strcat(fullname, filename); @@ -1470,7 +1454,7 @@ if (dcurrent->d_tag == DT_NEEDED) { tmp_lib = (dt_list *) malloc(sizeof (dt_list)); tmp_lib->libname = c->obj->dynnames + - dcurrent->d_un.d_val; + dcurrent->d_un.d_val; tmp_lib->d_tag = dcurrent->d_tag; tmp_lib->next = NULL; dt_needed = add_dtneeded(dt_needed, tmp_lib); @@ -1683,8 +1667,7 @@ if (c->obj->numfiles > 0) { i = 0; c->obj->filenames = (char **) - malloc(sizeof (char *) * - (c->obj->numfiles + 1)); + malloc(sizeof (char *) * (c->obj->numfiles + 1)); for (; optind < argc; i++, optind++) c->obj->filenames[i] = argv[optind]; }