This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Gold complains about relocations from note sections to discarded sections
- From: Nick Clifton <nickc at redhat dot com>
- To: iant at google dot com, ccoutant at gmail dot com
- Cc: binutils at sourceware dot org
- Date: Fri, 13 Jul 2018 10:33:42 +0100
- Subject: Gold complains about relocations from note sections to discarded sections
Hi Ian, Hi Cary,
Gold will complain if there is a relocation in a note section
that references a symbol in a discarded section. For example:
% cat note.s
.section .text.unused
.word 1
% as --generate-missing-build-notes=yes note.s -o note.o
% gold --gc-sections note.o
note.o(.gnu.build.attributes+0x14): error: relocation refers to local symbol "" [1], which is defined in a discarded section
note.o(.gnu.build.attributes+0x1c): error: relocation refers to local symbol "" [1], which is defined in a discarded section
note.o(.gnu.build.attributes+0x38): error: relocation refers to local symbol "" [4], which is defined in a discarded section
note.o(.gnu.build.attributes+0x40): error: relocation refers to local symbol "" [4], which is defined in a discarded section
I have a small patch (see below) which handles this specific case, but
I really think that gold ought to be ignoring any relocs in note
sections (or maybe any non-ALLOC section) that are against discarded
sections.
What do you think ?
Cheers
Nick
diff --git a/gold/target-reloc.h b/gold/target-reloc.h
index 6bde51dc31..3b4decf262 100644
--- a/gold/target-reloc.h
+++ b/gold/target-reloc.h
@@ -136,6 +136,7 @@ class Default_comdat_behavior
if (Layout::is_debug_info_section(name))
return CB_PRETEND;
if (strcmp(name, ".eh_frame") == 0
+ || strcmp(name, ".gnu.build.attributes") == 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;