brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.2 KiB · 30b92f5 Raw
174 lines · plain
1// REQUIRES: arm2// RUN: rm -rf %t && split-file %s %t3 4// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi --arm-add-build-attributes %t/a.s -o %t/a.o5// RUN: ld.lld %t/a.o -T %t/exidx-non-zero-offset.t -o %t/non-zero6// RUN: llvm-readelf --program-headers --unwind --symbols -x .exceptions %t/non-zero | FileCheck %s7// RUN: ld.lld %t/a.o -T %t/exidx-zero-offset.t -o %t/zero8// RUN: llvm-readelf --program-headers --unwind --symbols -x .exceptions %t/zero | FileCheck %s9 10/// On platforms that load ELF files directly the ARM.exidx sections11/// are located with the PT_ARM_EXIDX program header. This requires12/// all .ARM.exidx input sections to be placed in a single13/// .ARM.exidx output section. Embedded systems that do not load14/// from an ELF file use the linker defined symbols __exidx_start and15/// __exidx_stop. There is no requirement to place the .ARM.exidx16/// input sections in their own output section. This test case checks17/// that a .ARM.exidx synthetic section that isn't at a zero offset18/// within the output section gets the correct offsets. We check19/// this by checking that equal amounts of alignment padding20/// inserted before and after the section start produce the same21/// results.22 23/// For the two linker scripts, one with the .ARM.exidx table24/// at a zero offset within its output section and one with a25/// non-zero offset, but both at the same file and address;26/// the PT_ARM_EXIDX, symbols and table contents should be the27/// same.28// CHECK:      EXIDX 0x010080 0x00000080 0x00000080 0x00028 0x00028 R   0x429 30/// unwind entries starting from the right address are identical.31/// llvm-readelf does not seem to be able to detect Thumb functionNames32/// whereas arm-none-eabi-readelf can. Used CHECK rather than CHECK-NEXT33/// to cope with possible improvements llvm-readelf.34// CHECK:        FunctionAddress: 0x035// CHECK-NEXT:   FunctionName: f136// CHECK-NEXT:   Model: Compact (Inline)37// CHECK-NEXT:   PersonalityIndex: 038// CHECK-NEXT:   Opcodes [39// CHECK-NEXT:     0x97      ; vsp = r740// CHECK-NEXT:     0x84 0x08 ; pop {r7, lr}41// CHECK-NEXT:   ]42// CHECK-NEXT: }43// CHECK-NEXT: Entry {44// CHECK-NEXT:   FunctionAddress: 0x845// CHECK-NEXT:   FunctionName: f246// CHECK-NEXT:   Model: CantUnwind47// CHECK-NEXT: }48// CHECK-NEXT: Entry {49// CHECK-NEXT:   FunctionAddress: 0xE50// CHECK:        ExceptionHandlingTable: .ARM.extab51// CHECK-NEXT:   TableEntryAddress: 0xA852// CHECK-NEXT:   Model: Generic53// CHECK-NEXT:   PersonalityRoutineAddress: 0x1254// CHECK-NEXT: }55// CHECK-NEXT: Entry {56// CHECK-NEXT:   FunctionAddress: 0x1057// CHECK:        Model: CantUnwind58// CHECK-NEXT: }59// CHECK-NEXT: Entry {60// CHECK-NEXT:   FunctionAddress: 0x1461// CHECK-NEXT:   FunctionName: __ARMv7ABSLongThunk_f362// CHECK-NEXT:   Model: CantUnwind63// CHECK-NEXT: }64 65// CHECK:      {{[0-9]+}}: 00000080 {{.*}} __exidx_start66// CHECK-NEXT: {{[0-9]+}}: 000000a8 {{.*}} __exidx_end67 68// CHECK:      0x00000080 80ffff7f 08849780 80ffff7f 0100000069// CHECK-NEXT: 0x00000090 7effff7f 14000000 78ffff7f 0100000070// CHECK-NEXT: 0x000000a0 74ffff7f 0100000071 72//--- exidx-non-zero-offset.t73SECTIONS {74  .text : { *(.text .text.*) }75  /* Addition of thunk in .text changes alignment padding */76  .exceptions : {77  /* Alignment padding within .exceptions */78  . = ALIGN(128);79  /* Embedded C libraries find exceptions via linker defined80     symbols */81  __exidx_start = .;82  *(.ARM.exidx) ;83  __exidx_end = .;84  }85  .ARM.extab : { *(.ARM.extab .ARM.extab.*) }86}87 88//--- exidx-zero-offset.t89SECTIONS {90  .text : { *(.text .text.*) }91  /* Addition of thunk in .text changes alignment padding */92  /* alignment padding before .exceptions starts */93  .exceptions : ALIGN(128) {94  /* Embedded C libraries find exceptions via linker defined95     symbols */96  __exidx_start = .;97  *(.ARM.exidx) ;98  __exidx_end = .;99  }100  .ARM.extab : { *(.ARM.extab .ARM.extab.*) }101}102 103//--- a.s104.syntax unified105 106/// Expect inline unwind instructions.107.section .text.01, "ax", %progbits108.arm109.balign 4110.global f1111.type f1, %function112f1:113.fnstart114/// provoke an interworking thunk.115b f3116bx lr117.save {r7, lr}118.setfp r7, sp, #0119.fnend120 121/// Expect no unwind information from assembler. The linker must122/// synthesise an EXIDX_CANTUNWIND entry to prevent an exception123/// thrown through f2 from matching against the unwind instructions124/// for f1.125.section .text.02, "ax", %progbits126.global f2127.type f2, %function128.balign 4129f2:130bx lr131 132/// Expect 1 EXIDX_CANTUNWIND entry that can be merged into the linker133/// generated EXIDX_CANTUNWIND as if the assembler had generated it.134.section .text.03, "ax",%progbits135.global f3136.type f3, %function137.thumb138.balign 2139f3:140.fnstart141bx lr142.cantunwind143.fnend144 145/// Expect a section with a reference to an .ARM.extab.146.section .text.04, "ax",%progbits147.global f4148.balign 2149.type f4, %function150f4:151.fnstart152bx lr153.personality __gxx_personality_v0154.handlerdata155.long 0156.fnend157 158 159/// Dummy implementation of personality routines to satisfy reference160/// from exception tables, linker will generate EXIDX_CANTUNWIND.161.section .text.__aeabi_unwind_cpp_pr0, "ax", %progbits162.global __aeabi_unwind_cpp_pr0163.type __aeabi_unwind_cpp_pr0, %function164.balign 2165__aeabi_unwind_cpp_pr0:166bx lr167 168.section .text.__gcc_personality_v0, "ax", %progbits169.global __gxx_personality_v0170.type __gcc_personality_v0, %function171.balign 2172__gxx_personality_v0:173bx lr174