+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
".text.unlikely",
".text.exit",
".text.startup",
- ".text.hot"
+ ".text.hot",
+ ".text.sorted"
};
for (size_t i = 0;
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)
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();
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;
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"
+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.
${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)
${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)
${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)
${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)
*(.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)
*(.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)
*(.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)