xref: /aosp_15_r20/external/llvm/test/MC/ARM/eh-directive-text-section.s (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \
2*9880d681SAndroid Build Coastguard Worker@ RUN:   | llvm-readobj -s -sd -sr | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker@ Check the .fnstart directive and the .fnend directive.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker@ The .fnstart directive and .fnend directive should create an entry in
7*9880d681SAndroid Build Coastguard Worker@ exception handling table.  For example, if the function is defined in .text
8*9880d681SAndroid Build Coastguard Worker@ section, then there should be an entry in .ARM.exidx section.
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Worker	.syntax	unified
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker	.text
13*9880d681SAndroid Build Coastguard Worker	.globl	func1
14*9880d681SAndroid Build Coastguard Worker	.align	2
15*9880d681SAndroid Build Coastguard Worker	.type	func1,%function
16*9880d681SAndroid Build Coastguard Worker	.fnstart
17*9880d681SAndroid Build Coastguard Workerfunc1:
18*9880d681SAndroid Build Coastguard Worker	bx	lr
19*9880d681SAndroid Build Coastguard Worker	.fnend
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
24*9880d681SAndroid Build Coastguard Worker@ Check the .text section.
25*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
26*9880d681SAndroid Build Coastguard Worker@ CHECK: Sections [
27*9880d681SAndroid Build Coastguard Worker@ CHECK:   Section {
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
30*9880d681SAndroid Build Coastguard Worker@ Check the index of .text section.  This will be used in .ARM.exidx.
31*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
32*9880d681SAndroid Build Coastguard Worker@ CHECK:     Index: 2
33*9880d681SAndroid Build Coastguard Worker@ CHECK-NEXT:     Name: .text
34*9880d681SAndroid Build Coastguard Worker@ CHECK:     Type: SHT_PROGBITS (0x1)
35*9880d681SAndroid Build Coastguard Worker@ CHECK:     Flags [ (0x6)
36*9880d681SAndroid Build Coastguard Worker@ CHECK:       SHF_ALLOC (0x2)
37*9880d681SAndroid Build Coastguard Worker@ CHECK:       SHF_EXECINSTR (0x4)
38*9880d681SAndroid Build Coastguard Worker@ CHECK:     ]
39*9880d681SAndroid Build Coastguard Worker@ CHECK:     SectionData (
40*9880d681SAndroid Build Coastguard Worker@ CHECK:       0000: 1EFF2FE1                             |../.|
41*9880d681SAndroid Build Coastguard Worker@ CHECK:     )
42*9880d681SAndroid Build Coastguard Worker@ CHECK:   }
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
46*9880d681SAndroid Build Coastguard Worker@ Check the name of the EXIDX section.  For the function in the .text section,
47*9880d681SAndroid Build Coastguard Worker@ this should be .ARM.exidx.  It is incorrect to see .ARM.exidx.text here.
48*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
49*9880d681SAndroid Build Coastguard Worker@ CHECK:   Section {
50*9880d681SAndroid Build Coastguard Worker@ CHECK:     Name: .ARM.exidx
51*9880d681SAndroid Build Coastguard Worker@ CHECK:     Type: SHT_ARM_EXIDX (0x70000001)
52*9880d681SAndroid Build Coastguard Worker@ CHECK:     Flags [ (0x82)
53*9880d681SAndroid Build Coastguard Worker@ CHECK:       SHF_ALLOC (0x2)
54*9880d681SAndroid Build Coastguard Worker@ CHECK:       SHF_LINK_ORDER (0x80)
55*9880d681SAndroid Build Coastguard Worker@ CHECK:     ]
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
58*9880d681SAndroid Build Coastguard Worker@ Check the linked section of the EXIDX section.  This should be the index
59*9880d681SAndroid Build Coastguard Worker@ of the .text section.
60*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
61*9880d681SAndroid Build Coastguard Worker@ CHECK:     Link: 2
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
64*9880d681SAndroid Build Coastguard Worker@ The first word should be the offset to .text.  The second word should be
65*9880d681SAndroid Build Coastguard Worker@ 0xB0B0B080, which means compact model 0 is used (0x80) and the rest of the
66*9880d681SAndroid Build Coastguard Worker@ word is filled with FINISH opcode (0xB0).
67*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
68*9880d681SAndroid Build Coastguard Worker@ CHECK:     SectionData (
69*9880d681SAndroid Build Coastguard Worker@ CHECK:       0000: 00000000 B0B0B080                    |........|
70*9880d681SAndroid Build Coastguard Worker@ CHECK:     )
71*9880d681SAndroid Build Coastguard Worker@ CHECK:   }
72*9880d681SAndroid Build Coastguard Worker@ CHECK: ]
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
75*9880d681SAndroid Build Coastguard Worker@ The first word should be relocated to the code address in .text section.
76*9880d681SAndroid Build Coastguard Worker@ Besides, since this function is using compact model 0, thus we have to
77*9880d681SAndroid Build Coastguard Worker@ add an relocation to __aeabi_unwind_cpp_pr0.
78*9880d681SAndroid Build Coastguard Worker@-------------------------------------------------------------------------------
79*9880d681SAndroid Build Coastguard Worker@ CHECK:     Relocations [
80*9880d681SAndroid Build Coastguard Worker@ CHECK:       0x0 R_ARM_NONE __aeabi_unwind_cpp_pr0 0x0
81*9880d681SAndroid Build Coastguard Worker@ CHECK:       0x0 R_ARM_PREL31 .text 0x0
82*9880d681SAndroid Build Coastguard Worker@ CHECK:     ]
83