[llvm] r362139 - [RuntimeDyld] Apply padding and alignment bumps to all sections with stubs, and
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu May 30 12:59:20 PDT 2019
Author: lhames
Date: Thu May 30 12:59:20 2019
New Revision: 362139
URL: http://llvm.org/viewvc/llvm-project?rev=362139&view=rev
Log:
[RuntimeDyld] Apply padding and alignment bumps to all sections with stubs, and
increase the MachO/x86-64 stub alignment to 8.
Stub alignment should be guaranteed for any section containing RuntimeDyld
stubs/GOT-entries. To do this we should pad and align all sections containing
stubs, not just code sections.
This commit also bumps the MachO/x86-64 stub alignment to 8, so that GOT entries
will be aligned.
Modified:
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h
llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=362139&r1=362138&r2=362139&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Thu May 30 12:59:20 2019
@@ -799,13 +799,12 @@ RuntimeDyldImpl::emitSection(const Objec
pData = data.data();
}
- // Code section alignment needs to be at least as high as stub alignment or
- // padding calculations may by incorrect when the section is remapped to a
- // higher alignment.
- if (IsCode) {
+ // If there are any stubs then the section alignment needs to be at least as
+ // high as stub alignment or padding calculations may by incorrect when the
+ // section is remapped.
+ if (StubBufSize != 0) {
Alignment = std::max(Alignment, getStubAlignment());
- if (StubBufSize > 0)
- PaddingSize += getStubAlignment() - 1;
+ PaddingSize += getStubAlignment() - 1;
}
// Some sections, such as debug info, don't need to be loaded for execution.
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h?rev=362139&r1=362138&r2=362139&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h Thu May 30 12:59:20 2019
@@ -28,7 +28,7 @@ public:
unsigned getMaxStubSize() const override { return 8; }
- unsigned getStubAlignment() override { return 1; }
+ unsigned getStubAlignment() override { return 8; }
Expected<relocation_iterator>
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
Modified: llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s?rev=362139&r1=362138&r2=362139&view=diff
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s (original)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s Thu May 30 12:59:20 2019
@@ -22,8 +22,9 @@ insn2:
movl x(%rip), %eax
# Test PC-rel GOT relocation.
-# Verify both the contents of the GOT entry for y, and that the movq instruction
-# references the correct GOT entry address:
+# Verify the alignment of the GOT entry, the contents of the GOT entry for y,
+# and that the movq instruction references the correct GOT entry address:
+# rtdyld-check: stub_addr(test_x86-64.o/__text, y)[2:0] = 0
# rtdyld-check: *{8}(stub_addr(test_x86-64.o/__text, y)) = y
# rtdyld-check: decode_operand(insn3, 4) = stub_addr(test_x86-64.o/__text, y) - next_pc(insn3)
insn3:
More information about the llvm-commits
mailing list