[PATCH] D104354: [lld-macho] Put DATA_IN_CODE immediately after FUNCTION_STARTS

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 15 22:11:20 PDT 2021


int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

codesign checks for this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104354

Files:
  lld/MachO/OutputSegment.cpp
  lld/test/MachO/linkedit-contiguity.s


Index: lld/test/MachO/linkedit-contiguity.s
===================================================================
--- lld/test/MachO/linkedit-contiguity.s
+++ lld/test/MachO/linkedit-contiguity.s
@@ -6,8 +6,6 @@
 ## It also checks that the last section in __LINKEDIT covers the last byte of
 ## the segment.
 
-## FIXME: Include LC_DATA_IN_CODE in this test when we add support for it.
-
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
 # RUN: %lld %t/foo.o -dylib -o %t/libfoo.dylib
 
@@ -38,6 +36,11 @@
 # CHECK:      cmd LC_FUNCTION_STARTS
 # CHECK-NEXT: cmdsize
 # CHECK-NEXT: dataoff [[#FUNCSTARTS_OFF: EXPORT_OFF + EXPORT_SIZE]]
+# CHECK-NEXT: datasize [[#FUNCSTARTS_SIZE:]]
+
+# CHECK:      cmd LC_DATA_IN_CODE
+# CHECK-NEXT: cmdsize
+# CHECK-NEXT: dataoff [[#DIC_OFF: FUNCSTARTS_OFF + FUNCSTARTS_SIZE]]
 
 # CHECK:      cmd LC_CODE_SIGNATURE
 # CHECK-NEXT: cmdsize 16
@@ -56,3 +59,8 @@
   callq _foo
   callq _weak_foo
   ret
+
+.p2align 2, 0x90
+.data_region jt32
+.long 0
+.end_data_region
Index: lld/MachO/OutputSegment.cpp
===================================================================
--- lld/MachO/OutputSegment.cpp
+++ lld/MachO/OutputSegment.cpp
@@ -115,12 +115,13 @@
     }
   } else if (segname == segment_names::linkEdit) {
     return StringSwitch<int>(osec->name)
-        .Case(section_names::rebase, -9)
-        .Case(section_names::binding, -8)
-        .Case(section_names::weakBinding, -7)
-        .Case(section_names::lazyBinding, -6)
-        .Case(section_names::export_, -5)
-        .Case(section_names::functionStarts, -4)
+        .Case(section_names::rebase, -10)
+        .Case(section_names::binding, -9)
+        .Case(section_names::weakBinding, -8)
+        .Case(section_names::lazyBinding, -7)
+        .Case(section_names::export_, -6)
+        .Case(section_names::functionStarts, -5)
+        .Case(section_names::dataInCode, -4)
         .Case(section_names::symbolTable, -3)
         .Case(section_names::indirectSymbolTable, -2)
         .Case(section_names::stringTable, -1)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104354.352338.patch
Type: text/x-patch
Size: 2059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210616/e9938159/attachment.bin>


More information about the llvm-commits mailing list