This is the mail archive of the
mailing list for the binutils project.
Re: Symbols defined via linker script: local or global?
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: Alan Modra <amodra at gmail dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Thu, 7 Jul 2016 14:47:45 +0200
- Subject: Re: Symbols defined via linker script: local or global?
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com> <20160512121548.GB2111@bubble.grove.modra.org> <firstname.lastname@example.org> <20160512124228.GC2111@bubble.grove.modra.org> <57347A7F.email@example.com> <577DEF03.firstname.lastname@example.org> <20160707122622.GK6605@bubble.grove.modra.org>
On 07/07/16 14:26, Alan Modra wrote:
On Thu, Jul 07, 2016 at 07:56:19AM +0200, Sebastian Huber wrote:
sorry for the delay. I have now a test case. It seems to be related to the
Indeed. elf_gc_sweep_symbol is forcing the symbols local. The
problem is that lang_gc_sections runs fairly early in the linking
process, before sections are laid out, and your script is defining
symbols inside output section statements. Although
lang_do_assignments runs before lang_gc_sections, it doesn't descend
into output section statements. That results in the assignments
"SC = .;" and "SD = .;" not being performed. So SC, which was an
undefined symbol in your object file, stays undefined. SD remains
unknown, until the "SF = SD;" assignment, where the reference makes it
an undefined symbol. Somewhat oddly, this assignment doesn't put SF
into the symbol hash table (because the expression for its value
wasn't valid). So when elf_gc_sweep_symbol runs, it sees SA and SB
defined, and SC, SD and SE undefined. SF is unknown. Even though SA,
SC and SE are referenced from your object file, their section is
discarded, and thus relocations in that section do not mark their
symbols. elf_gc_sweep_symbol forces unmarked undefined symbols
lang_do_assignments probably should descend into output section
statements, and all the fallout from not having a BFD section,
thanks for your analysis. It looks complicated, is this a bug or a
feature? If its a bug, is it worth to fix or is my use case too exotic?
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : email@example.com
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.