This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ifunc plt synthetic syms


On Fri, Jul 10, 2009 at 3:32 AM, Alan Modra<amodra@bigpond.net.au> wrote:
> IRELATIVE relocs in the PLT don't have a symbol, so currently we
> generate synthetic symbols for them of *ABS*@plt, which isn't very
> helpful. ?On RELA targets it's easy to do better, like so
>
> ? ? ? ? ?* elf.c (_bfd_elf_get_synthetic_symtab): Report addends.
>
> Index: bfd/elf.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elf.c,v
> retrieving revision 1.483
> diff -u -p -r1.483 elf.c
> --- bfd/elf.c ? 27 Jun 2009 16:07:09 -0000 ? ? ?1.483
> +++ bfd/elf.c ? 10 Jul 2009 08:08:20 -0000
> @@ -8922,7 +8922,17 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd
> ? size = count * sizeof (asymbol);
> ? p = relplt->relocation;
> ? for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel)
> - ? ?size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
> + ? ?{
> + ? ? ?size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
> + ? ? ?if (p->addend != 0)
> + ? ? ? {
> +#ifdef BFD64
> + ? ? ? ? size += sizeof ("+0x") - 1 + 8 + 8 * (bed->s->elfclass == ELFCLASS64);
> +#else
> + ? ? ? ? size += sizeof ("+0x") - 1 + 8;
> +#endif
> + ? ? ? }
> + ? ?}
>
> ? s = *ret = bfd_malloc (size);
> ? if (s == NULL)
> @@ -8953,6 +8963,13 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd
> ? ? ? len = strlen ((*p->sym_ptr_ptr)->name);
> ? ? ? memcpy (names, (*p->sym_ptr_ptr)->name, len);
> ? ? ? names += len;
> + ? ? ?if (p->addend != 0)
> + ? ? ? {
> + ? ? ? ? memcpy (names, "+0x", sizeof ("+0x") - 1);
> + ? ? ? ? names += sizeof ("+0x") - 1;
> + ? ? ? ? bfd_sprintf_vma (abfd, names, p->addend);
> + ? ? ? ? names += strlen (names);
> + ? ? ? }
> ? ? ? memcpy (names, "@plt", sizeof ("@plt"));
> ? ? ? names += sizeof ("@plt");
> ? ? ? ++s, ++n;
>

I checked in this patch to remove leading zeros in addend and update
the ifunc testcases.

Thanks.

-- 
H.J.
Index: ld/testsuite/ChangeLog
===================================================================
--- ld/testsuite/ChangeLog      (revision 6362)
+++ ld/testsuite/ChangeLog      (working copy)
@@ -1,3 +1,11 @@
+2009-07-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * ld-ifunc/ifunc-1-local-x86.d: Updated.
+       * ld-ifunc/ifunc-1-x86.d: Likewise.Likewise.
+       * ld-ifunc/ifunc-2-local-x86-64.d: Likewise.Likewise.
+       * ld-ifunc/ifunc-2-x86-64.d: Likewise.
+       * ld-ifunc/ifunc-3a-x86.d: Likewise.Likewise.
+
 2009-07-10  Alan Modra  <amodra@bigpond.net.au>

        * ld-ifunc/ifunc.exp: Run for powerpc.  Really generate static
Index: ld/testsuite/ld-ifunc/ifunc-2-x86-64.d
===================================================================
--- ld/testsuite/ld-ifunc/ifunc-2-x86-64.d      (revision 6361)
+++ ld/testsuite/ld-ifunc/ifunc-2-x86-64.d      (working copy)
@@ -4,6 +4,6 @@
 #target: x86_64-*-*

 #...
-[ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*@plt>
-[ \t0-9a-f]+:[ \t0-9a-f]+lea[ \t]+.*\(%rip\),%rax.*[ \t0-9a-fq]+<\*ABS\*@plt>
+[ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*\+0x220@plt>
+[ \t0-9a-f]+:[ \t0-9a-f]+lea[ \t]+.*\(%rip\),%rax.*[
\t0-9a-fq]+<\*ABS\*\+0x220@plt>
 #pass
Index: ld/testsuite/ld-ifunc/ifunc-1-x86.d
===================================================================
--- ld/testsuite/ld-ifunc/ifunc-1-x86.d (revision 6361)
+++ ld/testsuite/ld-ifunc/ifunc-1-x86.d (working copy)
@@ -3,5 +3,5 @@
 #target: x86_64-*-* i?86-*-*

 #...
-[ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*@plt>
+[ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*\+0x220@plt>
 #pass
Index: ld/testsuite/ld-ifunc/ifunc-3a-x86.d
===================================================================
--- ld/testsuite/ld-ifunc/ifunc-3a-x86.d        (revision 6361)
+++ ld/testsuite/ld-ifunc/ifunc-3a-x86.d        (working copy)
@@ -4,5 +4,5 @@
 #target: x86_64-*-* i?86-*-*

 #...
-[ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*@plt>
+[ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*\+0x258@plt>
 #pass
Index: ld/testsuite/ld-ifunc/ifunc-2-local-x86-64.d
===================================================================
--- ld/testsuite/ld-ifunc/ifunc-2-local-x86-64.d        (revision 6361)
+++ ld/testsuite/ld-ifunc/ifunc-2-local-x86-64.d        (working copy)
@@ -4,6 +4,6 @@
 #target: x86_64-*-*

 #...
-[ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*@plt>
-[ \t0-9a-f]+:[ \t0-9a-f]+lea[ \t]+.*\(%rip\),%rax.*[ \t0-9a-fq]+<\*ABS\*@plt>
+[ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*\+0x220@plt>
+[ \t0-9a-f]+:[ \t0-9a-f]+lea[ \t]+.*\(%rip\),%rax.*[
\t0-9a-fq]+<\*ABS\*\+0x220@plt>
 #pass
Index: ld/testsuite/ld-ifunc/ifunc-1-local-x86.d
===================================================================
--- ld/testsuite/ld-ifunc/ifunc-1-local-x86.d   (revision 6361)
+++ ld/testsuite/ld-ifunc/ifunc-1-local-x86.d   (working copy)
@@ -3,5 +3,5 @@
 #target: x86_64-*-* i?86-*-*

 #...
-[ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*@plt>
+[ \t0-9a-f]+:[ \t0-9a-f]+call[ \t0-9a-fq]+<\*ABS\*\+0x200@plt>
 #pass
Index: bfd/elf.c
===================================================================
--- bfd/elf.c   (revision 6362)
+++ bfd/elf.c   (working copy)
@@ -8965,10 +8965,16 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd
       names += len;
       if (p->addend != 0)
        {
+         char buf[30], *a;
+         int len;
          memcpy (names, "+0x", sizeof ("+0x") - 1);
          names += sizeof ("+0x") - 1;
-         bfd_sprintf_vma (abfd, names, p->addend);
-         names += strlen (names);
+         bfd_sprintf_vma (abfd, buf, p->addend);
+         for (a = buf; *a == '0'; ++a)
+           ;
+         len = strlen (a);
+         memcpy (names, a, len);
+         names += len;
        }
       memcpy (names, "@plt", sizeof ("@plt"));
       names += sizeof ("@plt");
Index: bfd/ChangeLog
===================================================================
--- bfd/ChangeLog       (revision 6362)
+++ bfd/ChangeLog       (working copy)
@@ -1,3 +1,8 @@
+2009-07-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf.c (_bfd_elf_get_synthetic_symtab): Remove leading zeros
+       when reporting  addends.
+
 2009-07-10  Alan Modra  <amodra@bigpond.net.au>

        * elf32-ppc.c (ppc_elf_howto_raw): Add R_PPC_IRELATIVE.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]