[PATCH] D88867: Fix JITLink for ELF X86 so that it accepts a .bss section by adding a call to createZeroFillBlock
Lang Hames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 21:36:12 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01baeda7ca66: [JITLink][ELF] Handle BSS sections, improve some error messages. (authored by lhames).
Changed prior to commit:
https://reviews.llvm.org/D88867?vs=296356&id=296359#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88867/new/
https://reviews.llvm.org/D88867
Files:
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s
Index: llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s
===================================================================
--- llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s
+++ llvm/test/ExecutionEngine/JITLink/X86/ELF_x86-64_relocations.s
@@ -46,6 +46,17 @@
.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
Index: llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
===================================================================
--- llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -357,6 +357,9 @@
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 @@
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 @@
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>(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88867.296359.patch
Type: text/x-patch
Size: 2187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201006/104c7c71/attachment.bin>
More information about the llvm-commits
mailing list