This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Reinstate bypass for call-to-undefweak reloc overflow on SPARC
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: binutils at sourceware dot org
- Date: Wed, 1 Feb 2006 23:04:44 +0100
- Subject: Reinstate bypass for call-to-undefweak reloc overflow on SPARC
Hi,
It was presumably ditched when DaveM merged the 32-bit and 64-bit code. :-)
We need it for g++.dg/warn/weak1.C, otherwise the linker complains:
weak1.o: In function `main':weak1.C:(.text+0x24): relocation truncated to fit:
R_SPARC_WDISP30 against undefined symbol `foo()'
extern void foo (void) __attribute__ ((weak));
int
main ()
{
if (&foo)
foo ();
return 0;
}
Tested on SPARC/Solaris 10 and SPARC64/Solaris 9. GCC 4.1.0pre was also
regtested. Applied as semi-obvious. :-)
2006-02-01 Eric Botcazou <ebotcazou@libertysurf.fr>
* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Reinstate bypass
for call-to-undefweak reloc overflow.
--
Eric Botcazou
Index: elfxx-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-sparc.c,v
retrieving revision 1.16
diff -u -p -r1.16 elfxx-sparc.c
--- elfxx-sparc.c 31 Jan 2006 22:42:21 -0000 1.16
+++ elfxx-sparc.c 1 Feb 2006 21:08:37 -0000
@@ -3373,7 +3373,18 @@ _bfd_sparc_elf_relocate_section (bfd *ou
break;
if (h != NULL)
- name = NULL;
+ {
+ /* Assume this is a call protected by other code that
+ detect the symbol is undefined. If this is the case,
+ we can safely ignore the overflow. If not, the
+ program is hosed anyway, and a little warning isn't
+ going to help. */
+ if (h->root.type == bfd_link_hash_undefweak
+ && howto->pc_relative)
+ break;
+
+ name = NULL;
+ }
else
{
name = bfd_elf_string_from_elf_section (input_bfd,