[llvm-branch-commits] [llvm] 607743e - [JITLink][COFF] Bound getGraphBlock by the section count (#239715)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Nov 11 01:51:44 PST 2026
Author: JP Hafer
Date: 2026-11-11T13:31:28+11:00
New Revision: 607743e51f1e504ae9c4bb61383afd956e3b74ee
URL: https://github.com/llvm/llvm-project/commit/607743e51f1e504ae9c4bb61383afd956e3b74ee
DIFF: https://github.com/llvm/llvm-project/commit/607743e51f1e504ae9c4bb61383afd956e3b74ee.diff
LOG: [JITLink][COFF] Bound getGraphBlock by the section count (#239715)
getGraphBlock checked the section index against the number of symbol
table entries instead of the number of sections. In an object with no
more symbol table entries than sections, valid sections had no block,
and linking failed with "Referencing a section that wasn't added to the
graph". An index past the last section read past the block table.
Assisted-by: Claude Code
Added:
llvm/test/ExecutionEngine/JITLink/x86-64/COFF_few_symbols.test
Modified:
llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h
index 171a30e1bfb9a7..269c00ba6ccf7e 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h
+++ b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h
@@ -72,7 +72,7 @@ class COFFLinkGraphBuilder {
Block *getGraphBlock(COFFSectionIndex SecIndex) const {
if (SecIndex <= 0 ||
- SecIndex >= static_cast<COFFSectionIndex>(GraphSymbols.size()))
+ SecIndex >= static_cast<COFFSectionIndex>(GraphBlocks.size()))
return nullptr;
return GraphBlocks[SecIndex];
}
diff --git a/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_few_symbols.test b/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_few_symbols.test
new file mode 100644
index 00000000000000..5012745e633645
--- /dev/null
+++ b/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_few_symbols.test
@@ -0,0 +1,21 @@
+# Check that an object with no more symbol table entries than sections links.
+#
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-jitlink -noexec %t
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ ]
+sections:
+ - Name: .text
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ SectionData: C3
+symbols:
+ - Name: main
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
More information about the llvm-branch-commits
mailing list