[PATCH] D85501: [lld-macho] Handle command-line option -sectcreate SEG SECT FILE

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 09:54:01 PDT 2020


int3 added inline comments.


================
Comment at: lld/MachO/InputFiles.cpp:313
+  isec->data = {buf, mb.getBufferSize()};
+  inputSections.push_back(isec);
+}
----------------
none of the other InputFile constructors modify `inputSections` directly; I think it would better fit the pattern if `OpaqueFile` instead inserted the `isec` in its `subsections` map (at an offset of zero)


================
Comment at: lld/test/MachO/sectcreate.s:4
+# RUN: echo "Contents of -sectcreate option" >%t2
+# RUN: lld -flavor darwinnew -Z -o %t %t.o -sectcreate FOO BARF %t2
+# RUN: llvm-objdump -s %t | FileCheck %s
----------------
would be interesting to test multiple `-sectcreate` flags in sequence, e.g. checking that we lay out their sections in sequence as well. Also, does ld64 interleave them amongst the other object files on the command line, or do the created sections all appear at the end? Would be good to match that behavior


================
Comment at: lld/test/MachO/sectcreate.s:8-9
+# CHECK: Contents of section BARF:
+# CHECK: 100001000 436f6e74 656e7473 206f6620 2d736563  Contents of -sec
+# CHECK: 100001010 74637265 61746520 6f707469 6f6e0a    tcreate option.
+
----------------
FileCheck does a substring match, so you could drop the hex bytes and just match against the ASCII


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85501/new/

https://reviews.llvm.org/D85501



More information about the llvm-commits mailing list