Treat SHT_FINI_ARRAY and SHT_PREINIT_ARRAY as relocatable sections
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 30 Aug 2018 15:01:36 +0000 (08:01 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 30 Aug 2018 15:03:34 +0000 (08:03 -0700)
Since SHT_FINI_ARRAY and SHT_PREINIT_ARRAY sections are relocatable,
this patch fixes readelf and adds a testcase.

binutils/

* readelf.c (process_section_headers): Treat SHT_FINI_ARRAY and
SHT_PREINIT_ARRAY as relocatable sections.

gas/

* testsuite/gas/elf/elf.exp: Run section14.
* testsuite/gas/elf/section14.d: New file.
* testsuite/gas/elf/section14.s: Likewise.

binutils/ChangeLog
binutils/readelf.c
gas/ChangeLog
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/section14.d [new file with mode: 0644]
gas/testsuite/gas/elf/section14.s [new file with mode: 0644]

index 6b036db6a2e777a28fedb4c7466e31af166afef7..a3d1354375086bf3c1e09792a78a185168636bbf 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-30  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * readelf.c (process_section_headers): Treat SHT_FINI_ARRAY and
+       SHT_PREINIT_ARRAY as relocatable sections.
+
 2018-08-30  Chenghua Xu  <paul.hua.gm@gmail.com>
 
        * MAINTAINERS: Add myself as a MIPS port maintainer.
index 194f1c3e0cf3bc38b39714260a691b7f0fa601cb..9c675ddf1e130d52226b5fb5817235e96f6070ad 100644 (file)
@@ -6359,6 +6359,8 @@ process_section_headers (Filedata * filedata)
                  && filedata->section_headers[section->sh_info].sh_type != SHT_NOBITS
                  && filedata->section_headers[section->sh_info].sh_type != SHT_NOTE
                  && filedata->section_headers[section->sh_info].sh_type != SHT_INIT_ARRAY
+                 && filedata->section_headers[section->sh_info].sh_type != SHT_FINI_ARRAY
+                 && filedata->section_headers[section->sh_info].sh_type != SHT_PREINIT_ARRAY
                  /* FIXME: Are other section types valid ?  */
                  && filedata->section_headers[section->sh_info].sh_type < SHT_LOOS))
            {
index 37b3560f32b8861018b202fcbe1de10558e6a8ef..aa8633a98fef1d91439d5646507d36639656ae2f 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-30  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * testsuite/gas/elf/elf.exp: Run section14.
+       * testsuite/gas/elf/section14.d: New file.
+       * testsuite/gas/elf/section14.s: Likewise.
+
 2018-08-29  Daniel Cederman  <cederman@gaisler.com>
 
        * testsuite/gas/sparc/leon.d: New test.
index a7c793b0b0c37567a04310de900ab8f981b9429e..ee4aa57c247c1b32553c1d25b7ee4491e8fe5581 100644 (file)
@@ -219,6 +219,7 @@ if { [is_elf_format] } then {
     run_dump_test "section12a"
     run_dump_test "section12b"
     run_dump_test "section13"
+    run_dump_test "section14"
     run_dump_test "dwarf2-1"
     run_dump_test "dwarf2-2"
     run_dump_test "dwarf2-3"
diff --git a/gas/testsuite/gas/elf/section14.d b/gas/testsuite/gas/elf/section14.d
new file mode 100644 (file)
index 0000000..82b8a77
--- /dev/null
@@ -0,0 +1,10 @@
+#name: array sections
+#as: --no-pad-sections
+#readelf: -S --wide
+
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ +\[Nr\] Name +Type +Addr(ess|) +Off +Size +ES +Flg +Lk +Inf +Al
+ +\[ 0\] +NULL +0+ +0+ +0+ +0+ +0 +0 +0
+#pass
diff --git a/gas/testsuite/gas/elf/section14.s b/gas/testsuite/gas/elf/section14.s
new file mode 100644 (file)
index 0000000..992bbe6
--- /dev/null
@@ -0,0 +1,18 @@
+       .section        .init_array
+       .align 4
+       .type   init_array, %object
+       .size   init_array, 4
+init_array:
+       .dc.a   foo
+       .section        .preinit_array
+       .align 4
+       .type   preinit_array, %object
+       .size   preinit_array, 4
+preinit_array:
+       .dc.a   foo
+       .section        .fini_array
+       .align 4
+       .type   fini_array, %object
+       .size   fini_array, 4
+fini_array:
+       .dc.a   foo
This page took 0.067337 seconds and 4 git commands to generate.