Skip to content

Commit 79475f0

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:f89b7a9ee205 into amd-gfx:2dc51f904f3f
Local branch amd-gfx 2dc51f9 Merged main:853e126ce32a into amd-gfx:ec075f374ad2 Remote branch main f89b7a9 [mlir] reword error message on unloaded dialect (llvm#67980)
2 parents 2dc51f9 + f89b7a9 commit 79475f0

File tree

15 files changed

+499
-163
lines changed

15 files changed

+499
-163
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes HOST
2+
3+
4+
!HOST-LABEL: func.func @_QPread_write_section() {
5+
!HOST: %0 = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFread_write_sectionEi"}
6+
!HOST: %[[READ:.*]] = fir.address_of(@_QFread_write_sectionEsp_read) : !fir.ref<!fir.array<10xi32>>
7+
!HOST: %[[C10:.*]] = arith.constant 10 : index
8+
!HOST: %[[READ_SHAPE:.*]] = fir.shape %[[C10]] : (index) -> !fir.shape<1>
9+
!HOST: %[[READ_DECL:.*]]:2 = hlfir.declare %[[READ]](%[[READ_SHAPE]]) {uniq_name = "_QFread_write_sectionEsp_read"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
10+
!HOST: %[[WRITE:.*]] = fir.address_of(@_QFread_write_sectionEsp_write) : !fir.ref<!fir.array<10xi32>>
11+
!HOST: %[[C10:.*]] = arith.constant 10 : index
12+
!HOST: %[[WRITE_SHAPE:.*]] = fir.shape %[[C10]] : (index) -> !fir.shape<1>
13+
!HOST: %[[WRITE_DECL:.*]]:2 = hlfir.declare %[[WRITE]](%[[WRITE_SHAPE]]) {uniq_name = "_QFread_write_sectionEsp_write"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
14+
15+
!HOST: %[[C1:.*]] = arith.constant 1 : index
16+
!HOST: %[[C2:.*]] = arith.constant 1 : index
17+
!HOST: %[[C3:.*]] = arith.constant 4 : index
18+
!HOST: %[[BOUNDS0:.*]] = omp.bounds lower_bound(%[[C2]] : index) upper_bound(%[[C3]] : index) stride(%[[C1]] : index) start_idx(%[[C1]] : index)
19+
!HOST: %[[MAP0:.*]] = omp.map_info var_ptr(%[[READ_DECL]]#1 : !fir.ref<!fir.array<10xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS0]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_read(2:5)"}
20+
!HOST: %[[C4:.*]] = arith.constant 1 : index
21+
!HOST: %[[C5:.*]] = arith.constant 1 : index
22+
!HOST: %[[C6:.*]] = arith.constant 4 : index
23+
!HOST: %[[BOUNDS1:.*]] = omp.bounds lower_bound(%[[C5]] : index) upper_bound(%[[C6]] : index) stride(%[[C4]] : index) start_idx(%[[C4]] : index)
24+
!HOST: %[[MAP1:.*]] = omp.map_info var_ptr(%[[WRITE_DECL]]#1 : !fir.ref<!fir.array<10xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS1]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_write(2:5)"}
25+
!HOST: omp.target map_entries(%[[MAP0]], %[[MAP1]] : !fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>) {
26+
27+
subroutine read_write_section()
28+
integer :: sp_read(10) = (/1,2,3,4,5,6,7,8,9,10/)
29+
integer :: sp_write(10) = (/0,0,0,0,0,0,0,0,0,0/)
30+
31+
!$omp target map(tofrom:sp_read(2:5)) map(tofrom:sp_write(2:5))
32+
do i = 2, 5
33+
sp_write(i) = sp_read(i)
34+
end do
35+
!$omp end target
36+
end subroutine read_write_section
37+
38+
39+
module assumed_array_routines
40+
contains
41+
42+
!HOST-LABEL: func.func @_QMassumed_array_routinesPassumed_shape_array(
43+
!HOST-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) {
44+
!HOST: %[[ARG0_DECL:.*]]:2 = hlfir.declare %[[ARG0]] {fortran_attrs = #fir.var_attrs<intent_inout>, uniq_name = "_QMassumed_array_routinesFassumed_shape_arrayEarr_read_write"} : (!fir.box<!fir.array<?xi32>>) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
45+
!HOST: %[[C0:.*]] = arith.constant 1 : index
46+
!HOST: %[[C1:.*]] = arith.constant 0 : index
47+
!HOST: %[[C2:.*]]:3 = fir.box_dims %[[ARG0_DECL]]#1, %[[C1]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
48+
!HOST: %[[C3:.*]] = arith.constant 1 : index
49+
!HOST: %[[C4:.*]] = arith.constant 4 : index
50+
!HOST: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C3]] : index) upper_bound(%[[C4]] : index) stride(%[[C2]]#2 : index) start_idx(%[[C0]] : index) {stride_in_bytes = true}
51+
!HOST: %[[ADDROF:.*]] = fir.box_addr %[[ARG0_DECL]]#1 : (!fir.box<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
52+
!HOST: %[[MAP:.*]] = omp.map_info var_ptr(%[[ADDROF]] : !fir.ref<!fir.array<?xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
53+
!HOST: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) {
54+
subroutine assumed_shape_array(arr_read_write)
55+
integer, intent(inout) :: arr_read_write(:)
56+
57+
!$omp target map(tofrom:arr_read_write(2:5))
58+
do i = 2, 5
59+
arr_read_write(i) = i
60+
end do
61+
!$omp end target
62+
end subroutine assumed_shape_array
63+
64+
65+
!HOST-LABEL: func.func @_QMassumed_array_routinesPassumed_size_array(
66+
!HOST-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) {
67+
!HOST: %[[UNDEF:.*]] = fir.undefined index
68+
!HOST: %[[ARG0_SHAPE:.*]] = fir.shape %[[UNDEF]] : (index) -> !fir.shape<1>
69+
!HOST: %[[ARG0_DECL:.*]]:2 = hlfir.declare %[[ARG0]](%[[ARG0_SHAPE]]) {fortran_attrs = #fir.var_attrs<intent_inout>, uniq_name = "_QMassumed_array_routinesFassumed_size_arrayEarr_read_write"} : (!fir.ref<!fir.array<?xi32>>, !fir.shape<1>) -> (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?xi32>>)
70+
!HOST: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QMassumed_array_routinesFassumed_size_arrayEi"}
71+
!HOST: %[[C0:.*]] = arith.constant 1 : index
72+
!HOST: %[[C1:.*]] = arith.constant 1 : index
73+
!HOST: %[[C2:.*]] = arith.constant 4 : index
74+
!HOST: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C1]] : index) upper_bound(%[[C2]] : index) stride(%[[C0]] : index) start_idx(%[[C0]] : index)
75+
!HOST: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARG0_DECL]]#1 : !fir.ref<!fir.array<?xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
76+
!HOST: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) {
77+
subroutine assumed_size_array(arr_read_write)
78+
integer, intent(inout) :: arr_read_write(*)
79+
80+
!$omp target map(tofrom:arr_read_write(2:5))
81+
do i = 2, 5
82+
arr_read_write(i) = i
83+
end do
84+
!$omp end target
85+
end subroutine assumed_size_array
86+
end module assumed_array_routines
87+
88+
89+
!HOST-LABEL:func.func @_QPcall_assumed_shape_and_size_array() {
90+
!HOST: %[[C20:.*]] = arith.constant 20 : index
91+
!HOST: %[[READ_WRITE:.*]] = fir.alloca !fir.array<20xi32> {bindc_name = "arr_read_write", uniq_name = "_QFcall_assumed_shape_and_size_arrayEarr_read_write"}
92+
!HOST: %[[SHAPE_READ_WRITE:.*]] = fir.shape %[[C20]] : (index) -> !fir.shape<1>
93+
!HOST: %[[READ_WRITE_DECL:.*]]:2 = hlfir.declare %[[READ_WRITE]](%[[SHAPE_READ_WRITE]]) {uniq_name = "_QFcall_assumed_shape_and_size_arrayEarr_read_write"} : (!fir.ref<!fir.array<20xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<20xi32>>, !fir.ref<!fir.array<20xi32>>)
94+
!HOST: %[[LB:.*]] = arith.constant 1 : index
95+
!HOST: %[[UB:.*]] = arith.constant 10 : index
96+
!HOST: %[[STEP:.*]] = arith.constant 1 : index
97+
!HOST: %[[SHAPE_VAL10:.*]] = arith.constant 10 : index
98+
!HOST: %[[SHAPE:.*]] = fir.shape %[[SHAPE_VAL10]] : (index) -> !fir.shape<1>
99+
!HOST: %[[READ_WRITE_DESIGNATE:.*]] = hlfir.designate %[[READ_WRITE_DECL]]#0 (%[[LB]]:%[[UB]]:%[[STEP]]) shape %[[SHAPE]] : (!fir.ref<!fir.array<20xi32>>, index, index, index, !fir.shape<1>) -> !fir.ref<!fir.array<10xi32>>
100+
!HOST: %[[READ_WRITE_EMBOX:.*]] = fir.embox %[[READ_WRITE_DESIGNATE]](%[[SHAPE]]) : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<10xi32>>
101+
!HOST: %[[ARG0:.*]] = fir.convert %[[READ_WRITE_EMBOX]] : (!fir.box<!fir.array<10xi32>>) -> !fir.box<!fir.array<?xi32>>
102+
!HOST: fir.call @_QMassumed_array_routinesPassumed_shape_array(%[[ARG0]]) fastmath<contract> : (!fir.box<!fir.array<?xi32>>) -> ()
103+
!HOST: %[[LB:.*]] = arith.constant 10 : index
104+
!HOST: %[[UB:.*]] = arith.constant 20 : index
105+
!HOST: %[[STEP:.*]] = arith.constant 1 : index
106+
!HOST: %[[SHAPE_VAL11:.*]] = arith.constant 11 : index
107+
!HOST: %[[SHAPE:.*]] = fir.shape %[[SHAPE_VAL11]] : (index) -> !fir.shape<1>
108+
!HOST: %[[READ_WRITE_EMBOX:.*]] = hlfir.designate %[[READ_WRITE_DECL]]#0 (%[[LB]]:%[[UB]]:%[[STEP]]) shape %[[SHAPE]] : (!fir.ref<!fir.array<20xi32>>, index, index, index, !fir.shape<1>) -> !fir.ref<!fir.array<11xi32>>
109+
!HOST: %[[ARG1:.*]] = fir.convert %[[READ_WRITE_EMBOX]] : (!fir.ref<!fir.array<11xi32>>) -> !fir.ref<!fir.array<?xi32>>
110+
!HOST: fir.call @_QMassumed_array_routinesPassumed_size_array(%[[ARG1]]) fastmath<contract> : (!fir.ref<!fir.array<?xi32>>) -> ()
111+
!HOST: return
112+
!HOST:}
113+
114+
subroutine call_assumed_shape_and_size_array
115+
use assumed_array_routines
116+
integer :: arr_read_write(20)
117+
call assumed_shape_array(arr_read_write(1:10))
118+
call assumed_size_array(arr_read_write(10:20))
119+
end subroutine call_assumed_shape_and_size_array

lld/ELF/Arch/AArch64.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ void AArch64::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
770770
uint64_t secAddr = sec.getOutputSection()->addr;
771771
if (auto *s = dyn_cast<InputSection>(&sec))
772772
secAddr += s->outSecOff;
773+
else if (auto *ehIn = dyn_cast<EhInputSection>(&sec))
774+
secAddr += ehIn->getParent()->outSecOff;
773775
AArch64Relaxer relaxer(sec.relocs());
774776
for (size_t i = 0, size = sec.relocs().size(); i != size; ++i) {
775777
const Relocation &rel = sec.relocs()[i];

lld/ELF/Arch/PPC64.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,8 @@ void PPC64::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
15631563
uint64_t secAddr = sec.getOutputSection()->addr;
15641564
if (auto *s = dyn_cast<InputSection>(&sec))
15651565
secAddr += s->outSecOff;
1566+
else if (auto *ehIn = dyn_cast<EhInputSection>(&sec))
1567+
secAddr += ehIn->getParent()->outSecOff;
15661568
uint64_t lastPPCRelaxedRelocOff = -1;
15671569
for (const Relocation &rel : sec.relocs()) {
15681570
uint8_t *loc = buf + rel.offset;

lld/ELF/Arch/X86_64.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,8 @@ void X86_64::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
989989
uint64_t secAddr = sec.getOutputSection()->addr;
990990
if (auto *s = dyn_cast<InputSection>(&sec))
991991
secAddr += s->outSecOff;
992+
else if (auto *ehIn = dyn_cast<EhInputSection>(&sec))
993+
secAddr += ehIn->getParent()->outSecOff;
992994
for (const Relocation &rel : sec.relocs()) {
993995
if (rel.expr == R_NONE) // See deleteFallThruJmpInsn
994996
continue;

lld/ELF/SyntheticSections.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,14 @@ static uint64_t readFdeAddr(uint8_t *buf, int size) {
583583
uint64_t EhFrameSection::getFdePc(uint8_t *buf, size_t fdeOff,
584584
uint8_t enc) const {
585585
// The starting address to which this FDE applies is
586-
// stored at FDE + 8 byte.
586+
// stored at FDE + 8 byte. And this offset is within
587+
// the .eh_frame section.
587588
size_t off = fdeOff + 8;
588589
uint64_t addr = readFdeAddr(buf + off, enc & 0xf);
589590
if ((enc & 0x70) == DW_EH_PE_absptr)
590591
return addr;
591592
if ((enc & 0x70) == DW_EH_PE_pcrel)
592-
return addr + getParent()->addr + off;
593+
return addr + getParent()->addr + off + outSecOff;
593594
fatal("unknown FDE size relative encoding");
594595
}
595596

lld/ELF/Target.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ void TargetInfo::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
159159
uint64_t secAddr = sec.getOutputSection()->addr;
160160
if (auto *s = dyn_cast<InputSection>(&sec))
161161
secAddr += s->outSecOff;
162+
else if (auto *ehIn = dyn_cast<EhInputSection>(&sec))
163+
secAddr += ehIn->getParent()->outSecOff;
162164
for (const Relocation &rel : sec.relocs()) {
163165
uint8_t *loc = buf + rel.offset;
164166
const uint64_t val = SignExtend64(
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// REQUIRES: aarch64
2+
// RUN: rm -rf %t && split-file %s %t && cd %t
3+
4+
// RUN: llvm-mc -filetype=obj -triple=aarch64 a.s -o a.o
5+
// RUN: ld.lld a.o -T eh-frame-non-zero-offset.t -o non-zero
6+
// RUN: llvm-readelf --program-headers --unwind --symbols -x .eh_frame non-zero | FileCheck --check-prefix=NONZERO %s
7+
// RUN: ld.lld a.o -T eh-frame-zero-offset.t -o zero
8+
// RUN: llvm-readelf --program-headers --unwind --symbols -x .eh_frame zero | FileCheck --check-prefix=ZERO %s
9+
10+
// NONZERO: {{[0-9]+}}: 0000000000000088 {{.*}} __eh_frame_start
11+
// NONZERO-NEXT: {{[0-9]+}}: 00000000000000b4 {{.*}} __eh_frame_end
12+
13+
// NONZERO: 0x00000088 10000000 00000000 017a5200 017c1e01
14+
// NONZERO-NEXT: 0x00000098 1b0c1f00 10000000 18000000 5cffffff
15+
// NONZERO-NEXT: 0x000000a8 04000000 00000000 00000000
16+
17+
// ZERO: {{[0-9]+}}: 0000000000000008 {{.*}} __eh_frame_start
18+
// ZERO-NEXT: {{[0-9]+}}: 0000000000000034 {{.*}} __eh_frame_end
19+
20+
// ZERO: 0x00000008 10000000 00000000 017a5200 017c1e01
21+
// ZERO-NEXT: 0x00000018 1b0c1f00 10000000 18000000 dcffffff
22+
// ZERO-NEXT: 0x00000028 04000000 00000000 00000000
23+
24+
//--- eh-frame-non-zero-offset.t
25+
SECTIONS {
26+
.text : { *(.text .text.*) }
27+
.eh_frame : {
28+
/* Padding within .eh_frame */
29+
. += 128;
30+
__eh_frame_start = .;
31+
*(.eh_frame) ;
32+
__eh_frame_end = .;
33+
}
34+
}
35+
36+
//--- eh-frame-zero-offset.t
37+
SECTIONS {
38+
.text : { *(.text .text.*) }
39+
.eh_frame : {
40+
__eh_frame_start = .;
41+
*(.eh_frame) ;
42+
__eh_frame_end = .;
43+
}
44+
}
45+
46+
//--- a.s
47+
.section .text.01, "ax",%progbits
48+
.global f1
49+
.type f1, %function
50+
f1:
51+
.cfi_startproc
52+
.space 4
53+
.cfi_endproc
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// REQUIRES: arm
2+
// RUN: rm -rf %t && split-file %s %t && cd %t
3+
4+
// RUN: llvm-mc -filetype=obj -triple=arm a.s -o a.o
5+
// RUN: ld.lld a.o -T eh-frame-non-zero-offset.t -o non-zero
6+
// RUN: llvm-readelf --program-headers --unwind --symbols -x .eh_frame non-zero | FileCheck --check-prefix=NONZERO %s
7+
// RUN: ld.lld a.o -T eh-frame-zero-offset.t -o zero
8+
// RUN: llvm-readelf --program-headers --unwind --symbols -x .eh_frame zero | FileCheck --check-prefix=ZERO %s
9+
10+
// NONZERO: {{[0-9]+}}: 00000084 {{.*}} __eh_frame_start
11+
// NONZERO-NEXT: {{[0-9]+}}: 000000b0 {{.*}} __eh_frame_end
12+
13+
// NONZERO: 0x00000084 10000000 00000000 017a5200 017c0e01
14+
// NONZERO-NEXT: 0x00000094 1b0c0d00 10000000 18000000 60ffffff
15+
// NONZERO-NEXT: 0x000000a4 04000000 00000000 00000000
16+
17+
// ZERO: {{[0-9]+}}: 00000004 {{.*}} __eh_frame_start
18+
// ZERO-NEXT: {{[0-9]+}}: 00000030 {{.*}} __eh_frame_end
19+
20+
// ZERO: 0x00000004 10000000 00000000 017a5200 017c0e01
21+
// ZERO-NEXT: 0x00000014 1b0c0d00 10000000 18000000 e0ffffff
22+
// ZERO-NEXT: 0x00000024 04000000 00000000 00000000
23+
24+
//--- eh-frame-non-zero-offset.t
25+
SECTIONS {
26+
.text : { *(.text .text.*) }
27+
.eh_frame : {
28+
/* Padding within .eh_frame */
29+
. += 128;
30+
__eh_frame_start = .;
31+
*(.eh_frame) ;
32+
__eh_frame_end = .;
33+
}
34+
}
35+
36+
//--- eh-frame-zero-offset.t
37+
SECTIONS {
38+
.text : { *(.text .text.*) }
39+
.eh_frame : {
40+
__eh_frame_start = .;
41+
*(.eh_frame) ;
42+
__eh_frame_end = .;
43+
}
44+
}
45+
46+
//--- a.s
47+
.section .text.01, "ax",%progbits
48+
.global f1
49+
.type f1, %function
50+
f1:
51+
.cfi_startproc
52+
.cfi_sections .eh_frame
53+
.space 4
54+
.cfi_endproc
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// REQUIRES: ppc
2+
// RUN: rm -rf %t && split-file %s %t && cd %t
3+
4+
// RUN: llvm-mc -filetype=obj -triple=ppc64le a.s -o a.o
5+
// RUN: ld.lld a.o -T eh-frame-non-zero-offset.t -o non-zero
6+
// RUN: llvm-readelf --program-headers --unwind --symbols -x .eh_frame non-zero | FileCheck --check-prefix=NONZERO %s
7+
// RUN: ld.lld a.o -T eh-frame-zero-offset.t -o zero
8+
// RUN: llvm-readelf --program-headers --unwind --symbols -x .eh_frame zero | FileCheck --check-prefix=ZERO %s
9+
10+
// NONZERO: {{[0-9]+}}: 0000000000000088 {{.*}} __eh_frame_start
11+
// NONZERO-NEXT: {{[0-9]+}}: 00000000000000b4 {{.*}} __eh_frame_end
12+
13+
// NONZERO: 0x00000088 10000000 00000000 017a5200 04784101
14+
// NONZERO-NEXT: 0x00000098 1b0c0100 10000000 18000000 5cffffff
15+
// NONZERO-NEXT: 0x000000a8 04000000 00000000 00000000
16+
17+
// ZERO: {{[0-9]+}}: 0000000000000008 {{.*}} __eh_frame_start
18+
// ZERO-NEXT: {{[0-9]+}}: 0000000000000034 {{.*}} __eh_frame_end
19+
20+
// ZERO: 0x00000008 10000000 00000000 017a5200 04784101
21+
// ZERO-NEXT: 0x00000018 1b0c0100 10000000 18000000 dcffffff
22+
// ZERO-NEXT: 0x00000028 04000000 00000000 00000000
23+
24+
//--- eh-frame-non-zero-offset.t
25+
SECTIONS {
26+
.text : { *(.text .text.*) }
27+
.eh_frame : {
28+
/* Padding within .eh_frame */
29+
. += 128;
30+
__eh_frame_start = .;
31+
*(.eh_frame) ;
32+
__eh_frame_end = .;
33+
}
34+
}
35+
36+
//--- eh-frame-zero-offset.t
37+
SECTIONS {
38+
.text : { *(.text .text.*) }
39+
.eh_frame : {
40+
__eh_frame_start = .;
41+
*(.eh_frame) ;
42+
__eh_frame_end = .;
43+
}
44+
}
45+
46+
//--- a.s
47+
.section .text.01, "ax",%progbits
48+
.global f1
49+
.type f1, %function
50+
f1:
51+
.cfi_startproc
52+
.space 4
53+
.cfi_endproc
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// REQUIRES: x86
2+
// RUN: rm -rf %t && split-file %s %t && cd %t
3+
4+
// RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
5+
// RUN: ld.lld a.o -T eh-frame-non-zero-offset.t -o non-zero
6+
// RUN: llvm-readelf --program-headers --unwind --symbols -x .eh_frame non-zero | FileCheck --check-prefix=NONZERO %s
7+
// RUN: ld.lld a.o -T eh-frame-zero-offset.t -o zero
8+
// RUN: llvm-readelf --program-headers --unwind --symbols -x .eh_frame zero | FileCheck --check-prefix=ZERO %s
9+
10+
// NONZERO: {{[0-9]+}}: 0000000000000088 {{.*}} __eh_frame_start
11+
// NONZERO-NEXT: {{[0-9]+}}: 00000000000000bc {{.*}} __eh_frame_end
12+
13+
// NONZERO: 0x00000088 14000000 00000000 017a5200 01781001
14+
// NONZERO-NEXT: 0x00000098 1b0c0708 90010000 14000000 1c000000
15+
// NONZERO-NEXT: 0x000000a8 58ffffff 04000000 00000000 00000000
16+
// NONZERO-NEXT: 0x000000b8 00000000
17+
18+
// ZERO: {{[0-9]+}}: 0000000000000008 {{.*}} __eh_frame_start
19+
// ZERO-NEXT: {{[0-9]+}}: 000000000000003c {{.*}} __eh_frame_end
20+
21+
// ZERO: 0x00000008 14000000 00000000 017a5200 01781001
22+
// ZERO-NEXT: 0x00000018 1b0c0708 90010000 14000000 1c000000
23+
// ZERO-NEXT: 0x00000028 d8ffffff 04000000 00000000 00000000
24+
// ZERO-NEXT: 0x00000038 00000000
25+
26+
//--- eh-frame-non-zero-offset.t
27+
SECTIONS {
28+
.text : { *(.text .text.*) }
29+
.eh_frame : {
30+
/* Padding within .eh_frame */
31+
. += 128;
32+
__eh_frame_start = .;
33+
*(.eh_frame) ;
34+
__eh_frame_end = .;
35+
}
36+
}
37+
38+
//--- eh-frame-zero-offset.t
39+
SECTIONS {
40+
.text : { *(.text .text.*) }
41+
.eh_frame : {
42+
__eh_frame_start = .;
43+
*(.eh_frame) ;
44+
__eh_frame_end = .;
45+
}
46+
}
47+
48+
//--- a.s
49+
.section .text.01, "ax",%progbits
50+
.global f1
51+
.type f1, %function
52+
f1:
53+
.cfi_startproc
54+
.space 4
55+
.cfi_endproc

0 commit comments

Comments
 (0)