diff options
author | Zachary Turner <zturner@google.com> | 2019-01-30 23:52:32 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2019-01-30 23:52:32 +0000 |
commit | 3c35f774deb8b7f4d6915c3fe3f53114ff3a07ba (patch) | |
tree | 6b295f2097a79b06e0c0a110c97330004c1c9037 /llvm/lib/ExecutionEngine | |
parent | 01c4939658f7776a924b150aeb65dbd72567831e (diff) | |
download | bcm5719-llvm-3c35f774deb8b7f4d6915c3fe3f53114ff3a07ba.tar.gz bcm5719-llvm-3c35f774deb8b7f4d6915c3fe3f53114ff3a07ba.zip |
[RuntimeDyld] Don't try to allocate sections with align 0.
ELF sections allow 0 for the alignment, which is specified to
be the same as 1. However many clients do not expect this and
will behave poorly in the presence of a 0-aligned section (for
example by trying to modulo something by the section alignment).
We can be more polite by making sure that we always pass a
non-zero value to clients.
Differential Revision: https://reviews.llvm.org/D57482
llvm-svn: 352694
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index 473a8120b42..589cdcbcb0d 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -743,6 +743,11 @@ RuntimeDyldImpl::emitSection(const ObjectFile &Obj, bool IsReadOnly = isReadOnlyData(Section); uint64_t DataSize = Section.getSize(); + // An alignment of 0 (at least with ELF) is identical to an alignment of 1, + // while being more "polite". Other formats do not support 0-aligned sections + // anyway, so we should guarantee that the alignment is always at least 1. + Alignment = std::max(1u, Alignment); + StringRef Name; if (auto EC = Section.getName(Name)) return errorCodeToError(EC); |