This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PR21287, Inconsistent section type for .init_array and .init_array.42
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 10 Apr 2017 17:10:41 +0930
- Subject: PR21287, Inconsistent section type for .init_array and .init_array.42
- Authentication-results: sourceware.org; auth=none
PR21287 notes that .init_array is correctly given a type of
SHT_INIT_ARRAY while .init_array.nnn gets SHT_PROGBITS. This patch
fixes that problem, and properly drops warnings from the compiler that
would cause the testsuite to fail. My a44d0bd78 change to check
ld_compile status, necessary to pick up compile errors, also meant
warnings were not ignored.
bfd/
PR 21287
* elf.c (special_sections_f): Match .fini_array and .fini_array.*.
(special_sections_i): Likewise for .init_array.
(special_sections_p): Likewise for .preinit_array.
ld/
PR 21287
* testsuite/ld-elf/init-fini-arrays.d: Match INIT_ARRAY and FINI_ARRAY.
* testsuite/ld-elf/init-fini-arrays.s: Use %init_array and %fini_array
section types.
* testsuite/lib/ld-lib.exp (default_ld_compile): Trim assembler
warnings about "ignoring incorrect section type".
(run_ld_link_exec_tests, run_cc_link_tests): Delete old comment.
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a4664f8..1d8ef2a 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2017-04-10 Alan Modra <amodra@gmail.com>
+
+ PR 21287
+ * elf.c (special_sections_f): Match .fini_array and .fini_array.*.
+ (special_sections_i): Likewise for .init_array.
+ (special_sections_p): Likewise for .preinit_array.
+
2017-04-07 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19579
diff --git a/bfd/elf.c b/bfd/elf.c
index dcb0e6f..1f02d42 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2601,9 +2601,9 @@ static const struct bfd_elf_special_section special_sections_d[] =
static const struct bfd_elf_special_section special_sections_f[] =
{
- { STRING_COMMA_LEN (".fini"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
- { STRING_COMMA_LEN (".fini_array"), 0, SHT_FINI_ARRAY, SHF_ALLOC + SHF_WRITE },
- { NULL, 0, 0, 0, 0 }
+ { STRING_COMMA_LEN (".fini"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
+ { STRING_COMMA_LEN (".fini_array"), -2, SHT_FINI_ARRAY, SHF_ALLOC + SHF_WRITE },
+ { NULL, 0 , 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_g[] =
@@ -2628,10 +2628,10 @@ static const struct bfd_elf_special_section special_sections_h[] =
static const struct bfd_elf_special_section special_sections_i[] =
{
- { STRING_COMMA_LEN (".init"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
- { STRING_COMMA_LEN (".init_array"), 0, SHT_INIT_ARRAY, SHF_ALLOC + SHF_WRITE },
- { STRING_COMMA_LEN (".interp"), 0, SHT_PROGBITS, 0 },
- { NULL, 0, 0, 0, 0 }
+ { STRING_COMMA_LEN (".init"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
+ { STRING_COMMA_LEN (".init_array"), -2, SHT_INIT_ARRAY, SHF_ALLOC + SHF_WRITE },
+ { STRING_COMMA_LEN (".interp"), 0, SHT_PROGBITS, 0 },
+ { NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_l[] =
@@ -2649,9 +2649,9 @@ static const struct bfd_elf_special_section special_sections_n[] =
static const struct bfd_elf_special_section special_sections_p[] =
{
- { STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY, SHF_ALLOC + SHF_WRITE },
- { STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
- { NULL, 0, 0, 0, 0 }
+ { STRING_COMMA_LEN (".preinit_array"), -2, SHT_PREINIT_ARRAY, SHF_ALLOC + SHF_WRITE },
+ { STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
+ { NULL, 0, 0, 0, 0 }
};
static const struct bfd_elf_special_section special_sections_r[] =
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 4255b5e..4dcfd81 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,15 @@
2017-04-10 Alan Modra <amodra@gmail.com>
+ PR 21287
+ * testsuite/ld-elf/init-fini-arrays.d: Match INIT_ARRAY and FINI_ARRAY.
+ * testsuite/ld-elf/init-fini-arrays.s: Use %init_array and %fini_array
+ section types.
+ * testsuite/lib/ld-lib.exp (default_ld_compile): Trim assembler
+ warnings about "ignoring incorrect section type".
+ (run_ld_link_exec_tests, run_cc_link_tests): Delete old comment.
+
+2017-04-10 Alan Modra <amodra@gmail.com>
+
* testsuite/ld-elfvsb/elfvsb.exp (visibility_run): Delete
sh1p.o, sh2p.o, sh1np.o and sh2np.o before compiling. Use
remote_file host exists rather than file exists.
diff --git a/ld/testsuite/ld-elf/init-fini-arrays.d b/ld/testsuite/ld-elf/init-fini-arrays.d
index 46b536c..912373d 100644
--- a/ld/testsuite/ld-elf/init-fini-arrays.d
+++ b/ld/testsuite/ld-elf/init-fini-arrays.d
@@ -7,7 +7,7 @@
# well with unique group sections under ld -r.
#...
- \[[ 0-9]+\] \.init_array\.01000[ \t]+PROGBITS[ \t0-9a-f]+WA?.*
+ \[[ 0-9]+\] \.init_array\.01000[ \t]+INIT_ARRAY[ \t0-9a-f]+WA?.*
#...
- \[[ 0-9]+\] \.fini_array\.01000[ \t]+PROGBITS[ \t0-9a-f]+WA?.*
+ \[[ 0-9]+\] \.fini_array\.01000[ \t]+FINI_ARRAY[ \t0-9a-f]+WA?.*
#pass
diff --git a/ld/testsuite/ld-elf/init-fini-arrays.s b/ld/testsuite/ld-elf/init-fini-arrays.s
index 8f7a3f7..6740ed6 100644
--- a/ld/testsuite/ld-elf/init-fini-arrays.s
+++ b/ld/testsuite/ld-elf/init-fini-arrays.s
@@ -1,6 +1,7 @@
- .section .init_array.01000,"aw",%progbits
- .align 4
- .word 0
- .section .fini_array.01000,"aw",%progbits
- .align 4
- .word 0
+ .section .init_array.01000,"aw",%init_array
+ .p2align 2
+ .word 0
+
+ .section .fini_array.01000,"aw",%fini_array
+ .p2align 2
+ .word 0
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index bdce739..b60fcad 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -282,6 +282,11 @@ proc default_ld_compile { cc source object } {
remote_file build delete "ld.tmp"
remote_file host delete "ld.tmp"
set exec_output [prune_warnings $exec_output]
+ # Versions of gcc up to and including pre-release gcc-7, at least on
+ # some targets, generate .section directives with incorrect type.
+ # Ignore warnings from the assembler about this.
+ regsub -all "(^|\n)\[^\n\]*: ignoring incorrect section type \[^\n\]*" $exec_output "" exec_output
+ regsub -all "^\[^\n\]*: Assembler messages:\n" $exec_output "" exec_output
if [string match "" $exec_output] then {
if {![file exists $object]} then {
regexp ".*/(\[^/\]*)$" $source all dobj
@@ -1421,9 +1426,6 @@ proc run_ld_link_exec_tests { ldtests args } {
set objfile "tmpdir/$fileroot.o"
lappend objfiles $objfile
- # We ignore warnings since some compilers may generate
- # incorrect section attributes and the assembler will warn
- # them.
if { [ string match "c++" $lang ] } {
set cmd "$CXX -c $CXXFLAGS $cflags"
} else {
@@ -1598,9 +1600,6 @@ proc run_cc_link_tests { ldtests } {
set objfile "tmpdir/$fileroot.o"
lappend objfiles $objfile
- # We ignore warnings since some compilers may generate
- # incorrect section attributes and the assembler will warn
- # them.
if { [ string match "c++" $lang ] } {
set cmd "$CXX -c $CXXFLAGS $cflags"
} else {
--
Alan Modra
Australia Development Lab, IBM