https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69271

            Bug ID: 69271
           Summary: LTO drops weak binding from aliases
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

i guess it is related to bug 67548
but it happens without -r now.

void foo(void) {}
extern void foo_alias(void) __attribute__((weak, alias("foo")));
int bar = 0;
extern int bar_alias __attribute__((weak, alias("bar")));

compiled as

gcc -shared -fPIC -flto -o foo.so foo.c

$ readelf --dyn-sym -W foo.so |grep foo
     8: 0000000000000640     6 FUNC    GLOBAL DEFAULT   10 foo_alias
     9: 0000000000000640     6 FUNC    GLOBAL DEFAULT   10 foo
$ readelf --dyn-sym -W foo.so |grep bar
     4: 00000000002008cc     4 OBJECT  GLOBAL DEFAULT   21 bar
     6: 00000000002008cc     4 OBJECT  GLOBAL DEFAULT   21 bar_alias

without -flto i get the expected

$ readelf --dyn-sym -W foo.so |grep foo
     8: 0000000000000640     7 FUNC    WEAK   DEFAULT   10 foo_alias
     9: 0000000000000640     7 FUNC    GLOBAL DEFAULT   10 foo
$ readelf --dyn-sym -W foo.so |grep bar
     4: 00000000002008cc     4 OBJECT  GLOBAL DEFAULT   21 bar
     6: 00000000002008cc     4 OBJECT  WEAK   DEFAULT   21 bar_alias

this silently breaks the libc if it's compiled with lto

my gcc version is 6.0.0 20160113, tested on x86_64 and aarch64 targets.

Reply via email to