summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2019-05-30 19:59:20 +0000
committerLang Hames <lhames@gmail.com>2019-05-30 19:59:20 +0000
commit0e124b37bd7fa42ab1087668b1fa7c35a9684deb (patch)
treedbe815eb28e0f51b3af0f3f1539a81e5f52457c7 /llvm/lib/ExecutionEngine
parent5f0f4e3ae03afa84034c01ddaac559e0b5cb6532 (diff)
downloadbcm5719-llvm-0e124b37bd7fa42ab1087668b1fa7c35a9684deb.tar.gz
bcm5719-llvm-0e124b37bd7fa42ab1087668b1fa7c35a9684deb.zip
[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. llvm-svn: 362139
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp11
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h2
2 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index f99868db443..b1d22b89af0 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -799,13 +799,12 @@ RuntimeDyldImpl::emitSection(const ObjectFile &Obj,
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.
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h
index 249f8dc0f29..28febbdb948 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h
@@ -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,
OpenPOWER on IntegriCloud