[lld] [lld-macho][NFC] Refactor insertions into inputSections (PR #85692)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 11:07:40 PDT 2024


================
@@ -38,6 +38,43 @@ static_assert(sizeof(void *) != 8 ||
 
 std::vector<ConcatInputSection *> macho::inputSections;
 
+void lld::macho::addInputSection(InputSection *inputSection) {
+  // Used across function calls to impose section ordering
+  static uint64_t inputOrder = 0;
+
+  if (auto *isec = dyn_cast<ConcatInputSection>(inputSection)) {
+    if (isec->isCoalescedWeak())
+      return;
+    if (config->emitInitOffsets &&
+        sectionType(isec->getFlags()) == S_MOD_INIT_FUNC_POINTERS) {
+      in.initOffsets->addInput(isec);
+      return;
----------------
ellishg wrote:

These returns will skip the `assert()` below. Is that ok?

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


More information about the llvm-commits mailing list