[binutils-gdb] lto: Don't check format of IR dummy file
H.J. Lu
hjl@sourceware.org
Fri Aug 28 06:22:15 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d658ddcc389085970ac025414cae7ad908f40726
commit d658ddcc389085970ac025414cae7ad908f40726
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Aug 28 09:08:39 2026 +0800
lto: Don't check format of IR dummy file
1. Don't check format of IR dummy file in lang_check.
2. Allow empty DESTLIST in lang_list_remove_tail.
PR ld/34572
* ldlang.c (lang_check): Don't check format of IR dummy file.
(debug_file_chain): New.
(debug_input_files): Use debug_file_chain.
(lang_list_remove_tail): Also check empty DESTLIST.
* testsuite/ld-plugin/dummy.s: Add .note.GNU-stack section.
* testsuite/ld-plugin/lto.exp: Add PR ld/34572 tests.
* testsuite/ld-plugin/pr34572.rd: New file.
* testsuite/ld-plugin/pr34572a.c: Likewise.
* testsuite/ld-plugin/pr34572b.c: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Diff:
---
ld/ldlang.c | 19 ++++++++++---
ld/testsuite/ld-plugin/dummy.s | 2 +-
ld/testsuite/ld-plugin/lto.exp | 57 +++++++++++++++++++++++++++++++++++++++
ld/testsuite/ld-plugin/pr34572.rd | 6 +++++
ld/testsuite/ld-plugin/pr34572a.c | 8 ++++++
ld/testsuite/ld-plugin/pr34572b.c | 4 +++
6 files changed, 91 insertions(+), 5 deletions(-)
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 65494acca00..2e4f9fffbee 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7617,6 +7617,9 @@ lang_check (void)
if (file->flags.claimed)
continue;
input_bfd = file->the_bfd;
+ /* Don't check format of IR dummy file. */
+ if ((input_bfd->flags & BFD_PLUGIN) != 0)
+ continue;
compatible
= bfd_arch_get_compatible (input_bfd, link_info.output_bfd,
command_line.accept_unknown_input_arch);
@@ -7926,11 +7929,11 @@ lang_set_flags (lang_memory_region_type *ptr, const char *flags, int invert)
}
static void
-debug_input_files (void)
+debug_file_chain (lang_statement_list_type *chain)
{
lang_input_statement_type *f;
- for (f = &input_file_chain.head->input_statement;
+ for (f = &chain->head->input_statement;
f != NULL;
f = f->next_real_file)
if (f->the_bfd)
@@ -7939,6 +7942,12 @@ debug_input_files (void)
fprintf (stderr, "input: %s\n", f->filename);
}
+static void
+debug_input_files (void)
+{
+ debug_file_chain (&input_file_chain);
+}
+
/* Call a function on each real input file. This function will be
called on an archive, but not on the elements. */
@@ -8392,8 +8401,10 @@ lang_list_remove_tail (lang_statement_list_type *destlist,
lang_statement_list_type *origlist)
{
union lang_statement_union **savetail;
- /* Check that ORIGLIST really is an earlier state of DESTLIST. */
- ASSERT (origlist->head == destlist->head);
+ /* Check that ORIGLIST really is an earlier state of DESTLIST or an
+ empty list. */
+ ASSERT ((origlist->head == NULL && origlist->tail == &destlist->head)
+ || origlist->head == destlist->head);
savetail = origlist->tail;
origlist->head = *(savetail);
origlist->tail = destlist->tail;
diff --git a/ld/testsuite/ld-plugin/dummy.s b/ld/testsuite/ld-plugin/dummy.s
index 8b137891791..0f5ab47ca42 100644
--- a/ld/testsuite/ld-plugin/dummy.s
+++ b/ld/testsuite/ld-plugin/dummy.s
@@ -1 +1 @@
-
+ .section .note.GNU-stack,"",%progbits
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 4504fd4be01..1e3fe182e14 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -1385,4 +1385,61 @@ if { [check_lto_fat_available] } {
}
}
+# Skip native x32 and i?86 targets since system LLVMgold.so may not be
+# compatible with native x32 and i?86 targets binutils.
+if { ![istarget "x86_64-*-linux*-gnux32"]
+ && ![istarget "i?86-*-*"]
+ && [info exists CLANG_FOR_TARGET]
+ && ![string match "" $llvm_plug_opt] } {
+ set CC_FOR_TARGET_saved "$CC_FOR_TARGET"
+ set CC_FOR_TARGET "$CLANG_FOR_TARGET"
+ run_cc_link_tests [list \
+ [list \
+ "Build pr34572a.o" \
+ "" \
+ "-flto" \
+ {pr34572a.c} \
+ ] \
+ [list \
+ "Build pr34572b.o" \
+ "" \
+ "-flto" \
+ {pr34572b.c} \
+ ] \
+ [list \
+ "Build pr34572a.exe" \
+ "-flto -Wl,--start-lib tmpdir/pr34572a.o -Wl,--end-lib" \
+ "" \
+ {dummy.s} \
+ {} \
+ "pr34572a.exe"
+ ] \
+ ]
+
+ if { [isnative] } {
+ if {[file exists tmpdir/pr34572a.exe]} {
+ set exec_output [run_host_cmd "tmpdir/pr34572a.exe" ""]
+ if [string match "PASS\n" $exec_output] then {
+ pass "Run pr34572a.exe"
+ } else {
+ fail "Run pr34572a.exe"
+ }
+ }
+ }
+
+ run_ld_link_tests [list \
+ [list \
+ "Build pr34572b.exe" \
+ "$llvm_plug_opt --start-lib tmpdir/pr34572b.o --end-lib" \
+ "" \
+ "" \
+ {dummy.s} \
+ {{readelf {-sW} pr34572.rd}} \
+ "pr34572b.exe" \
+ ] \
+ ]
+
+ set CC_FOR_TARGET "$CC_FOR_TARGET_saved"
+}
+
restore_notify
diff --git a/ld/testsuite/ld-plugin/pr34572.rd b/ld/testsuite/ld-plugin/pr34572.rd
new file mode 100644
index 00000000000..dcf0d108a83
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr34572.rd
@@ -0,0 +1,6 @@
+#...
+Symbol table '\.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: +[0-9a-f]+ +[0-9]+ +FUNC +GLOBAL +DEFAULT .*[0-9]+ _start
+#pass
diff --git a/ld/testsuite/ld-plugin/pr34572a.c b/ld/testsuite/ld-plugin/pr34572a.c
new file mode 100644
index 00000000000..4e63772629e
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr34572a.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int
+main (void)
+{
+ printf ("PASS\n");
+ return 0;
+}
diff --git a/ld/testsuite/ld-plugin/pr34572b.c b/ld/testsuite/ld-plugin/pr34572b.c
new file mode 100644
index 00000000000..ca92bf15a24
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr34572b.c
@@ -0,0 +1,4 @@
+void
+_start (void)
+{
+}
More information about the Binutils-cvs
mailing list