This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug lto/59582] New: LTO discards symbol that defined as weak elsewhere


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59582

            Bug ID: 59582
           Summary: LTO discards symbol that defined as weak elsewhere
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joey.ye at arm dot com

~/work/lto_startup_s/3 $ cat Makefile 
CC=gcc
CFLAGS=-flto
EXT_CFLAGS=
e : ext.o main.o
    $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
ext.o : ext.c
    $(CC) $(EXT_CFLAGS) -c -o $@ $^

~/work/lto_startup_s/3 $ cat main.c
int callback() { return 0; }
int main() { return s_func(); }

~/work/lto_startup_s/3 $ cat ext.c
__attribute__((weak)) int callback() { return 1; }
int s_func() { return callback(); }
~/work/lto_startup_s/3 $ make -B
gcc  -c -o ext.o ext.c
gcc -flto   -c -o main.o main.c
gcc -flto  ext.o main.o -o e
`callback' referenced in section `.text' of ext.o: defined in discarded section
`.text' of main.o (symbol from plugin)
collect2: error: ld returned 1 exit status
make: *** [e] Error 1

~/work/lto_startup_s/3 $ gcc -v
gcc version 4.9.0 20131223 (experimental)

Hints to reproduce:
1. ext.c is compiled without lto
2. main.o shows before ext.o in command line


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