brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 31a7c5f Raw
71 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t1.obj3# RUN: llvm-mc -triple=x86_64-windows-gnu %S/Inputs/comdat-jumptable2.s -filetype=obj -o %t2.obj4 5# RUN: llvm-objdump -s %t1.obj | FileCheck --check-prefix=OBJ1 %s6# RUN: llvm-objdump -s %t2.obj | FileCheck --check-prefix=OBJ2 %s7 8# RUN: lld-link -lldmingw -entry:main %t1.obj %t2.obj -out:%t.exe9# RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=EXE %s10 11# Test linking cases where comdat functions have an associated jump table12# 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 that14# refer to discarded comdat sections just are emitted as they were originally.15 16# In real scenarios, the jump table .rdata section should be identical across17# all object files; here it is different to illustrate more clearly what18# the linker actually does.19 20# OBJ1: Contents of section .rdata:21# OBJ1:  0000 aaaaaaaa 14000000 1e000000 2800000022# OBJ1:  0010 bbbbbbbb23 24# OBJ2: Contents of section .rdata:25# OBJ2:  0000 cccccccc 14000000 1e000000 2800000026# OBJ2:  0010 dddddddd27 28# EXE: Contents of section .rdata:29# EXE:  140002000 aaaaaaaa 0c100000 12100000 1810000030# EXE:  140002010 bbbbbbbb cccccccc 14000000 1e00000031# EXE:  140002020 28000000 dddddddd32 33 34        .section .text@comdatfunc, "x"35        .linkonce discard36        .globl comdatfunc37comdatfunc:38        leaq .Ljumptable(%rip), %rax39        movslq (%rax, %rcx, 4), %rcx40        addq %rcx, %rax41        jmp *%rax42 43        .section .rdata, "dr"44        .long 0xaaaaaaaa45.Ljumptable:46        .long .Ltail1-.Ljumptable47        .long .Ltail2-.Ljumptable48        .long .Ltail3-.Ljumptable49        .long 0xbbbbbbbb50 51        .section .text@comdatfunc, "x"52# If assembled with binutils, the following line can be kept in:53#       .linkonce discard54.Ltail1:55        movl $1, %eax56        ret57.Ltail2:58        movl $2, %eax59        ret60.Ltail3:61        movl $3, %eax62        ret63 64 65        .text66        .globl main67main:68        call comdatfunc69        call otherfunc70        ret71