]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld: Clear map_head_is_link_order for .gnu_object_only
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 13 Jul 2025 21:21:32 +0000 (05:21 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 14 Jul 2025 01:12:38 +0000 (09:12 +0800)
Clear map_head_is_link_order when generating .gnu_object_only section so
that lang_add_section can add new sections and .sframe sections will be
properly merged by _bfd_elf_merge_section_sframe.

PR ld/33146
* ldlang.c (cmdline_emit_object_only_section): Clear
map_head_is_link_order.
* testsuite/ld-plugin/lto.exp (as_gsframe): New.
(lto_link_tests): Add $as_gsframe to compile lto-4b.o and
lto-4c.o.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
ld/ldlang.c
ld/testsuite/ld-plugin/lto.exp

index cd1825b1bc0b91d3f5c7ac2fc10a3b47bf7b17ab..d4b4ef2f29b1a724ae80e42239522ce6a5c592a9 100644 (file)
@@ -10887,6 +10887,9 @@ cmdline_emit_object_only_section (void)
   lang_init (true);
   ldexp_init (true);
 
+  /* Allow lang_add_section to add new sections.  */
+  map_head_is_link_order = false;
+
   /* Set up the object-only output. */
   lang_final ();
 
index f0d0954ab09a8f93c37afb39a333e02b96f777c9..d68e5f44397fdfa47fe72e347e44a210c3c7a5e8 100644 (file)
@@ -51,6 +51,11 @@ if { [check_lto_fat_available] } {
   set no_lto "-fno-lto"
 }
 
+set as_gsframe ""
+if { [gas_sframe_check] } {
+    set as_gsframe "-Wa,--gsframe"
+}
+
 # Simple LTO tests and generate input files for complex LTO tests.
 set lto_link_tests [list \
   [list "LTO 1" \
@@ -76,10 +81,10 @@ set lto_link_tests [list \
    "" "-flto $lto_fat" \
    {lto-4a.c} {} ""] \
   [list "Compile 4b" \
-   "" "-O2" \
+   "" "-O2 $as_gsframe" \
    {lto-4b.c} {} ""] \
   [list "Compile 4c" \
-   "" "-O2" \
+   "" "-O2 $as_gsframe" \
    {lto-4c.c} {} ""] \
   [list "Compile 5a" \
    "" "-flto $lto_fat" \