From: Peter Johnson Date: Tue, 1 Nov 2005 04:23:54 +0000 (-0000) Subject: * elf-objfmt.c (elf_objfmt_symtab_append): Don't append symbol a second X-Git-Tag: v0.5.0rc1~78 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e2fc30f468400c4bb66c5b6fe632db0a6d5b05c;p=yasm * elf-objfmt.c (elf_objfmt_symtab_append): Don't append symbol a second time if it already has associated data. This keeps global followed by extern from generating duplicate symbol table entries. svn path=/trunk/yasm/; revision=1300 --- diff --git a/modules/objfmts/elf/elf-objfmt.c b/modules/objfmts/elf/elf-objfmt.c index 0e3f8160..c5bd4d6d 100644 --- a/modules/objfmts/elf/elf-objfmt.c +++ b/modules/objfmts/elf/elf-objfmt.c @@ -91,10 +91,14 @@ elf_objfmt_symtab_append(yasm_objfmt_elf *objfmt_elf, yasm_symrec *sym, elf_symbol_type type, elf_symbol_vis vis, yasm_expr *size, elf_address value) { - elf_strtab_entry *name = elf_strtab_append_str(objfmt_elf->strtab, - yasm_symrec_get_name(sym)); - elf_symtab_entry *entry = elf_symtab_entry_create(name, sym); - elf_symtab_append_entry(objfmt_elf->elf_symtab, entry); + /* Only append to table if not already appended */ + elf_symtab_entry *entry = yasm_symrec_get_data(sym, &elf_symrec_data); + if (!entry) { + elf_strtab_entry *name = elf_strtab_append_str(objfmt_elf->strtab, + yasm_symrec_get_name(sym)); + entry = elf_symtab_entry_create(name, sym); + elf_symtab_append_entry(objfmt_elf->elf_symtab, entry); + } elf_symtab_set_nonzero(entry, NULL, sectidx, bind, type, size, value); elf_sym_set_visibility(entry, vis); diff --git a/modules/objfmts/elf/tests/Makefile.inc b/modules/objfmts/elf/tests/Makefile.inc index 51d51b06..f39c04a5 100644 --- a/modules/objfmts/elf/tests/Makefile.inc +++ b/modules/objfmts/elf/tests/Makefile.inc @@ -28,6 +28,9 @@ EXTRA_DIST += modules/objfmts/elf/tests/elfglobal.hex EXTRA_DIST += modules/objfmts/elf/tests/elfglobext.asm EXTRA_DIST += modules/objfmts/elf/tests/elfglobext.errwarn EXTRA_DIST += modules/objfmts/elf/tests/elfglobext.hex +EXTRA_DIST += modules/objfmts/elf/tests/elfglobext2.asm +EXTRA_DIST += modules/objfmts/elf/tests/elfglobext2.errwarn +EXTRA_DIST += modules/objfmts/elf/tests/elfglobext2.hex EXTRA_DIST += modules/objfmts/elf/tests/elfreloc-ext.asm EXTRA_DIST += modules/objfmts/elf/tests/elfreloc-ext.errwarn EXTRA_DIST += modules/objfmts/elf/tests/elfreloc-ext.hex diff --git a/modules/objfmts/elf/tests/elfglobext2.asm b/modules/objfmts/elf/tests/elfglobext2.asm new file mode 100644 index 00000000..6467aa34 --- /dev/null +++ b/modules/objfmts/elf/tests/elfglobext2.asm @@ -0,0 +1,2 @@ +global foo +extern foo diff --git a/modules/objfmts/elf/tests/elfglobext2.errwarn b/modules/objfmts/elf/tests/elfglobext2.errwarn new file mode 100644 index 00000000..e69de29b diff --git a/modules/objfmts/elf/tests/elfglobext2.hex b/modules/objfmts/elf/tests/elfglobext2.hex new file mode 100644 index 00000000..ca4b2db9 --- /dev/null +++ b/modules/objfmts/elf/tests/elfglobext2.hex @@ -0,0 +1,376 @@ +7f +45 +4c +46 +01 +01 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +03 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +b0 +00 +00 +00 +00 +00 +00 +00 +34 +00 +00 +00 +00 +00 +28 +00 +05 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +2e +74 +65 +78 +74 +00 +2e +73 +74 +72 +74 +61 +62 +00 +2e +73 +79 +6d +74 +61 +62 +00 +2e +73 +68 +73 +74 +72 +74 +61 +62 +00 +00 +00 +00 +00 +2d +00 +66 +6f +6f +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +01 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +04 +00 +f1 +ff +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +03 +00 +04 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +10 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +17 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +40 +00 +00 +00 +21 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +07 +00 +00 +00 +03 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +64 +00 +00 +00 +07 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +0f +00 +00 +00 +02 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +6c +00 +00 +00 +40 +00 +00 +00 +02 +00 +00 +00 +03 +00 +00 +00 +04 +00 +00 +00 +10 +00 +00 +00 +01 +00 +00 +00 +01 +00 +00 +00 +06 +00 +00 +00 +00 +00 +00 +00 +40 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +00 +10 +00 +00 +00 +00 +00 +00 +00