[llvm] [llvm-objcopy] Always update indirectsymoff in MachO (PR #117726)

Richard Dzenis via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 26 08:05:15 PST 2024


================
@@ -361,11 +361,10 @@ Error MachOLayoutBuilder::layoutTail(uint64_t Offset) {
         return createStringError(llvm::errc::not_supported,
                                  "shared library is not yet supported");
 
-      if (!O.IndirectSymTable.Symbols.empty()) {
-        MLC.dysymtab_command_data.indirectsymoff = StartOfIndirectSymbols;
-        MLC.dysymtab_command_data.nindirectsyms =
-            O.IndirectSymTable.Symbols.size();
-      }
+      MLC.dysymtab_command_data.nindirectsyms =
+          O.IndirectSymTable.Symbols.size();
+      MLC.dysymtab_command_data.indirectsymoff =
+          O.IndirectSymTable.Symbols.empty() ? 0 : StartOfIndirectSymbols;
----------------
RIscRIpt wrote:

I thought to use `MLC.dysymtab_command_data.nindirectsyms` instead of `O.IndirectSymTable.Symbols.empty()` when I wrote the code initially.

I will change the ordering back.

https://github.com/llvm/llvm-project/pull/117726


More information about the llvm-commits mailing list