aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2019-09-18 13:23:34 +0200
committerMartin Liska <mliska@suse.cz>2019-11-26 17:20:10 +0100
commit5fa5f8f5fe494ba4fe98c11899a5464cd164ec75 (patch)
tree451d1fa4e113336dd195ecb9628767da592d9553
parent239b426b11425c4bd6b36aa7fd92a01e74fd42cb (diff)
downloadgdb-5fa5f8f5fe494ba4fe98c11899a5464cd164ec75.zip
gdb-5fa5f8f5fe494ba4fe98c11899a5464cd164ec75.tar.gz
gdb-5fa5f8f5fe494ba4fe98c11899a5464cd164ec75.tar.bz2
Introduce new .text.sorted.* sections.
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.
-rw-r--r--gold/ChangeLog9
-rw-r--r--gold/layout.cc3
-rw-r--r--gold/output.cc8
-rw-r--r--gold/testsuite/section_sorting_name.cc43
-rwxr-xr-xgold/testsuite/section_sorting_name.sh6
-rw-r--r--ld/ChangeLog12
-rw-r--r--ld/scripttempl/arclinux.sc1
-rw-r--r--ld/scripttempl/elf.sc1
-rw-r--r--ld/scripttempl/elf64bpf.sc1
-rw-r--r--ld/scripttempl/nds32elf.sc1
-rw-r--r--ld/testsuite/ld-arm/arm-no-rel-plt.ld1
-rw-r--r--ld/testsuite/ld-arm/fdpic-main.ld1
-rw-r--r--ld/testsuite/ld-arm/fdpic-shared.ld1
13 files changed, 85 insertions, 3 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 9d71814..3dc2ce8 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -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
diff --git a/gold/layout.cc b/gold/layout.cc
index 194d088c..4a6a7f6 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -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;
diff --git a/gold/output.cc b/gold/output.cc
index df80587..428a880 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -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();
diff --git a/gold/testsuite/section_sorting_name.cc b/gold/testsuite/section_sorting_name.cc
index 3a1d9ba..8270b40 100644
--- a/gold/testsuite/section_sorting_name.cc
+++ b/gold/testsuite/section_sorting_name.cc
@@ -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;
diff --git a/gold/testsuite/section_sorting_name.sh b/gold/testsuite/section_sorting_name.sh
index ae44570..00ad7cc 100755
--- a/gold/testsuite/section_sorting_name.sh
+++ b/gold/testsuite/section_sorting_name.sh
@@ -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"
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 029de5f..969ab78 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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.
diff --git a/ld/scripttempl/arclinux.sc b/ld/scripttempl/arclinux.sc
index e13969e..41e8ccd 100644
--- a/ld/scripttempl/arclinux.sc
+++ b/ld/scripttempl/arclinux.sc
@@ -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)
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index c3ad467..0d61881 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -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)
diff --git a/ld/scripttempl/elf64bpf.sc b/ld/scripttempl/elf64bpf.sc
index de73775..7937a41 100644
--- a/ld/scripttempl/elf64bpf.sc
+++ b/ld/scripttempl/elf64bpf.sc
@@ -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)
diff --git a/ld/scripttempl/nds32elf.sc b/ld/scripttempl/nds32elf.sc
index 065c984..8d8d6e3 100644
--- a/ld/scripttempl/nds32elf.sc
+++ b/ld/scripttempl/nds32elf.sc
@@ -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)
diff --git a/ld/testsuite/ld-arm/arm-no-rel-plt.ld b/ld/testsuite/ld-arm/arm-no-rel-plt.ld
index d56e820..14c1aeb 100644
--- a/ld/testsuite/ld-arm/arm-no-rel-plt.ld
+++ b/ld/testsuite/ld-arm/arm-no-rel-plt.ld
@@ -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)
diff --git a/ld/testsuite/ld-arm/fdpic-main.ld b/ld/testsuite/ld-arm/fdpic-main.ld
index d19a589..b01b630 100644
--- a/ld/testsuite/ld-arm/fdpic-main.ld
+++ b/ld/testsuite/ld-arm/fdpic-main.ld
@@ -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)
diff --git a/ld/testsuite/ld-arm/fdpic-shared.ld b/ld/testsuite/ld-arm/fdpic-shared.ld
index b1e262d..b710ffa 100644
--- a/ld/testsuite/ld-arm/fdpic-shared.ld
+++ b/ld/testsuite/ld-arm/fdpic-shared.ld
@@ -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)