public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Discard unneeded PLT entries on SPARC 64-bit
@ 2005-01-09 22:49 Eric Botcazou
  2005-01-10 11:04 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2005-01-09 22:49 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 2361 bytes --]

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

[-- Attachment #2: bfd_sparc_discard_plt.diff --]
[-- Type: text/x-diff, Size: 829 bytes --]

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Discard unneeded PLT entries on SPARC 64-bit
  2005-01-09 22:49 [PATCH] Discard unneeded PLT entries on SPARC 64-bit Eric Botcazou
@ 2005-01-10 11:04 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2005-01-10 11:04 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: binutils

On Sun, Jan 09, 2005 at 11:48:35PM +0100, Eric Botcazou wrote:
> 	* 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.

OK.  Looks like a step in the right direction.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-01-10 11:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-09 22:49 [PATCH] Discard unneeded PLT entries on SPARC 64-bit Eric Botcazou
2005-01-10 11:04 ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).