[llvm] 01baeda - [JITLink][ELF] Handle BSS sections, improve some error messages.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 21:36:02 PDT 2020
Author: Lang Hames
Date: 2020-10-05T21:35:35-07:00
New Revision: 01baeda7ca6645f5d8455733b110c89203a61ccf
URL: https://github.com/llvm/llvm-project/commit/01baeda7ca6645f5d8455733b110c89203a61ccf
DIFF: https://github.com/llvm/llvm-project/commit/01baeda7ca6645f5d8455733b110c89203a61ccf.diff
LOG: [JITLink][ELF] Handle BSS sections, improve some error messages.
This patch enables basic BSS section handling, and improves a couple of error
messages in the ELF section parsing code.
Patch by Christian Schafmeister. Thanks Christian!
Differential Revision: https://reviews.llvm.org/D88867
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index 20295434d2e5..40c7d04378e5 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -357,6 +357,9 @@ class ELFLinkGraphBuilder_x86_64 {
if (SecRef.sh_type == ELF::SHT_SYMTAB)
// TODO: Dynamic?
SymTab = SecRef;
+ } else {
+ auto &Section = G->createSection(*Name, Prot);
+ G->createZeroFillBlock(Section, Size, Address, Alignment, 0);
}
}
@@ -480,7 +483,8 @@ class ELFLinkGraphBuilder_x86_64 {
return Name.takeError();
auto Section = G->findSectionByName(*Name);
if (!Section)
- return make_error<llvm::StringError>("Could not find a section",
+ return make_error<llvm::StringError>("Could not find a section " +
+ *Name,
llvm::inconvertibleErrorCode());
// we only have one for now
auto blocks = Section->blocks();
@@ -527,7 +531,8 @@ class ELFLinkGraphBuilder_x86_64 {
auto JitSection = G->findSectionByName(*sectName);
if (!JitSection)
return make_error<llvm::StringError>(
- "Could not find a section", llvm::inconvertibleErrorCode());
+ "Could not find the JitSection " + *sectName,
+ llvm::inconvertibleErrorCode());
auto bs = JitSection->blocks();
if (bs.empty())
return make_error<llvm::StringError>(
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s b/llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s
index ca9c926b32de..0eef11110264 100644
--- a/llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s
+++ b/llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s
@@ -46,6 +46,17 @@ named_data:
.long 42
.size named_data, 4
+# Test BSS / zero-fill section handling.
+# llvm-jitlink: *{4}bss_variable = 0
+
+ .type bss_variable, at object
+ .bss
+ .globl bss_variable
+ .p2align 2
+bss_variable:
+ .long 0
+ .size bss_variable, 4
+
.ident "clang version 10.0.0-4ubuntu1 "
.section ".note.GNU-stack","", at progbits
- .addrsig
\ No newline at end of file
+ .addrsig
More information about the llvm-commits
mailing list