Bug 25351 - .ARM.attributes not found
Summary: .ARM.attributes not found
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: 2.34
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-07 14:48 UTC by Jerome Guitton
Modified: 2020-01-10 13:36 UTC (History)
0 users

See Also:
Host:
Target: aarch64-elf
Build: x86_64-pc-linux-gnu
Last reconfirmed: 2020-01-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Guitton 2020-01-07 14:48:00 UTC
Hello,

This change may have been only partially implemented:


commit b8a6ced79668ec8af3180e50b76f7517ebbab0d9
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Jul 3 17:57:36 2018 +0930

    Correct removal of .gnu.attributes

    Setting SEC_EXCLUDE for empty .gnu.attributes is too late in the link
    process for the linker to remove the section.  That must be done in
    bfd_elf_final_link, as we do for removed group sections.

        * elflink.c (bfd_elf_final_link): Remove zero size .gnu.attributes
        sections.


Since then, a link with -r and a simple link directive for ARM.attributes would fail.

 bash% aarch64-elf-gcc -c r.c
 bash% aarch64-elf-ld -o r.out -r r.o -T l.ld
 aarch64-elf-ld: r.out: could not find output section .ARM.attributes for input section .ARM.attributes
 aarch64-elf-ld: final link failed: nonrepresentable section on output


Am I missing something?


Here is the reproducer:

bash% cat l.ld
SECTIONS
{
.ARM.attributes : {
   __ARM.attributes_start = .;
   *(.ARM.attributes)
   __ARM.attributes_end = .;
   }
}

bash% cat r.c 
/* { dg-lto-do link } */
/* { dg-lto-options {{-r -nostdlib}} } */
/* { dg-extra-ld-options "-flinker-output=nolto-rel" } */
int exported_var = 42;
/* { dg-final { scan-symbol "exported_var" } } */
Comment 1 cvs-commit@gcc.gnu.org 2020-01-08 12:57:08 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4c6ee6465acc58f0f86c44668c4e862901186239

commit 4c6ee6465acc58f0f86c44668c4e862901186239
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Jan 8 11:36:01 2020 +1030

    PR25351 .ARM.attributes not found for symbol
    
    	PR 25351
    	* elflink.c (bfd_elf_final_link): Call _bfd_fix_excluded_sec_syms
    	after removing sections.
Comment 2 Alan Modra 2020-01-10 11:39:04 UTC
Fixed.  You might like to fix your scripts too.  Symbols are usually best defined in the final link.  Those defined by ld -r are either going to be redefined in the final link or run the risk of being wrong.
Comment 3 Jerome Guitton 2020-01-10 13:36:24 UTC
amodra at gmail dot com (sourceware-bugzilla@sourceware.org):

> Fixed.  You might like to fix your scripts too.  Symbols are usually best
> defined in the final link.  Those defined by ld -r are either going to be
> redefined in the final link or run the risk of being wrong.

Thanks a lot!
- Jerome