This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix localplt check for GNU_IFUNC
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>, "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Wed, 19 Mar 2014 14:47:54 -0400
- Subject: Re: [PATCH] Fix localplt check for GNU_IFUNC
- Authentication-results: sourceware.org; auth=none
- References: <531B63DE dot 5090803 at linux dot vnet dot ibm dot com>
On 03/08/2014 01:39 PM, Adhemerval Zanella wrote:
> While reviewing the strncat optimization for powerpc64 I noted in the
> disassembled object that a call to strlen (bl strlen) generates a PLT
> call to strlen (since now strlen is an IFUNC for powerpc64). Strangely
> it was not being caught by check-localplt testcase.
>
> GNU_IFUNC are shown by readelf in 'Relocation section' value as (symbol)
> instead of expected hexadecimal value. This causes the check-localplt
> script to igore potential PLT stub begin generated by wrong IFUNC usage.
> This patch changes the localplt script to emit such PLT cases.
>
> Checked on PPC64 and X86_64.
>
> --
>
> 2014-03-03 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
>
> * scripts/localplt.awk: Do not ignore IFUNC relocation while parsing
> relocation sections.
Can you show example output?
On x86-64 I see:
0000003000bba030 0000034400000007 R_X86_64_JUMP_SLOT memset() memset + 0
0000003000bba048 000007ba00000007 R_X86_64_JUMP_SLOT memmove() memmove + 0
Not (memset) or (memmove).
I'd like to see this fixed... and this is the first patch in patchtracker :-)
> ---
>
> diff --git a/scripts/localplt.awk b/scripts/localplt.awk
> index 2265b02..5e38073 100644
> --- a/scripts/localplt.awk
> +++ b/scripts/localplt.awk
> @@ -32,9 +32,15 @@ $1 == "Offset" && $2 == "Info" { in_relocs = 1; next }
> NF == 0 { in_relocs = 0 }
>
> in_relocs && relocs_offset == jmprel_offset && NF >= 5 {
> - symval = strtonum("0x" $4);
> - if (symval != 0)
> + # Relocations against GNU_IFUNC symbols are not shown as an hexadecimal
> + # value, but rather as the resolver symbol name between ().
> + if ($4 ~ /\(.*\)/) {
> print whatfile, $5
> + } else {
> + symval = strtonum("0x" $4);
> + if (symval != 0)
> + print whatfile, $5
> + }
> }
>
> in_relocs { next }
>