[PATCH] Always define referenced __start_SECNAME/__stop_SECNAME
H.J. Lu
hjl.tools@gmail.com
Tue Jun 13 02:10:00 GMT 2017
On Mon, Jun 12, 2017 at 6:54 PM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Jun 12, 2017 at 05:18:58PM -0700, H.J. Lu wrote:
>> On Mon, Jun 12, 2017 at 4:32 PM, Alan Modra <amodra@gmail.com> wrote:
>> > On Sat, Jun 10, 2017 at 03:46:49PM -0700, H.J. Lu wrote:
>> >> This patch changes linker to always define referenced __start_SECNAME and
>> >> __stop_SECNAME if the input section name is the same output section name,
>> >> which is always true for orphaned sections, and SECNAME is a C identifier.
>> >
>> > I think this change is reasonable.
>> >
>> >> Also __start_SECNAME and __stop_SECNAME symbols are marked as hidden by
>> >> ELF linker.
>> >
>> > Why is this necessary? Also, you make another change in behaviour
>>
>> It is to make sure that __start_SECNAME and __stop_SECNAME
>> symbols for section SECNAME in different modules are unique.
>
> I understand, and it would have been good if these symbols were
> defined that way in the beginning, but they weren't. I'm concerned
> that if you make this change as well we will find some code that
> relies on the symbols being dynamic.
My change fixes a real bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=20022
We can suggest workarounds if some codes depend on that.
>>
>> > that you don't mention: __start and __stop symbols were previously
>> > defined by ld -Ur, not just at final link. You'll need to modify
>>
>> Is there a testcase for this behavior?
>
> Not that I'm aware of.
>
>From ld manual:
'-Ur'
For anything other than C++ programs, this option is equivalent to
'-r': it generates relocatable output--i.e., an output file that
can in turn serve as input to 'ld'. When linking C++ programs,
'-Ur' _does_ resolve references to constructors, unlike '-r'. It
does not work to use '-Ur' on files that were themselves linked
with '-Ur'; once the constructor table has been built, it cannot be
added to. Use '-Ur' only for the last partial link, and '-r' for
the others.
It isn't intended for __start_SECNAME and __stop_SECNAME. Check
config.build_constructors for __start_SECNAME and __stop_SECNAME
was introduced by:
commit 71bfc0aef6964c54b8e29466e97fb246cdeb2049
Author: Alan Modra <amodra@gmail.com>
Date: Thu Sep 7 07:08:58 2000 +0000
Fix list handling for orphan section output statements.
diff --git a/ld/ChangeLog b/ld/ChangeLog
index e9ca684..0292f83 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2000-09-07 Alan Modra <alan@linuxcare.com.au>
+
+ * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Fix
+ broken list handling. Create __start_SECNAME and __stop_SECNAME
+ when no place-holder. Add some comments. Test both SEC_CODE and
+ SEC_READONLY for hold_text to prevent .rodata orphan poisoning.
Do you remember if it was done on purpose to generate
__start_SECNAME and __stop_SECNAME for -Ur? If yes,
we can add your use case as a testcase.
Here is the updated patch to address
https://sourceware.org/bugzilla/show_bug.cgi?id=21571
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Always-define-referenced-__start_SECNAME-__stop_SECN.patch
Type: text/x-patch
Size: 41737 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20170613/788fdcc1/attachment.bin>
More information about the Binutils
mailing list