1# REQUIRES: x86 2 3## Testcase checks that we correctly deduplicate FDEs when ICF 4## merges two sections. 5 6# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t 7# RUN: ld.lld %t -o %t2 --icf=all --eh-frame-hdr 8# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=OBJ 9# RUN: llvm-readobj -S --section-data %t2 | FileCheck %s 10 11# OBJ: Relocations [ 12# OBJ-NEXT: Section {{.*}} .rela.eh_frame { 13# OBJ-NEXT: 0x20 R_X86_64_PC32 .text.f1 0x0 14# OBJ-NEXT: 0x34 R_X86_64_PC32 .text.f1 0x2 15# OBJ-NEXT: 0x48 R_X86_64_PC32 .text.f2 0x0 16# OBJ-NEXT: 0x5C R_X86_64_PC32 .text.f2 0x2 17# OBJ-NEXT: } 18# OBJ-NEXT: ] 19 20# CHECK: Section { 21# CHECK: Index: 1 22# CHECK: Name: .eh_frame_hdr 23# CHECK-NEXT: Type: SHT_PROGBITS 24# CHECK-NEXT: Flags [ 25# CHECK-NEXT: SHF_ALLOC 26# CHECK-NEXT: ] 27# CHECK-NEXT: Address: 0x200158 28# CHECK-NEXT: Offset: 0x158 29# CHECK-NEXT: Size: 28 30# CHECK-NEXT: Link: 0 31# CHECK-NEXT: Info: 0 32# CHECK-NEXT: AddressAlignment: 33# CHECK-NEXT: EntrySize: 0 34# CHECK-NEXT: SectionData ( 35# CHECK-NEXT: 0000: 011B033B 1C000000 02000000 6C100000 36## ^ ^-- FDE(1) PC 37## ^-- Number of FDEs 38# CHECK-NEXT: 0010: 38000000 6E100000 50000000 39## ^-- FDE(2) PC 40# CHECK-NEXT: ) 41# CHECK-NEXT: } 42## FDE(1) == 0x201000 - .eh_frame_hdr(0x200158) = 0xEA8 43## FDE(2) == 0x201000 - .eh_frame_hdr(0x200158) + 2(relocation addend) = 0xEAA 44 45## Check .eh_frame contains CIE and two FDEs remaining after ICF. 46# CHECK-NEXT: Section { 47# CHECK-NEXT: Index: 2 48# CHECK-NEXT: Name: .eh_frame 49# CHECK-NEXT: Type: SHT_PROGBITS 50# CHECK-NEXT: Flags [ 51# CHECK-NEXT: SHF_ALLOC 52# CHECK-NEXT: ] 53# CHECK-NEXT: Address: 0x200178 54# CHECK-NEXT: Offset: 0x178 55# CHECK-NEXT: Size: 76 56# CHECK-NEXT: Link: 0 57# CHECK-NEXT: Info: 0 58# CHECK-NEXT: AddressAlignment: 8 59# CHECK-NEXT: EntrySize: 0 60# CHECK-NEXT: SectionData ( 61# CHECK-NEXT: 0000: 14000000 00000000 017A5200 01781001 62# CHECK-NEXT: 0010: 1B0C0708 90010000 14000000 1C000000 63# CHECK-NEXT: 0020: 2C100000 01000000 00000000 00000000 64# CHECK-NEXT: 0030: 14000000 34000000 16100000 01000000 65# CHECK-NEXT: 0040: 00000000 00000000 00000000 66# CHECK-NEXT: ) 67# CHECK-NEXT: } 68 69# CHECK: Section { 70# CHECK: Index: 71# CHECK: Name: .text 72# CHECK-NEXT: Type: SHT_PROGBITS 73# CHECK-NEXT: Flags [ 74# CHECK-NEXT: SHF_ALLOC 75# CHECK-NEXT: SHF_EXECINSTR 76# CHECK-NEXT: ] 77# CHECK-NEXT: Address: 0x2011C4 78 79.section .text.f1, "ax" 80.cfi_startproc 81nop 82.cfi_endproc 83nop 84.cfi_startproc 85ret 86.cfi_endproc 87 88.section .text.f2, "ax" 89.cfi_startproc 90nop 91.cfi_endproc 92nop 93.cfi_startproc 94ret 95.cfi_endproc 96