2 # RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t1.obj
3 # RUN: llvm-mc -triple=x86_64-windows-gnu %S/Inputs/comdat-jumptable2.s -filetype=obj -o %t2.obj
5 # RUN: llvm-objdump -s %t1.obj | FileCheck --check-prefix=OBJ1 %s
6 # RUN: llvm-objdump -s %t2.obj | FileCheck --check-prefix=OBJ2 %s
8 # RUN: lld-link -lldmingw -entry:main %t1.obj %t2.obj -out:%t.exe
9 # RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=EXE %s
11 # Test linking cases where comdat functions have an associated jump table
12 # in a non-comdat rdata (which GCC produces for functions with jump tables).
13 # In these cases, ld.bfd keeps all rdata sections, but the relocations that
14 # refer to discarded comdat sections just are emitted as they were originally.
16 # In real scenarios, the jump table .rdata section should be identical across
17 # all object files; here it is different to illustrate more clearly what
18 # the linker actually does.
20 # OBJ1: Contents of section .rdata:
21 # OBJ1: 0000 aaaaaaaa 14000000 1e000000 28000000
24 # OBJ2: Contents of section .rdata:
25 # OBJ2: 0000 cccccccc 14000000 1e000000 28000000
28 # EXE: Contents of section .rdata:
29 # EXE: 140002000 aaaaaaaa 0c100000 12100000 18100000
30 # EXE: 140002010 bbbbbbbb cccccccc 14000000 1e000000
31 # EXE: 140002020 28000000 dddddddd
34 .section .text@comdatfunc, "x"
38 leaq
.Ljumptable(%rip), %rax
39 movslq
(%rax
, %rcx
, 4), %rcx
46 .long .Ltail1-.Ljumptable
47 .long .Ltail2-.Ljumptable
48 .long .Ltail3-.Ljumptable
51 .section .text@comdatfunc, "x"
52 # If assembled with binutils, the following line can be kept in: