Skip to content

Commit c815fe2

Browse files
MaskRayyuxuanchen1997
authored andcommitted
[AArch64,ELF] Use getCurrentSection().first in changeSection
Summary: Similar to the NVPTX change 4ae23bc. And improve the tests. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251399
1 parent b1c58a4 commit c815fe2

File tree

2 files changed

+41
-29
lines changed

2 files changed

+41
-29
lines changed

llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class AArch64ELFStreamer : public MCELFStreamer {
187187
// We have to keep track of the mapping symbol state of any sections we
188188
// use. Each one should start off as EMS_None, which is provided as the
189189
// default constructor by DenseMap::lookup.
190-
LastMappingSymbols[getPreviousSection().first] = LastEMS;
190+
LastMappingSymbols[getCurrentSection().first] = LastEMS;
191191
LastEMS = LastMappingSymbols.lookup(Section);
192192

193193
MCELFStreamer::changeSection(Section, Subsection);
+40-28
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
1-
// RUN: llvm-mc -triple=aarch64-none-linux-gnu -filetype=obj < %s | llvm-objdump -t - | FileCheck %s
2-
3-
.text
4-
add w0, w0, w0
5-
6-
// .wibble should *not* inherit .text's mapping symbol. It's a completely different section.
7-
.section .wibble
8-
add w0, w0, w0
9-
10-
// A setion should be able to start with a $d
11-
.section .starts_data
12-
.word 42
13-
14-
// Changing back to .text should not emit a redundant $x
15-
.text
16-
add w0, w0, w0
17-
18-
// With all those constraints, we want:
19-
// + .text to have $x at 0 and no others
20-
// + .wibble to have $x at 0
21-
// + .starts_data to have $d at 0
22-
23-
24-
// CHECK: 0000000000000000 l .text 0000000000000000 $x
25-
// CHECK-NEXT: 0000000000000000 l .wibble 0000000000000000 $x
26-
// CHECK-NEXT: 0000000000000000 l .starts_data 0000000000000000 $d
27-
// CHECK-NOT: ${{[adtx]}}
28-
1+
// RUN: llvm-mc -triple=aarch64 -filetype=obj %s | llvm-objdump -t - | FileCheck %s
2+
3+
.section .text1,"ax"
4+
add w0, w0, w0
5+
6+
.text
7+
add w0, w0, w0
8+
.word 42
9+
10+
.pushsection .data,"aw"
11+
.word 42
12+
.popsection
13+
14+
.text
15+
add w1, w1, w1
16+
17+
.section .text1,"ax"
18+
add w1, w1, w1
19+
20+
.text
21+
.word 42
22+
23+
.section .rodata,"a"
24+
.word 42
25+
add w0, w0, w0
26+
27+
.ident "clang"
28+
.section ".note.GNU-stack","",@progbits
29+
30+
// CHECK: SYMBOL TABLE:
31+
// CHECK-NEXT: 0000000000000000 l .text1 0000000000000000 $x.0
32+
// CHECK-NEXT: 0000000000000000 l .text 0000000000000000 $x.1
33+
// CHECK-NEXT: 0000000000000004 l .text 0000000000000000 $d.2
34+
// CHECK-NEXT: 0000000000000000 l .data 0000000000000000 $d.3
35+
// CHECK-NEXT: 0000000000000008 l .text 0000000000000000 $x.4
36+
// CHECK-NEXT: 000000000000000c l .text 0000000000000000 $d.5
37+
// CHECK-NEXT: 0000000000000000 l .rodata 0000000000000000 $d.6
38+
// CHECK-NEXT: 0000000000000004 l .rodata 0000000000000000 $x.7
39+
// CHECK-NEXT: 0000000000000000 l .comment 0000000000000000 $d.8
40+
// CHECK-NOT: {{.}}

0 commit comments

Comments
 (0)