This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: binutils 2.9.5.0.5 still trigger the last bug - static libstdc++ required
- To: ian@zembu.com (Ian Lance Taylor)
- Subject: Re: binutils 2.9.5.0.5 still trigger the last bug - static libstdc++ required
- From: hjl@lucon.org (H.J. Lu)
- Date: Sat, 7 Aug 1999 23:02:31 -0700 (PDT)
- Cc: jj@sunsite.ms.mff.cuni.cz, binutils@sourceware.cygnus.com,davem@redhat.com
>
> Date: Sat, 7 Aug 1999 18:17:42 -0700 (PDT)
> From: hjl@lucon.org (H.J. Lu)
>
> > The bug has been in binutils for a while. Ian, Jakub, with "make check"
> > in ld, I got
> >
> > FAIL: shared (non PIC)
> > FAIL: shared (non PIC, load offset)
> > FAIL: shared (PIC main, non PIC so)
> >
> > This suggests a bug in handling relocations when generating shared
> > libraries.
> >
> > To me it makes perfect sense to include libstdc++.a in a shared
> > object. Anyhow, it seems silly to patch g++ merely because there is a
> > bug in ld. We should just fix the bug in ld. A bug like this can't
> > be hard to fix, especially since the GNU linker used to pass those
> > tests on Solaris.
>
> binutils 2.9.1.0.25, which is basically binutils 2.9.1, failed those
> tests. I am no expert on Sparc. I don't know how it got broken. I
> will give it a try when I find time.
>
> When I used to run tests on Solaris those tests passed (well, the load
> offset test did not exist at that time, and I'm not concerned if it
> doesn't pass).
>
> Ian
>
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?
Thanks.
--
H.J. Lu (hjl@gnu.org)
---
Fri Sep 4 13:54:23 1998 David Miller <davem@dm.cobaltmicro.com>
* elf32-sparc.c (elf32_sparc_relocate_section): Properly adjust
the addend of a dynamic relocation referencing a section.
* elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
(sparc64_elf_finish_dynamic_symbol): Fix the PLT relocation
offset.
diff -upr binutils-2.9.1.0.22/bfd/elf64-sparc.c binutils-2.9.1.0.23/bfd/elf64-sparc.c
--- binutils-2.9.1.0.22/bfd/elf64-sparc.c Fri Dec 4 19:38:53 1998
+++ binutils-2.9.1.0.23/bfd/elf64-sparc.c Wed Mar 31 09:24:48 1999
@@ -1590,7 +1590,15 @@ sparc64_elf_relocate_section (output_bfd
}
outrel.r_info = ELF64_R_INFO (indx, r_type);
- outrel.r_addend = relocation + rel->r_addend;
+
+ /* 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;
}
}
@@ -1904,6 +1912,7 @@ sparc64_elf_finish_dynamic_symbol (outpu
rela.r_offset = sparc64_elf_plt_ptr_offset (h->plt_offset, max);
rela.r_addend = -(sparc64_elf_plt_entry_offset (h->plt_offset) + 4);
}
+ rela.r_offset += (splt->output_section->vma + splt->output_offset);
rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_JMP_SLOT);
bfd_elf64_swap_reloca_out (output_bfd, &rela,