From 4f2a4617936fd73a5fe18f8e12a02b0975ce7643 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Wed, 11 Jan 2023 02:23:15 -0500 Subject: [PATCH] [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 --- lld/MachO/Writer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp index b88f99c9..a099206 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 { -- 2.7.4