Bug 13779 - multiple definition symbol error when using gcc's lto and ld script
Summary: multiple definition symbol error when using gcc's lto and ld script
Status: RESOLVED WORKSFORME
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-28 02:57 UTC by Bin Tian
Modified: 2014-07-28 06:11 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bin Tian 2012-02-28 02:57:25 UTC
If an object file compiled with -flto is loaded by using ld script, the final
ld procedure will report multiple definition error.

$ cat a.c
int main (){return 0;}
$ cat a.ld
INPUT(a.o)
$ gcc -flto -c a.c
$ gcc -flto a.ld
/tmp/ccPbuiPm.ltrans0.ltrans.o: In function `main':
ccPbuiPm.ltrans0.o:(.text+0x0): multiple definition of `main'
a.o:a.c:(.text+0x0): first defined here
a.o: In function `main':
a.c:(.text+0x0): multiple definition of `main'
a.o:a.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status

This bug is also subbmited to gcc, please go to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52401
Comment 1 Alan Modra 2014-07-28 06:11:39 UTC
I believe this bug was fixed in 2.23