[BZ,#19007] FAIL: elf/check-localplt with -z now and binutuls 2.26

Message ID 20150925211710.GA29199@intel.com
State Committed
Headers

Commit Message

Lu, Hongjiu Sept. 25, 2015, 9:17 p.m. UTC
  On linker in binutils 2.26 and newer generate GOT references instead
PLT references when -z now is passed to linker.  We need to extend
scripts/localplt.awk to allow PLT or GOT references.

Tested on x86 and x86-64.  OK for master?

H.J.
--
	[BZ #19007]
	* scripts/localplt.awk: Also allow GOT references.
	* sysdeps/unix/sysv/linux/i386/localplt.data: Mark
	_Unwind_Find_FDE, calloc, memalign, realloc and __libc_memalign
	with "+ REL R_386_GLOB_DAT".
	* sysdeps/x86_64/localplt.data: Mark calloc, memalign, realloc
	and __libc_memalign with "+ RELA R_X86_64_GLOB_DAT".
---
 scripts/localplt.awk                       |  2 +-
 sysdeps/unix/sysv/linux/i386/localplt.data | 16 ++++++++--------
 sysdeps/x86_64/localplt.data               | 14 +++++++-------
 3 files changed, 16 insertions(+), 16 deletions(-)
  

Comments

H.J. Lu Oct. 13, 2015, 7:48 p.m. UTC | #1
On Fri, Sep 25, 2015 at 2:17 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> On linker in binutils 2.26 and newer generate GOT references instead
> PLT references when -z now is passed to linker.  We need to extend
> scripts/localplt.awk to allow PLT or GOT references.
>
> Tested on x86 and x86-64.  OK for master?
>
> H.J.
> --
>         [BZ #19007]
>         * scripts/localplt.awk: Also allow GOT references.
>         * sysdeps/unix/sysv/linux/i386/localplt.data: Mark
>         _Unwind_Find_FDE, calloc, memalign, realloc and __libc_memalign
>         with "+ REL R_386_GLOB_DAT".
>         * sysdeps/x86_64/localplt.data: Mark calloc, memalign, realloc
>         and __libc_memalign with "+ RELA R_X86_64_GLOB_DAT".
> ---
>  scripts/localplt.awk                       |  2 +-
>  sysdeps/unix/sysv/linux/i386/localplt.data | 16 ++++++++--------
>  sysdeps/x86_64/localplt.data               | 14 +++++++-------
>  3 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/scripts/localplt.awk b/scripts/localplt.awk
> index f75b3b4..beaa342 100644
> --- a/scripts/localplt.awk
> +++ b/scripts/localplt.awk
> @@ -7,7 +7,7 @@
>  BEGIN { result = 0 }
>
>  FILENAME != lastfile {
> -  if (lastfile && jmprel_offset == 0) {
> +  if (lastfile && jmprel_offset == 0 && rela_offset == 0 && rel_offset == 0) {
>      print FILENAME ": *** failed to find expected output (readelf -WSdr)";
>      result = 2;
>    }
> diff --git a/sysdeps/unix/sysv/linux/i386/localplt.data b/sysdeps/unix/sysv/linux/i386/localplt.data
> index 2e03821..4ce8447 100644
> --- a/sysdeps/unix/sysv/linux/i386/localplt.data
> +++ b/sysdeps/unix/sysv/linux/i386/localplt.data
> @@ -1,17 +1,17 @@
>  # Linker in binutils 2.26 and newer consolidates R_X86_64_JUMP_SLOT
>  # relocation with R_386_GLOB_DAT relocation against the same symbol.
> -libc.so: _Unwind_Find_FDE
> -libc.so: calloc
> +libc.so: _Unwind_Find_FDE + REL R_386_GLOB_DAT
> +libc.so: calloc + REL R_386_GLOB_DAT
>  libc.so: free + REL R_386_GLOB_DAT
>  libc.so: malloc + REL R_386_GLOB_DAT
> -libc.so: memalign
> -libc.so: realloc
> +libc.so: memalign + REL R_386_GLOB_DAT
> +libc.so: realloc + REL R_386_GLOB_DAT
>  libm.so: matherr
>  # The dynamic loader uses __libc_memalign internally to allocate aligned
>  # TLS storage. The other malloc family of functions are expected to allow
>  # user symbol interposition.
> -ld.so: __libc_memalign
> -ld.so: malloc
> -ld.so: calloc
> -ld.so: realloc
> +ld.so: __libc_memalign + REL R_386_GLOB_DAT
> +ld.so: malloc + REL R_386_GLOB_DAT
> +ld.so: calloc + REL R_386_GLOB_DAT
> +ld.so: realloc + REL R_386_GLOB_DAT
>  ld.so: free + REL R_386_GLOB_DAT
> diff --git a/sysdeps/x86_64/localplt.data b/sysdeps/x86_64/localplt.data
> index d140476..f168b14 100644
> --- a/sysdeps/x86_64/localplt.data
> +++ b/sysdeps/x86_64/localplt.data
> @@ -3,17 +3,17 @@
>  # users can define their own functions and have library internals call them.
>  # Linker in binutils 2.26 and newer consolidates R_X86_64_JUMP_SLOT
>  # relocation with R_X86_64_GLOB_DAT relocation against the same symbol.
> -libc.so: calloc
> +libc.so: calloc + RELA R_X86_64_GLOB_DAT
>  libc.so: free + RELA R_X86_64_GLOB_DAT
>  libc.so: malloc + RELA R_X86_64_GLOB_DAT
> -libc.so: memalign
> -libc.so: realloc
> +libc.so: memalign + RELA R_X86_64_GLOB_DAT
> +libc.so: realloc + RELA R_X86_64_GLOB_DAT
>  libm.so: matherr
>  # The dynamic loader uses __libc_memalign internally to allocate aligned
>  # TLS storage. The other malloc family of functions are expected to allow
>  # user symbol interposition.
> -ld.so: __libc_memalign
> -ld.so: malloc
> -ld.so: calloc
> -ld.so: realloc
> +ld.so: __libc_memalign + RELA R_X86_64_GLOB_DAT
> +ld.so: malloc + RELA R_X86_64_GLOB_DAT
> +ld.so: calloc + RELA R_X86_64_GLOB_DAT
> +ld.so: realloc + RELA R_X86_64_GLOB_DAT
>  ld.so: free + RELA R_X86_64_GLOB_DAT
> --
> 2.4.3
>

PING.
  
Florian Weimer Oct. 14, 2015, 12:27 p.m. UTC | #2
On 09/25/2015 11:17 PM, H.J. Lu wrote:
> On linker in binutils 2.26 and newer generate GOT references instead
> PLT references when -z now is passed to linker.  We need to extend
> scripts/localplt.awk to allow PLT or GOT references.
> 
> Tested on x86 and x86-64.  OK for master?

I'm a bit puzzled why this change is needed now, and wasn't part of
commit 9637d8a253493be471d9a71640e91349f7a8a050 at the end of July.
What has changed since then?

Thanks,
Florian
  
H.J. Lu Oct. 14, 2015, 12:37 p.m. UTC | #3
On Wed, Oct 14, 2015 at 5:27 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 09/25/2015 11:17 PM, H.J. Lu wrote:
>> On linker in binutils 2.26 and newer generate GOT references instead
>> PLT references when -z now is passed to linker.  We need to extend
>> scripts/localplt.awk to allow PLT or GOT references.
>>
>> Tested on x86 and x86-64.  OK for master?
>
> I'm a bit puzzled why this change is needed now, and wasn't part of
> commit 9637d8a253493be471d9a71640e91349f7a8a050 at the end of July.
> What has changed since then?
>

It doesn't cover --enable-bind-now.
  
Florian Weimer Oct. 14, 2015, 12:40 p.m. UTC | #4
On 10/14/2015 02:37 PM, H.J. Lu wrote:
> On Wed, Oct 14, 2015 at 5:27 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 09/25/2015 11:17 PM, H.J. Lu wrote:
>>> On linker in binutils 2.26 and newer generate GOT references instead
>>> PLT references when -z now is passed to linker.  We need to extend
>>> scripts/localplt.awk to allow PLT or GOT references.
>>>
>>> Tested on x86 and x86-64.  OK for master?
>>
>> I'm a bit puzzled why this change is needed now, and wasn't part of
>> commit 9637d8a253493be471d9a71640e91349f7a8a050 at the end of July.
>> What has changed since then?
>>
> 
> It doesn't cover --enable-bind-now.

Thanks for the explanation.  Looks good to me then.

Florian
  

Patch

diff --git a/scripts/localplt.awk b/scripts/localplt.awk
index f75b3b4..beaa342 100644
--- a/scripts/localplt.awk
+++ b/scripts/localplt.awk
@@ -7,7 +7,7 @@ 
 BEGIN { result = 0 }
 
 FILENAME != lastfile {
-  if (lastfile && jmprel_offset == 0) {
+  if (lastfile && jmprel_offset == 0 && rela_offset == 0 && rel_offset == 0) {
     print FILENAME ": *** failed to find expected output (readelf -WSdr)";
     result = 2;
   }
diff --git a/sysdeps/unix/sysv/linux/i386/localplt.data b/sysdeps/unix/sysv/linux/i386/localplt.data
index 2e03821..4ce8447 100644
--- a/sysdeps/unix/sysv/linux/i386/localplt.data
+++ b/sysdeps/unix/sysv/linux/i386/localplt.data
@@ -1,17 +1,17 @@ 
 # Linker in binutils 2.26 and newer consolidates R_X86_64_JUMP_SLOT
 # relocation with R_386_GLOB_DAT relocation against the same symbol.
-libc.so: _Unwind_Find_FDE
-libc.so: calloc
+libc.so: _Unwind_Find_FDE + REL R_386_GLOB_DAT
+libc.so: calloc + REL R_386_GLOB_DAT
 libc.so: free + REL R_386_GLOB_DAT
 libc.so: malloc + REL R_386_GLOB_DAT
-libc.so: memalign
-libc.so: realloc
+libc.so: memalign + REL R_386_GLOB_DAT
+libc.so: realloc + REL R_386_GLOB_DAT
 libm.so: matherr
 # The dynamic loader uses __libc_memalign internally to allocate aligned
 # TLS storage. The other malloc family of functions are expected to allow
 # user symbol interposition.
-ld.so: __libc_memalign
-ld.so: malloc
-ld.so: calloc
-ld.so: realloc
+ld.so: __libc_memalign + REL R_386_GLOB_DAT
+ld.so: malloc + REL R_386_GLOB_DAT
+ld.so: calloc + REL R_386_GLOB_DAT
+ld.so: realloc + REL R_386_GLOB_DAT
 ld.so: free + REL R_386_GLOB_DAT
diff --git a/sysdeps/x86_64/localplt.data b/sysdeps/x86_64/localplt.data
index d140476..f168b14 100644
--- a/sysdeps/x86_64/localplt.data
+++ b/sysdeps/x86_64/localplt.data
@@ -3,17 +3,17 @@ 
 # users can define their own functions and have library internals call them.
 # Linker in binutils 2.26 and newer consolidates R_X86_64_JUMP_SLOT
 # relocation with R_X86_64_GLOB_DAT relocation against the same symbol.
-libc.so: calloc
+libc.so: calloc + RELA R_X86_64_GLOB_DAT
 libc.so: free + RELA R_X86_64_GLOB_DAT
 libc.so: malloc + RELA R_X86_64_GLOB_DAT
-libc.so: memalign
-libc.so: realloc
+libc.so: memalign + RELA R_X86_64_GLOB_DAT
+libc.so: realloc + RELA R_X86_64_GLOB_DAT
 libm.so: matherr
 # The dynamic loader uses __libc_memalign internally to allocate aligned
 # TLS storage. The other malloc family of functions are expected to allow
 # user symbol interposition.
-ld.so: __libc_memalign
-ld.so: malloc
-ld.so: calloc
-ld.so: realloc
+ld.so: __libc_memalign + RELA R_X86_64_GLOB_DAT
+ld.so: malloc + RELA R_X86_64_GLOB_DAT
+ld.so: calloc + RELA R_X86_64_GLOB_DAT
+ld.so: realloc + RELA R_X86_64_GLOB_DAT
 ld.so: free + RELA R_X86_64_GLOB_DAT