This is the mail archive of the
mailing list for the binutils project.
RE: LD script: global symbols and multiple defintions
- From: Ted Carter <tcarter at broadcom dot com>
- To: 'Alan Modra' <amodra at gmail dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 18 Dec 2014 17:24:04 +0000
- Subject: RE: LD script: global symbols and multiple defintions
- Authentication-results: sourceware.org; auth=none
- References: <loom dot 20141218T002405-365 at post dot gmane dot org> <20141218065418 dot GE23483 at bubble dot grove dot modra dot org>
No, not using PROVIDE since the symbol would use the definition from the program. I'm interested in what should happen when linker script variables conflict with symbols in the program. The only reference in the ld docs I could find on this topic was the example in PROVIDE. From the example:
_etext = .;
PROVIDE(etext = .);
"In this example, if the program defines `_etext' (with a leading underscore), the linker will give a multiple definition error."
If I replace _etext with foo and link with an object file that defines foo, like in my snippet, shouldn't I get an error?
From: Alan Modra [mailto:firstname.lastname@example.org]
Sent: Wednesday, December 17, 2014 10:54 PM
To: Ted Carter
Subject: Re: LD script: global symbols and multiple defintions
On Thu, Dec 18, 2014 at 12:59:34AM +0000, Ted Carter wrote:
> I was expecting that a global symbol defined in a linker script (e.g. foo =
> 0x3000) would produce a multiple definition error if a non-weak symbol is
> already defined in an object file on the link line, but this didn't happen.
> Instead, references will always resolve to the global definition without
> throwing a diag if it's defined elsewhere. My expectation is based on
> verbage in https://sourceware.org/binutils/docs-2.24/ld/PROVIDE.html#PROVIDE.
But you were not using PROVIDE??
Australia Development Lab, IBM