diff mbox

[BZ,#18410] : Incorrect handling of missing DT_PLTRELSZ

Message ID 20150515192532.GA11684@intel.com
State Superseded
Headers show

Commit Message

H.J. Lu May 15, 2015, 7:25 p.m. UTC
A shared object doesn't need PLT if there are no PLT relocations.  It
shouldn't be an error if DT_PLTRELSZ is missing.

OK for master?


H.J.
--
	[BZ #18410]
	* elf/dl-reloc.c (_dl_relocate_object): Don't issue an error
	for missing DT_PLTRELSZ.
---
 elf/dl-reloc.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Roland McGrath May 18, 2015, 8:41 p.m. UTC | #1
Can you add a test case?
H.J. Lu May 18, 2015, 9:02 p.m. UTC | #2
On Mon, May 18, 2015 at 1:41 PM, Roland McGrath <roland@hack.frob.com> wrote:
> Can you add a test case?

It is already in glibc. elf/tst-audit10 fails on x86 using binutils with

commit a3747075ae478f27bf3e0643021a85fb6cdad0e3
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue May 12 13:11:48 2015 -0700

    Allocate the first .plt entry space only if needed

    Commit dd7e64d45b317128f5fe813a8da0b13b4ad046ae may optimize out
    i386/x86-64 JUMP_SLOT relocation.  If there is no JUMP_SLOT relocation
    left, we don't need to the first .plt entry.  This patch allocates
    space for the first .plt entry only if we also reserve space for a PLT
    slot for JUMP_SLOT relocation.
Roland McGrath May 18, 2015, 9:03 p.m. UTC | #3
> On Mon, May 18, 2015 at 1:41 PM, Roland McGrath <roland@hack.frob.com> wrote:
> > Can you add a test case?
> 
> It is already in glibc. elf/tst-audit10 fails on x86 using binutils with

These are the kinds of details about a change that you should always
include in the first posting.
diff mbox

Patch

diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index 0872636..068ea65 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -258,21 +258,13 @@  _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
     ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling, skip_ifunc);
 
 #ifndef PROF
-    if (__glibc_unlikely (consider_profiling))
+    if (__glibc_unlikely (consider_profiling
+			  && l->l_info[DT_PLTRELSZ] != NULL))
       {
 	/* Allocate the array which will contain the already found
 	   relocations.  If the shared object lacks a PLT (for example
 	   if it only contains lead function) the l_info[DT_PLTRELSZ]
 	   will be NULL.  */
-	if (l->l_info[DT_PLTRELSZ] == NULL)
-	  {
-	    errstring = N_("%s: no PLTREL found in object %s\n");
-	  fatal:
-	    _dl_fatal_printf (errstring,
-			      RTLD_PROGNAME,
-			      l->l_name);
-	  }
-
 	size_t sizeofrel = l->l_info[DT_PLTREL]->d_un.d_val == DT_RELA
 			   ? sizeof (ElfW(Rela))
 			   : sizeof (ElfW(Rel));
@@ -283,7 +275,7 @@  _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
 	  {
 	    errstring = N_("\
 %s: out of memory to store relocation results for %s\n");
-	    goto fatal;
+	    _dl_fatal_printf (errstring, RTLD_PROGNAME, l->l_name);
 	  }
       }
 #endif