Introduce new .text.sorted.* sections.
authorMartin Liska <mliska@suse.cz>
Wed, 18 Sep 2019 11:23:34 +0000 (13:23 +0200)
committerMartin Liska <mliska@suse.cz>
Tue, 26 Nov 2019 16:20:10 +0000 (17:20 +0100)
gold/ChangeLog:

2019-11-26  Martin Liska  <mliska@suse.cz>

* layout.cc (Layout::special_ordering_of_input_section):
Add ".text.sorted".
* output.cc: Special case ".text.sorted".
* testsuite/section_sorting_name.cc: Cover also .text.sorted
subsections.
* testsuite/section_sorting_name.sh: Likewise.

ld/ChangeLog:

2019-11-26  Martin Liska  <mliska@suse.cz>

* scripttempl/arclinux.sc: Add .text.sorted.* which is sorted
by default.
* scripttempl/elf.sc: Likewise.
* scripttempl/elf64bpf.sc: Likewise.
* scripttempl/nds32elf.sc: Likewise.
* testsuite/ld-arm/arm-no-rel-plt.ld: Expect .text.sorted.*
in the default linker script.
* testsuite/ld-arm/fdpic-main.ld: Likewise.
* testsuite/ld-arm/fdpic-shared.ld: Likewise.

13 files changed:
gold/ChangeLog
gold/layout.cc
gold/output.cc
gold/testsuite/section_sorting_name.cc
gold/testsuite/section_sorting_name.sh
ld/ChangeLog
ld/scripttempl/arclinux.sc
ld/scripttempl/elf.sc
ld/scripttempl/elf64bpf.sc
ld/scripttempl/nds32elf.sc
ld/testsuite/ld-arm/arm-no-rel-plt.ld
ld/testsuite/ld-arm/fdpic-main.ld
ld/testsuite/ld-arm/fdpic-shared.ld

index 9d71814ae313da2df09d634e702ddfdb70dec6cc..3dc2ce81b7265d3fc631d50b6cf8123f3f6f0938 100644 (file)
@@ -1,3 +1,12 @@
+2019-11-26  Martin Liska  <mliska@suse.cz>
+
+       * layout.cc (Layout::special_ordering_of_input_section):
+       Add ".text.sorted".
+       * output.cc: Special case ".text.sorted".
+       * testsuite/section_sorting_name.cc: Cover also .text.sorted
+       subsections.
+       * testsuite/section_sorting_name.sh: Likewise.
+
 2019-11-19  Alan Modra  <amodra@gmail.com>
 
        PR 24853
index 194d088c2a19a4cce1f22ce53f87db77e983ca99..4a6a7f69dd5e58e5488620250e45c70992fd5663 100644 (file)
@@ -1129,7 +1129,8 @@ Layout::special_ordering_of_input_section(const char* name)
     ".text.unlikely",
     ".text.exit",
     ".text.startup",
-    ".text.hot"
+    ".text.hot",
+    ".text.sorted"
   };
 
   for (size_t i = 0;
index df80587e666d36592747ace913f26c010ee180ce..428a880b147f4c47e348a5343e777bfbbfd5cbd4 100644 (file)
@@ -3547,8 +3547,10 @@ Output_section::Input_section_sort_section_prefix_special_ordering_compare
     const Output_section::Input_section_sort_entry& s2) const
 {
   // Some input section names have special ordering requirements.
-  int o1 = Layout::special_ordering_of_input_section(s1.section_name().c_str());
-  int o2 = Layout::special_ordering_of_input_section(s2.section_name().c_str());
+  const char *s1_section_name = s1.section_name().c_str();
+  const char *s2_section_name = s2.section_name().c_str();
+  int o1 = Layout::special_ordering_of_input_section(s1_section_name);
+  int o2 = Layout::special_ordering_of_input_section(s2_section_name);
   if (o1 != o2)
     {
       if (o1 < 0)
@@ -3558,6 +3560,8 @@ Output_section::Input_section_sort_section_prefix_special_ordering_compare
       else
        return o1 < o2;
     }
+  else if (is_prefix_of(".text.sorted", s1_section_name))
+    return strcmp(s1_section_name, s2_section_name) <= 0;
 
   // Keep input order otherwise.
   return s1.index() < s2.index();
index 3a1d9baac3c079d8abc3ef46e20cc90f0ce202c5..8270b400aa86a19b087d41a44f4c7ce400c5a99e 100644 (file)
@@ -50,6 +50,49 @@ int hot_foo_0002()
   return 1;
 }
 
+extern "C"
+__attribute__ ((section(".text.sorted.0002")))
+int sorted_foo_0002()
+{
+  return 1;
+}
+
+extern "C"
+__attribute__ ((section(".text.sorted.0001.abc")))
+int sorted_foo_0001_abc()
+{
+  return 1;
+}
+
+
+extern "C"
+__attribute__ ((section(".text.sorted.0001")))
+int sorted_foo_0001()
+{
+  return 1;
+}
+
+extern "C"
+__attribute__ ((section(".text.sorted.0003")))
+int sorted_foo_0003()
+{
+  return 1;
+}
+
+extern "C"
+__attribute__ ((section(".text.sorted.z")))
+int sorted_foo_z()
+{
+  return 1;
+}
+
+extern "C"
+__attribute__ ((section(".text.sorted.y")))
+int sorted_foo_y()
+{
+  return 1;
+}
+
 int vdata_0002  __attribute__((section(".data.0002"))) = 2;
 int vbss_0002 __attribute__((section(".bss.0002"))) = 0;
 
index ae44570f7f41d7927fa92d68e37a820fa73c2e3e..00ad7cc20a6189852710e29b7d52dcf2b212cc58 100755 (executable)
@@ -59,6 +59,12 @@ END {
 check section_sorting_name.stdout "hot_foo_0001" "hot_foo_0002"
 check section_sorting_name.stdout "hot_foo_0002" "hot_foo_0003"
 
+check section_sorting_name.stdout "sorted_foo_0001" "sorted_foo_0001_abc"
+check section_sorting_name.stdout "sorted_foo_0001_abc" "sorted_foo_0002"
+check section_sorting_name.stdout "sorted_foo_0002" "sorted_foo_0003"
+check section_sorting_name.stdout "sorted_foo_0003" "sorted_foo_y"
+check section_sorting_name.stdout "sorted_foo_y" "sorted_foo_z"
+
 check section_sorting_name.stdout "vdata_0001" "vdata_0002"
 check section_sorting_name.stdout "vdata_0002" "vdata_0003"
 
index 029de5f0b951dae63d78a97e520eaae65ad464fb..969ab78035253121d445d9ba86537bae2429eb4a 100644 (file)
@@ -1,3 +1,15 @@
+2019-11-26  Martin Liska  <mliska@suse.cz>
+
+       * scripttempl/arclinux.sc: Add .text.sorted.* which is sorted
+       by default.
+       * scripttempl/elf.sc: Likewise.
+       * scripttempl/elf64bpf.sc: Likewise.
+       * scripttempl/nds32elf.sc: Likewise.
+       * testsuite/ld-arm/arm-no-rel-plt.ld: Expect .text.sorted.*
+       in the default linker script.
+       * testsuite/ld-arm/fdpic-main.ld: Likewise.
+       * testsuite/ld-arm/fdpic-shared.ld: Likewise.
+
 2019-11-25  Alan Modra  <amodra@gmail.com>
 
        * ldexp.c (fold_name): Pass section to bfd_octets_per_byte.
index e13969ede07eac5cd86a0f7d8058b7d41b521ae8..41e8ccdf1b2476814b2d2619eaf7e61d4a606f84 100644 (file)
@@ -491,6 +491,7 @@ cat <<EOF
     ${RELOCATING+*(.text.exit .text.exit.*)}
     ${RELOCATING+*(.text.startup .text.startup.*)}
     ${RELOCATING+*(.text.hot .text.hot.*)}
+    ${RELOCATING+*(SORT(.text.sorted.*))}
     *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
     /* .gnu.warning sections are handled specially by elf.em.  */
     *(.gnu.warning)
index c3ad467bff42d9641a52928066d0aa28e15e1ec0..0d61881185018071cc20475c8477af1f958cf76a 100644 (file)
@@ -514,6 +514,7 @@ cat <<EOF
     ${RELOCATING+*(.text.exit .text.exit.*)}
     ${RELOCATING+*(.text.startup .text.startup.*)}
     ${RELOCATING+*(.text.hot .text.hot.*)}
+    ${RELOCATING+*(SORT(.text.sorted.*))}
     *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
     /* .gnu.warning sections are handled specially by elf.em.  */
     *(.gnu.warning)
index de73775349af9906b33aaee29917b8cd05d4ef0c..7937a41d2cfd210306e3034033bfee0afb2eca26 100644 (file)
@@ -512,6 +512,7 @@ cat <<EOF
     ${RELOCATING+*(.text.exit .text.exit.*)}
     ${RELOCATING+*(.text.startup .text.startup.*)}
     ${RELOCATING+*(.text.hot .text.hot.*)}
+    ${RELOCATING+*(SORT(.text.sorted.*))}
     *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
     /* .gnu.warning sections are handled specially by elf.em.  */
     *(.gnu.warning)
index 065c984f705aa4de9b8a21b0a18d36c13f52caa5..8d8d6e3f74fd836d5929fd0d9d079e7efa545784 100644 (file)
@@ -438,6 +438,7 @@ cat <<EOF
     ${RELOCATING+*(.text.exit .text.exit.*)}
     ${RELOCATING+*(.text.startup .text.startup.*)}
     ${RELOCATING+*(.text.hot .text.hot.*)}
+    ${RELOCATING+*(SORT(.text.sorted.*))}
     *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
     /* .gnu.warning sections are handled specially by elf.em.  */
     *(.gnu.warning)
index d56e8203ad836cc2bd0517d04103f8841f835108..14c1aeb4397e7aaa095a1134e334fe5e913c0255 100644 (file)
@@ -65,6 +65,7 @@ SECTIONS
     *(.text.exit .text.exit.*)
     *(.text.startup .text.startup.*)
     *(.text.hot .text.hot.*)
+    *(SORT(.text.sorted.*))
     *(.text .stub .text.* .gnu.linkonce.t.*)
     /* .gnu.warning sections are handled specially by elf.em.  */
     *(.gnu.warning)
index d19a589d6c6a84deacad22c0cbb70e6d9d1904cb..b01b630fea7eef99daffedf94328e993192e0ba4 100644 (file)
@@ -76,6 +76,7 @@ SECTIONS
     *(.text.exit .text.exit.*)
     *(.text.startup .text.startup.*)
     *(.text.hot .text.hot.*)
+    *(SORT(.text.sorted.*))
     *(.text .stub .text.* .gnu.linkonce.t.*)
     /* .gnu.warning sections are handled specially by elf.em.  */
     *(.gnu.warning)
index b1e262d8297c2013c50d2070ed4afb8ba77e4eac..b710ffa745212be2087c380ac78a27cda72c85af 100644 (file)
@@ -67,6 +67,7 @@ SECTIONS
     *(.text.exit .text.exit.*)
     *(.text.startup .text.startup.*)
     *(.text.hot .text.hot.*)
+    *(SORT(.text.sorted.*))
     *(.text .stub .text.* .gnu.linkonce.t.*)
     /* .gnu.warning sections are handled specially by elf.em.  */
     *(.gnu.warning)
This page took 0.033125 seconds and 4 git commands to generate.