[lld-macho] Put DATA_IN_CODE immediately after FUNCTION_STARTS
authorJez Ng <jezng@fb.com>
Wed, 16 Jun 2021 19:23:07 +0000 (15:23 -0400)
committerJez Ng <jezng@fb.com>
Wed, 16 Jun 2021 19:23:07 +0000 (15:23 -0400)
codesign checks for this.

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D104354

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

index fda47ed..1be19e2 100644 (file)
@@ -115,12 +115,13 @@ static int sectionOrder(OutputSection *osec) {
     }
   } 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)
index 63a11db..a67e86d 100644 (file)
@@ -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
 
 # 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 @@ _main:
   callq _foo
   callq _weak_foo
   ret
+
+.p2align 2, 0x90
+.data_region jt32
+.long 0
+.end_data_region