This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Discard unneeded PLT entries on SPARC 64-bit
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: binutils at sources dot redhat dot com
- Date: Sun, 9 Jan 2005 23:48:35 +0100
- Subject: [PATCH] Discard unneeded PLT entries on SPARC 64-bit
Hi,
We have the following failure in the GCC 4.0.0pre+Binutils 2.15.94 testsuite
on Solaris/SPARC 64-bit:
FAIL: gcc.dg/cleanup-5.c execution test
The loader complains about bogus relocations in the PLT:
0000000100105380 R_SPARC_JMP_SLOT malloc
00000001001053a0 R_SPARC_JMP_SLOT _Unwind_Find_FDE
00000001001053c0 R_SPARC_JMP_SLOT memset
0000000000000000 R_SPARC_NONE *ABS*
0000000100105400 R_SPARC_JMP_SLOT exit
0000000000000000 R_SPARC_NONE *ABS*
0000000100105440 R_SPARC_JMP_SLOT memcpy
0000000100105460 R_SPARC_JMP_SLOT pthread_mutex_unlock
0000000000000000 R_SPARC_NONE *ABS*
00000001001054a0 R_SPARC_JMP_SLOT free
00000001001054c0 R_SPARC_JMP_SLOT __deregister_frame_info
0000000000000000 R_SPARC_NONE *ABS*
0000000000000000 R_SPARC_NONE *ABS*
0000000100105520 R_SPARC_JMP_SLOT pthread_create
0000000000000000 R_SPARC_NONE *ABS*
0000000100105560 R_SPARC_JMP_SLOT abort
0000000100105580 R_SPARC_JMP_SLOT pthread_once
0000000000000000 R_SPARC_NONE *ABS*
00000001001055c0 R_SPARC_JMP_SLOT _exit
0000000000000000 R_SPARC_NONE *ABS*
0000000100105600 R_SPARC_JMP_SLOT strlen
0000000000000000 R_SPARC_NONE *ABS*
0000000100105640 R_SPARC_JMP_SLOT pthread_mutex_lock
0000000000000000 R_SPARC_NONE *ABS*
0000000100105680 R_SPARC_JMP_SLOT atexit
0000000000000000 R_SPARC_NONE *ABS*
0000000000000000 R_SPARC_NONE *ABS*
00000001001056e0 R_SPARC_JMP_SLOT __register_frame_info
The 12 R_SPARC_NONE relocs correspond to LOCAL HIDDEN symbols in libgcc_eh
that are not referenced. Space is reserved for them in the .plt
and .rela.plt sections but apparently the relocations are never finalized.
The proposed fix is to avoid reserving space for them in the first place. The
condition is borrowed from the twin function in elf32-sparc.c. Tested on
sparc64-sun-solaris2.9.
2005-01-04 Eric Botcazou <ebotcazou@libertysurf.fr>
* elf64-sparc.c (sparc64_elf_adjust_dynamic_symbol): When linking a
non-shared object, do not reserve space in .plt and .rela.plt for regular
symbols not defined or referenced in shared objects.
Note that we still emit unneeded dynamic relocations against data for the
testcase:
0000000100105718 R_SPARC_GLOB_DAT __deregister_frame_info
0000000100105728 R_SPARC_GLOB_DAT __register_frame_info
but the fix would be more invasive.
--
Eric Botcazou
Index: elf64-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sparc.c,v
retrieving revision 1.100
diff -u -p -r1.100 elf64-sparc.c
--- elf64-sparc.c 9 Jan 2005 19:48:28 -0000 1.100
+++ elf64-sparc.c 9 Jan 2005 20:42:34 -0000
@@ -1680,7 +1680,11 @@ sparc64_elf_adjust_dynamic_symbol (info,
|| h->root.type == bfd_link_hash_defweak)
&& (h->root.u.def.section->flags & SEC_CODE) != 0))
{
- if (! elf_hash_table (info)->dynamic_sections_created)
+ if (! info->shared
+ && !h->def_dynamic
+ && !h->ref_dynamic
+ && h->root.type != bfd_link_hash_undefweak
+ && h->root.type != bfd_link_hash_undefined)
{
/* This case can occur if we saw a WPLT30 reloc in an input
file, but none of the input files were dynamic objects.