[patch] Nios II build_id fix
Cesar Philippidis
cesar@codesourcery.com
Wed Apr 9 00:16:00 GMT 2014
On 4/5/14, 10:12 PM, Alan Modra wrote:
> On Sat, Apr 05, 2014 at 09:16:10PM -0600, Sandra Loosemore wrote:
>> On 04/04/2014 07:31 PM, Alan Modra wrote:
>>> On Fri, Apr 04, 2014 at 10:52:22AM -0700, Cesar Philippidis wrote:
>>>> @@ -2016,6 +2016,10 @@ nios2_elf32_build_stubs (struct bfd_link
>>>> {
>>>> bfd_size_type size;
>>>>
>>>> + /* Ignore non-stub sections. */
>>>> + if (!strstr (stub_sec->name, STUB_SUFFIX))
>>>> + continue;
>>>
>>> Um, how do you manage to get non-stub sections in the stub bfd? Hmm,
>>> via dynobj being set to the stub bfd, I expect. If so, you could
>>> probably test (stub_sec->flags & SEC_LINKER_CREATED) == 0 instead.
>>
>> I had the same question when looking at this code. I think this
>> also suffers from the same bug (PR 13049) mentioned in the comment
>> on STUB_SUFFIX in elf32-arm.c.
>>
>> Hmmmm. I see that stub sections are being created without
>> SEC_LINKER_CREATED (ld/emultempl/nios2elf.em), while dynamic
>> sections created in dynobj do have that flag by default (from
>> ELF_DYNAMIC_SEC_FLAGS). Other sections that end up in dynobj maybe
>> do, maybe don't
>
> What other sections? I don't think there will be any. You'll either
> have stub sections or dynobj sections. The latter all have
> SEC_LINKER_CREATED, the former doesn't.
>
> I handle exactly the same situation in elf64-ppc.c, where dynobj is
> forced to be the stub bfd, without resorting to testing for
> STUB_SUFFIX in the name.
>
> Note that elf32-arm.c only needs to test for the stub name because the
> ARM backend does create other sections (glue, veneer) in the stub bfd
> besides stub sections. nios2 doesn't, as far as I can see.
Checking for dynobjs seemed to work out. I've tested this patch on both
ELF and Linux Nios II targets. Is it OK?
Thanks,
Cesar
-------------- next part --------------
2014-04-08 Cesar Philippidis <cesar@codesourcery.com>
bfd/
* elf32-nios2.c (nios2_elf32_build_stubs): Ignore dynobjs
when building function stubs.
Index: bfd/elf32-nios2.c
===================================================================
--- bfd/elf32-nios2.c (revision 430290)
+++ bfd/elf32-nios2.c (working copy)
@@ -2013,16 +2013,18 @@ nios2_elf32_build_stubs (struct bfd_link
for (stub_sec = htab->stub_bfd->sections;
stub_sec != NULL;
stub_sec = stub_sec->next)
- {
- bfd_size_type size;
-
- /* Allocate memory to hold the linker stubs. */
- size = stub_sec->size;
- stub_sec->contents = bfd_zalloc (htab->stub_bfd, size);
- if (stub_sec->contents == NULL && size != 0)
- return FALSE;
- stub_sec->size = 0;
- }
+ /* A dynobj may be forced to be a stub bfd, so ignore it here. */
+ if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
+ {
+ bfd_size_type size;
+
+ /* Allocate memory to hold the linker stubs. */
+ size = stub_sec->size;
+ stub_sec->contents = bfd_zalloc (htab->stub_bfd, size);
+ if (stub_sec->contents == NULL && size != 0)
+ return FALSE;
+ stub_sec->size = 0;
+ }
/* Build the stubs as directed by the stub hash table. */
table = &htab->bstab;
More information about the Binutils
mailing list