This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
[PATCH] Re: binutils 2.9.5.0.5 still trigger the last bug - static libstdc++ required
>
> This patch from David breaks none-PIC in DSO. David, can you tell
> us why this patch is needed and could you please run "make check"
> in ld on binutils 2.9.l.0.25 on Linux/Sparc?
Ok, I believe it was because of the glibc 2.0.x dynamic linker bug, because
glibc 2.1.1 and glibc 2.1.90 require that change to be back out (well, the
finish_dynamic_symbol should stay), otherwise things dump core.
glibc 2.1.x+ dl-machine.h (example for sparc32) looks like:
const Elf32_Sym *const refsym = sym;
Elf32_Addr value;
if (sym->st_shndx != SHN_UNDEF &&
ELF32_ST_BIND (sym->st_info) == STB_LOCAL)
value = map->l_addr;
else
{
value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info));
if (sym)
value += sym->st_value;
}
value += reloc->r_addend; /* Assume copy relocs have zero addend. */
...
while glibc 2.0.x reads as:
const int r_type = ELF32_R_TYPE (reloc->r_info);
Elf32_Addr value;
value = RESOLVE (&sym, (r_type == R_SPARC_COPY ? DL_LOOKUP_NOEXEC
: r_type == R_SPARC_JMP_SLOT ? DL_LOOKUP_NOPLT
: 0));
if (sym)
value += sym->st_value;
value += reloc->r_addend; /* Assume copy relocs have zero addend. */
...
In fact, glibc 2.0.x had sparc-linux support even more broken, RedHat
shipped ~450k of SPARC patches for it and the dl-machine.h buggy code was in
the patch.
1999-08-09 Jakub Jelinek <jj@ultra.linux.cz>
* elf64-sparc.c (sparc64_elf_relocate_section): Back out part of the
Sep, 4th, 1998 change. glibc 2.0.x dynamic linker had bug, not
binutils.
* elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
--- elf32-sparc.c.jj Fri Jul 23 15:31:15 1999
+++ elf32-sparc.c Mon Aug 9 10:05:49 1999
@@ -1475,15 +1475,7 @@ elf32_sparc_relocate_section (output_bfd
}
outrel.r_info = ELF32_R_INFO (indx, r_type);
-
- /* For non-RELATIVE dynamic relocations, we keep the
- same symbol, and so generally the same addend. But
- we do need to adjust those relocations referencing
- sections. */
- outrel.r_addend = rel->r_addend;
- if (r_symndx < symtab_hdr->sh_info
- && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- outrel.r_addend += sec->output_offset+sym->st_value;
+ outrel.r_addend = relocation + rel->r_addend;
}
}
--- elf64-sparc.c Mon Aug 2 09:39:54 1999
+++ elf64-sparc.c Mon Aug 9 10:06:16 1999
@@ -2249,15 +2249,7 @@ sparc64_elf_relocate_section (output_bfd
ELF64_R_TYPE_INFO (
ELF64_R_TYPE_DATA (rel->r_info),
r_type));
-
- /* For non-RELATIVE dynamic relocations, we keep the
- same symbol, and so generally the same addend. But
- we do need to adjust those relocations referencing
- sections. */
- outrel.r_addend = rel->r_addend;
- if (r_symndx < symtab_hdr->sh_info
- && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- outrel.r_addend += sec->output_offset+sym->st_value;
+ outrel.r_addend = relocation + rel->r_addend;
}
}
Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
UltraLinux | http://ultra.linux.cz/ | http://ultra.penguin.cz/
Linux version 2.3.13 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________