mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-18 17:17:49 +00:00
MCELF: Copy the symbol name only if we're going to modify it.
llvm-svn: 118920
This commit is contained in:
parent
8bb507dd6b
commit
b4c0c4211e
@ -1016,21 +1016,20 @@ void ELFObjectWriterImpl::ComputeSymbolTable(MCAssembler &Asm,
|
|||||||
// The @@@ in symbol version is replaced with @ in undefined symbols and
|
// The @@@ in symbol version is replaced with @ in undefined symbols and
|
||||||
// @@ in defined ones.
|
// @@ in defined ones.
|
||||||
StringRef Name = Symbol.getName();
|
StringRef Name = Symbol.getName();
|
||||||
|
SmallString<32> Buf;
|
||||||
|
|
||||||
size_t Pos = Name.find("@@@");
|
size_t Pos = Name.find("@@@");
|
||||||
std::string FinalName;
|
|
||||||
if (Pos != StringRef::npos) {
|
if (Pos != StringRef::npos) {
|
||||||
StringRef Prefix = Name.substr(0, Pos);
|
Buf += Name.substr(0, Pos);
|
||||||
unsigned n = MSD.SectionIndex == ELF::SHN_UNDEF ? 2 : 1;
|
unsigned Skip = MSD.SectionIndex == ELF::SHN_UNDEF ? 2 : 1;
|
||||||
StringRef Suffix = Name.substr(Pos + n);
|
Buf += Name.substr(Pos + Skip);
|
||||||
FinalName = Prefix.str() + Suffix.str();
|
Name = Buf;
|
||||||
} else {
|
|
||||||
FinalName = Name.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t &Entry = StringIndexMap[FinalName];
|
uint64_t &Entry = StringIndexMap[Name];
|
||||||
if (!Entry) {
|
if (!Entry) {
|
||||||
Entry = StringTable.size();
|
Entry = StringTable.size();
|
||||||
StringTable += FinalName;
|
StringTable += Name;
|
||||||
StringTable += '\x00';
|
StringTable += '\x00';
|
||||||
}
|
}
|
||||||
MSD.StringIndex = Entry;
|
MSD.StringIndex = Entry;
|
||||||
|
Loading…
Reference in New Issue
Block a user