diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-11-12 19:26:04 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-11-12 19:26:04 +0000 |
commit | 1261a2ff99299946952013f284615a06afa3dc50 (patch) | |
tree | 502c71c3febb347fe179cf5bf05b06415b739bc0 /lib/MC/ELFObjectWriter.cpp | |
parent | a0a6a47c02d360e8a167a6a28f03a3b453c38fbb (diff) |
MCELF: Copy the symbol name only if we're going to modify it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118920 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index f8caee9882..10600a5acd 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -1016,21 +1016,20 @@ void ELFObjectWriterImpl::ComputeSymbolTable(MCAssembler &Asm, // The @@@ in symbol version is replaced with @ in undefined symbols and // @@ in defined ones. StringRef Name = Symbol.getName(); + SmallString<32> Buf; + size_t Pos = Name.find("@@@"); - std::string FinalName; if (Pos != StringRef::npos) { - StringRef Prefix = Name.substr(0, Pos); - unsigned n = MSD.SectionIndex == ELF::SHN_UNDEF ? 2 : 1; - StringRef Suffix = Name.substr(Pos + n); - FinalName = Prefix.str() + Suffix.str(); - } else { - FinalName = Name.str(); + Buf += Name.substr(0, Pos); + unsigned Skip = MSD.SectionIndex == ELF::SHN_UNDEF ? 2 : 1; + Buf += Name.substr(Pos + Skip); + Name = Buf; } - uint64_t &Entry = StringIndexMap[FinalName]; + uint64_t &Entry = StringIndexMap[Name]; if (!Entry) { Entry = StringTable.size(); - StringTable += FinalName; + StringTable += Name; StringTable += '\x00'; } MSD.StringIndex = Entry; |