Bug 1600431

Summary: binutils: gold chokes on files assembled with --generate-missing-build-notes
Product: [Fedora] Fedora Reporter: Florian Weimer <fweimer>
Component: binutilsAssignee: Nick Clifton <nickc>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: dvlasenk, fweimer, herrold, howaboutsynergy, jakub, nickc, petersen, rjones, samuel-rhbugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: binutils-2.30.90-3.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-27 22:48:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
crti.o
none
crtn.o
none
crti.o none

Description Florian Weimer 2018-07-12 08:41:11 UTC
Compiling this simple program:

int
main (void)
{
  return 0;
}

with:

gcc -fuse-ld=gold -Wl,--gc-sections main.c

results in:

/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crti.o(.gnu.build.attributes+0x14): error: relocation refers to local symbol "" [1], which is defined in a discarded section
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crti.o(.gnu.build.attributes+0x1c): error: relocation refers to local symbol "" [1], which is defined in a discarded section
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crtn.o(.gnu.build.attributes+0x14): error: relocation refers to local symbol "" [1], which is defined in a discarded section
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crtn.o(.gnu.build.attributes+0x1c): error: relocation refers to local symbol "" [1], which is defined in a discarded section
collect2: error: ld returned 1 exit status

I'm attaching the crti.o file for reference.

Package versions:

binutils-2.30.90-2.fc29.x86_64
gcc-8.1.1-4.fc29.1.x86_64
glibc-2.27.9000-38.fc29.x86_64

Comment 1 Florian Weimer 2018-07-12 08:42:06 UTC
Created attachment 1458286 [details]
crtn.o

Comment 2 Florian Weimer 2018-07-12 08:42:51 UTC
Created attachment 1458287 [details]
crti.o

Comment 3 Nick Clifton 2018-07-12 16:20:32 UTC
I have added code to gold to skip warnings about unresolvable relocations in the .gnu.build.attributes section.  It already code to do this for several other sections, so I did not feel too bad about making the change.

Long term I need to discuss with the gold maintainers about the correct way
to handle this situation.  I suspect that it will turn into another case where section groups need to be used.

Fixed in: binutils-2.30.90-3.fc29

Comment 4 Raphael Groner 2018-07-26 06:11:29 UTC
Not sure if bug #1605019 was a duplicate.

Comment 5 Jan Kurik 2018-08-14 11:17:02 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 29 development cycle.
Changing version to '29'.

Comment 6 SEA7nK96vHh6h7UmBc 2019-04-12 06:36:53 UTC
If anyone else is interested in the patch from Nick Clifton from comment #3 
it's NOT part of binutils repo located at https://sourceware.org/git/binutils-gdb.git looked at latest (at this time) commit 3822612df0694cc07597e534fa73b34aa2540812 (HEAD -> master, origin/master, origin/HEAD) Date:   Fri Apr 12 00:00:26 2019 +0000

But I found it inside https://download-ib01.fedoraproject.org/pub/fedora/linux/updates/testing/29/Everything/SRPMS/Packages/b/binutils-2.31.1-25.fc29.src.rpm
with filename binutils-gold-ignore-discarded-note-relocs.patch

I can't attach files, but its contents look like this:

```patch
--- binutils.orig/gold/target-reloc.h	2018-07-12 11:37:24.894494658 +0100
+++ binutils-2.30.90/gold/target-reloc.h	2018-07-12 15:38:50.049083904 +0100
@@ -136,6 +136,7 @@ class Default_comdat_behavior
     if (Layout::is_debug_info_section(name))
       return CB_PRETEND;
     if (strcmp(name, ".eh_frame") == 0
+	|| strncmp(name, ".gnu.build.attributes", 21) == 0 	// FIXME: We should really be checking the section type for ST_NOTE...
 	|| strcmp(name, ".gcc_except_table") == 0)
       return CB_IGNORE;
     return CB_ERROR;
```

Now I will to try to see if I can use this patch for this similar Rust issue* for section named `.stack_sizes` 
* https://github.com/rust-lang/rust/issues/59652#issuecomment-482253086

Comment 7 SEA7nK96vHh6h7UmBc 2019-04-12 11:07:55 UTC
Note that I didn't hit this issue (using Comment 0 reproduction steps, AND the below steps) admitedly with ArchLinux's(not RedHat's) binutils [2.31.1-4](https://git.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/binutils&id=0de772f54ba7ac042b88d9db53ba1f586e89edce) and the unreleased-in-ArchLinux(yet) [2.32-1](https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/binutils&id=8e3f40011ddc933f016d6f126c3b3cb24e711c28) and they do not use the above patch, which means that the patch(in Comment 6) is no longer needed and that makes me wonder how else did the binutils devs fix this issue? or, maybe I'm missing something here, since I'm on a different OS!

I used these to test:

int
main (void)
{
  return 0;
}

gcc -fuse-ld=gold -Wl,--gc-sections main.c -Wa,--generate-missing-build-notes=yes                                                                               


local/binutils 2.32-2 (base-devel builtbydaddy)
    A set of programs to assemble and manipulate binary and object files
local/gcc 8.2.1+20181127-1 (base-devel)
    The GNU Compiler Collection - C and C++ frontends
local/gcc-libs 8.2.1+20181127-1 (base)
    Runtime libraries shipped by GCC
local/lib32-gcc-libs 8.2.1+20181127-1 (multilib-devel)
    32-bit runtime libraries shipped by GCC
local/glibc 2.29-1 (builtbydaddy base)
    GNU C Library
local/lib32-glibc 2.29-1 (builtbydaddy)
    GNU C Library (32-bit)

Comment 8 Ben Cotton 2019-10-31 19:09:36 UTC
This message is a reminder that Fedora 29 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 29 on 2019-11-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '29'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 29 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 9 Ben Cotton 2019-11-27 22:48:10 UTC
Fedora 29 changed to end-of-life (EOL) status on 2019-11-26. Fedora 29 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.