Subject: Re: CVS commit: basesrc/libexec/ld.elf_so
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
From: Rafal Boni <rafal@mediaone.net>
List: port-mips
Date: 11/11/2001 00:50:45
In message <200111110508.fAB58MP08982@mirage.ceres.dti.ne.jp>, you write:
-> In article <20011014231323.8E4DCB009@cvs.netbsd.org>
-> rafal@netbsd.org wrote:
->
-> > Module Name: basesrc
-> > Committed By: rafal
-> > Date: Sun Oct 14 23:13:22 UTC 2001
-> >
-> > Modified Files:
-> > basesrc/libexec/ld.elf_so: symbol.c
-> > basesrc/libexec/ld.elf_so/arch/mips: mips_reloc.c
-> >
-> > Log Message:
-> > Fix how underfined weak symbols are treated -- before, ld.so would do noth
-> ing
-> > with them, rather than defaulting them to zero. This caused breakage with
-> > the drawf EH stuff and init/fini code when they weren't used by the caller
-> > (and hence the appropriate handlers were left undefined). Also fix an un-
-> > initialized variable in symbol.c that only MIPS MD code tripped over.
->
-> After this change, still old binaries compiled before init/fini changes
-> dumps core in _rtld_relocate_mips_got().
-> The attached patch (i.e. partially backing out this change) seems
-> to fix this problem. Is it correct?
-> ---
-> Izumi Tsutsui
-> tsutsui@ceres.dti.ne.jp
I believe your patch is correct, or at least my last change was incomplete
(though in general two may not be the same 8-). For some reason I believed
_rtld_error() would abort processing, hence I never worried about what the
rest of the code would do if `def' was indeed NULL.
Thanks for catching this... I'll give it a try to make sure no negative
consequences arise in the cases I was having trouble with before, though
I don't expect to.
I believe Nick was also planning a pullup of ld.so changes to the release
branch, so I'll mention to him to hold on until this goes in..
--rafal
-> Index: mips_reloc.c
-> ===================================================================
-> RCS file: /cvsroot/basesrc/libexec/ld.elf_so/arch/mips/mips_reloc.c,v
-> retrieving revision 1.4
-> diff -u -r1.4 mips_reloc.c
-> --- mips_reloc.c 2001/10/14 23:13:22 1.4
-> +++ mips_reloc.c 2001/11/11 04:42:49
-> @@ -73,39 +73,41 @@
-> obj->path, sym->st_name + obj->strtab,
-> (u_long) ELF_R_TYPE(info),
-> (u_long) obj->symtabno - i - 1);
-> + else {
->
-> - if (sym->st_shndx == SHN_UNDEF) {
-> + if (sym->st_shndx == SHN_UNDEF) {
-> #if 0 /* These don't seem to work? */
->
-> - if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
-> - STT_FUNC) {
-> - if (sym->st_value)
-> - *got = sym->st_value +
-> - (Elf_Word)obj->relocbase;
-> - else
-> + if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
-> + STT_FUNC) {
-> + if (sym->st_value)
-> + *got = sym->st_value +
-> + (Elf_Word)obj->relocbase;
-> + else
-> + *got = def->st_value +
-> + (Elf_Word)defobj->relocbase
-> ;
-> + } else
-> +#endif
-> *got = def->st_value +
-> (Elf_Word)defobj->relocbase;
-> + } else if (sym->st_shndx == SHN_COMMON) {
-> + *got = def->st_value +
-> + (Elf_Word)defobj->relocbase;
-> + } else if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
-> + STT_FUNC &&
-> + *got != sym->st_value) {
-> + *got += (Elf_Word)obj->relocbase;
-> + } else if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
-> + STT_SECTION && ELFDEFNNAME(ST_BIND)(sym->st_info) =
-> =
-> + STB_GLOBAL) {
-> + if (sym->st_shndx == SHN_ABS)
-> + *got = sym->st_value +
-> + (Elf_Word)obj->relocbase;
-> + /* else SGI stuff ignored */
-> } else
-> -#endif
-> *got = def->st_value +
-> (Elf_Word)defobj->relocbase;
-> - } else if (sym->st_shndx == SHN_COMMON) {
-> - *got = def->st_value +
-> - (Elf_Word)defobj->relocbase;
-> - } else if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
-> - STT_FUNC &&
-> - *got != sym->st_value) {
-> - *got += (Elf_Word)obj->relocbase;
-> - } else if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
-> - STT_SECTION && ELFDEFNNAME(ST_BIND)(sym->st_info) ==
-> - STB_GLOBAL) {
-> - if (sym->st_shndx == SHN_ABS)
-> - *got = sym->st_value +
-> - (Elf_Word)obj->relocbase;
-> - /* else SGI stuff ignored */
-> - } else
-> - *got = def->st_value +
-> - (Elf_Word)defobj->relocbase;
-> + }
->
-> ++sym;
-> ++got;
->
->
----
Rafal Boni rafal@mediaone.net