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: [RFC] gas: don't emit stray unversioned symbol when using ".symver x,x at v"


On Mon, Jul 27, 2015 at 9:25 AM, Cary Coutant <ccoutant@gmail.com> wrote:
> If you try to version a symbol using the same name, e.g., ".symver
> x,x@v", gas will emit two symbols in the .o file -- an unversioned x
> and a versioned x, as in this example from HJ's patch for PR 18720:
>
> $ cat indirect3b.c
> #include <stdio.h>
>
> void
> foo (void)
> {
>   printf ("MAIN\n");
> }
>
> asm (".symver foo,foo@FOO");
> $ gcc -c -fpic indirect3b.c
> $ nm indirect3b.o
> 0000000000000000 T foo
> 0000000000000000 T foo@FOO
>                  U _GLOBAL_OFFSET_TABLE_
> 0000000000000000 r .LC0
>                  U puts
>
> The first unversioned definition of "foo" leads to problems in both ld and gold:
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=18703
> https://sourceware.org/bugzilla/show_bug.cgi?id=18720
>
> The following patch to gas eliminates the extra unversioned
> definition, and solves both problems:
>
> diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
> index 78dc6d9..8668be0 100644
> --- a/gas/config/obj-elf.c
> +++ b/gas/config/obj-elf.c
> @@ -2182,6 +2182,11 @@ elf_frob_symbol (symbolS *symp, int *puntp)
>               memmove (&p[2], &p[3], l);
>               S_SET_NAME (symp, sy_obj->versioned_name);
>             }
> +         else if (strncmp (S_GET_NAME (symp), sy_obj->versioned_name,
> +                           strlen (S_GET_NAME (symp))) == 0)
> +           {
> +             S_SET_NAME (symp, sy_obj->versioned_name);
> +           }
>           else
>             {
>               symbolS *symp2;
>
> With this patch, we get:
>
> $ nm indirect3b.o
> 0000000000000000 T foo@FOO
>                  U _GLOBAL_OFFSET_TABLE_
> 0000000000000000 r .LC0
>                  U puts
>
> There are a couple of testcases whose expected results would need to
> be adjusted, so I wanted to solicit more opinions about whether this
> is an appropriate change to the assembler before submitting formally
> as a patch.

I think this patch is incorrect as shown by linker test regressions:

FAIL: ELF symbol versioning
FAIL: Indirect symbol 1a: : local symbol `foo' in tmpdir/indirect1b.o
is referenced by DSO
FAIL: Indirect symbol 1a: : final link failed: Bad value
FAIL: Indirect symbol 1b: : local symbol `foo' in tmpdir/indirect1b.o
is referenced by DSO
FAIL: Indirect symbol 1b: : final link failed: Bad value
FAIL: Run with libindirect3c.so 1
FAIL: Run with libindirect3c.so 2
FAIL: Run with libindirect3c.so 3
FAIL: Run with libindirect3c.so 4
FAIL: vers24a
FAIL: vers24b
FAIL: ELF symbol versioning
FAIL: symver symver1

-- 
H.J.


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