Skip to content

Commit 091de2f

Browse files
MaskRayyuxuanchen1997
authored andcommitted
[CSKY] Create mapping symbols with non-unique names
Similar to #99836 for AArch64. Non-unique names save .strtab space and match GNU assembler.
1 parent 36dc399 commit 091de2f

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFStreamer.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ void CSKYELFStreamer::EmitMappingSymbol(StringRef Name) {
168168

169169
State = (Name == "$t" ? EMS_Text : EMS_Data);
170170

171-
auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
172-
Name + "." + Twine(MappingSymbolCounter++)));
171+
auto *Symbol = cast<MCSymbolELF>(getContext().createLocalSymbol(Name));
173172
emitLabel(Symbol);
174173

175174
Symbol->setType(ELF::STT_NOTYPE);

llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFStreamer.h

-3
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ class CSKYTargetELFStreamer : public CSKYTargetStreamer {
9999
};
100100

101101
class CSKYELFStreamer : public MCELFStreamer {
102-
int64_t MappingSymbolCounter = 0;
103-
104102
void EmitMappingSymbol(StringRef Name);
105103

106104
public:
@@ -138,7 +136,6 @@ class CSKYELFStreamer : public MCELFStreamer {
138136
MCELFStreamer::emitValueImpl(Value, Size, Loc);
139137
}
140138
void reset() override {
141-
MappingSymbolCounter = 0;
142139
State = EMS_None;
143140
MCELFStreamer::reset();
144141
}

llvm/test/DebugInfo/Symbolize/ELF/csky-mapping-symbol.s

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
## Verify that mapping symbols are actually present in the object at expected
77
## addresses.
8-
# RUN: llvm-nm --special-syms %t | FileCheck %s -check-prefix MAPPING_SYM
8+
# RUN: llvm-nm --special-syms %t | FileCheck %s -check-prefix MAPPING_SYM --match-full-lines
99

10-
# MAPPING_SYM: 00000000 t $d.0
11-
# MAPPING_SYM-NEXT: 00000008 t $d.2
12-
# MAPPING_SYM-NEXT: 00000004 t $t.1
10+
# MAPPING_SYM: 00000000 t $d
11+
# MAPPING_SYM-NEXT: 00000008 t $d
12+
# MAPPING_SYM-NEXT: 00000004 t $t
1313
# MAPPING_SYM-NEXT: 00000000 T foo
1414

1515
# RUN: llvm-symbolizer --obj=%t 0 4 0xc | FileCheck %s -check-prefix SYMBOL

0 commit comments

Comments
 (0)