xref: /llvm-project/lld/test/MachO/data-in-code-section-ordering.s (revision 025a5b22c848364be0009a630e7fb53f40515e68)
1*025a5b22SDaniel Bertalan# REQUIRES: x86
2*025a5b22SDaniel Bertalan# RUN: rm -rf %t; split-file %s %t
3*025a5b22SDaniel Bertalan
4*025a5b22SDaniel Bertalan## Check that data-in-code information is sorted even if
5*025a5b22SDaniel Bertalan## sections are reordered compared to the input order.
6*025a5b22SDaniel Bertalan
7*025a5b22SDaniel Bertalan# RUN: sed -e s/SYM/_first/ %t/input.s | \
8*025a5b22SDaniel Bertalan# RUN:   llvm-mc -filetype=obj --triple=x86_64-apple-darwin -o %t/first.o
9*025a5b22SDaniel Bertalan# RUN: sed -e s/SYM/_second/ %t/input.s | \
10*025a5b22SDaniel Bertalan# RUN:   llvm-mc -filetype=obj --triple=x86_64-apple-darwin -o %t/second.o
11*025a5b22SDaniel Bertalan# RUN: sed -e s/SYM/_third/ %t/input.s | \
12*025a5b22SDaniel Bertalan# RUN:   llvm-mc -filetype=obj --triple=x86_64-apple-darwin -o %t/third.o
13*025a5b22SDaniel Bertalan# RUN: %lld -dylib -lSystem -order_file %t/order.txt %t/first.o %t/second.o %t/third.o -o %t/out
14*025a5b22SDaniel Bertalan# RUN: llvm-objdump --macho --syms %t/out > %t/dump.txt
15*025a5b22SDaniel Bertalan# RUN: llvm-objdump --macho --data-in-code %t/out >> %t/dump.txt
16*025a5b22SDaniel Bertalan# RUN: FileCheck %s < %t/dump.txt
17*025a5b22SDaniel Bertalan
18*025a5b22SDaniel Bertalan# CHECK-LABEL: SYMBOL TABLE:
19*025a5b22SDaniel Bertalan# CHECK-DAG:   [[#%x, SECOND:]] g     F __TEXT,__text _second
20*025a5b22SDaniel Bertalan# CHECK-DAG:   [[#%x, FIRST:]]  g     F __TEXT,__text _first
21*025a5b22SDaniel Bertalan# CHECK-DAG:   [[#%x, THIRD:]]  g     F __TEXT,__text _third
22*025a5b22SDaniel Bertalan
23*025a5b22SDaniel Bertalan# CHECK-LABEL: Data in code table (3 entries)
24*025a5b22SDaniel Bertalan# CHECK-NEXT:  offset              length kind
25*025a5b22SDaniel Bertalan# CHECK-NEXT:  0x[[#%.8x, SECOND]] 4      JUMP_TABLE32
26*025a5b22SDaniel Bertalan# CHECK-NEXT:  0x[[#%.8x, FIRST]]  4      JUMP_TABLE32
27*025a5b22SDaniel Bertalan# CHECK-NEXT:  0x[[#%.8x, THIRD]]  4      JUMP_TABLE32
28*025a5b22SDaniel Bertalan
29*025a5b22SDaniel Bertalan#--- order.txt
30*025a5b22SDaniel Bertalan_second
31*025a5b22SDaniel Bertalan_first
32*025a5b22SDaniel Bertalan_third
33*025a5b22SDaniel Bertalan
34*025a5b22SDaniel Bertalan#--- input.s
35*025a5b22SDaniel Bertalan.globl SYM
36*025a5b22SDaniel BertalanSYM:
37*025a5b22SDaniel Bertalan.data_region jt32
38*025a5b22SDaniel Bertalan.long 0
39*025a5b22SDaniel Bertalan.end_data_region
40