summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJez Ng <jezng@fb.com>2023-01-11 02:23:15 -0500
committerJez Ng <jezng@fb.com>2023-01-24 20:11:04 -0500
commit4f2a4617936fd73a5fe18f8e12a02b0975ce7643 (patch)
tree4ac690bc74deaa3073f8a31dc977e31727bde13d
parent388b8c16c5610a54c639bb74e3c8de161e8ca1c6 (diff)
downloadllvm-4f2a4617936fd73a5fe18f8e12a02b0975ce7643.tar.gz
[lld-macho] Have all load commands aligned to the word size
This is what ld64 does, and also what we already do for most of the other load commands. I'm not aware of a good way to test this, but I don't think it really matters. Differential Revision: https://reviews.llvm.org/D141462
-rw-r--r--lld/MachO/Writer.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp
index b88f99c920f6..a09920687c55 100644
--- a/lld/MachO/Writer.cpp
+++ b/lld/MachO/Writer.cpp
@@ -328,7 +328,8 @@ public:
}
uint32_t getSize() const override {
- return alignTo(sizeof(dylib_command) + path.size() + 1, 8);
+ return alignToPowerOf2(sizeof(dylib_command) + path.size() + 1,
+ target->wordSize);
}
void writeTo(uint8_t *buf) const override {
@@ -362,7 +363,8 @@ uint32_t LCDylib::instanceCount = 0;
class LCLoadDylinker final : public LoadCommand {
public:
uint32_t getSize() const override {
- return alignTo(sizeof(dylinker_command) + path.size() + 1, 8);
+ return alignToPowerOf2(sizeof(dylinker_command) + path.size() + 1,
+ target->wordSize);
}
void writeTo(uint8_t *buf) const override {