This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] Always define referenced __start_SECNAME/__stop_SECNAME
On Wed, Jun 14, 2017 at 8:30 PM, Alan Modra <firstname.lastname@example.org> wrote:
> On Wed, Jun 14, 2017 at 06:20:47AM -0700, H.J. Lu wrote:
>> On Tue, Jun 13, 2017 at 8:50 PM, Alan Modra <email@example.com> wrote:
>> > I see these fails. Please investigate and fix. The powerpc-linux
>> Most of tests are supported on targets without --gc-sections support or
>> with a leading underscore in symbol name. I checked in a couple patches
>> to address them.
>> > fails are due to leaving the __start and __stop symbols undefined when
>> > sizing dynamic sections, which is wrong. That at least needs to be
>> There is no need to discard relocs on undefined symbols with
>> non-default visibilty, which may be defined later like __start_SECNAME
>> and __stop_SECNAME, or are real errors. I am enclosing a patch here.
> No, it is quite reasonable to discard these relocations, and it is a
> maintenance nightmare when symbols change state between
> allocate_dynrelocs and relocate_section. Granted, that already
> happened for .startof. and .sizeof. symbols, but the existence of
It is normal for linker defined symbols to change state. BFD just
has to deal with it.
> those special symbols was an undocumented feature of gas and ld.
> Making that happen for __start and __stop too just makes the problem
The main difference is that __start_SECNAME and __stop_SECNAME
are marked as hidden. Here is a patch to check it.
> In future please state on the mailing list which targets you tested
> against when posting global changes. I assumed you had tested this
> change against a representative set of targets, but it's clear you
Sure. I also have a request for you. Please add a testcase when
you fix a global bug in the future, especially there is one in the bug
report. It will prevent your bug fix from being accidentally bypassed later.
From de2b347055d7d3f9764e7c19f3bf8913cb1b5bb9 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <firstname.lastname@example.org>
Date: Thu, 15 Jun 2017 04:10:58 -0700
Subject: [PATCH] ppc: Don't discard relocs on __start_SECNAME/__stop_SECNAME
__start_SECNAME and __stop_SECNAME may be undefined and hidden.
They will be defined by linker later.
* elf32-ppc.c (allocate_dynrelocs): Don't discard relocs on
__start_SECNAME and __stop_SECNAME.
bfd/elf32-ppc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index a4814fc..92cc18b 100644
@@ -6056,8 +6056,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
else if (bfd_link_pic (info))
- /* Discard relocs on undefined symbols that must be local. */
+ /* Discard relocs on undefined symbols that must be local.
+ start_stop is set on __start_SECNAME/__stop_SECNAME which
+ mark section SECNAME and will be defined by linker later. */
if (h->root.type == bfd_link_hash_undefined
+ && !h->start_stop
&& ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
eh->dyn_relocs = NULL;