diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-11-08 20:25:44 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-11-08 20:25:44 +0000 |
| commit | 0811385d24a7b06151a834fe9ccadaa41a85fe6b (patch) | |
| tree | d0ff06aaf0ef6b0864f0c09898f9b1bd15c428fd /lld/ELF/OutputSections.cpp | |
| parent | 05effca2d8b78216e054e37cecd46bedb92c97fd (diff) | |
| download | bcm5719-llvm-0811385d24a7b06151a834fe9ccadaa41a85fe6b.tar.gz bcm5719-llvm-0811385d24a7b06151a834fe9ccadaa41a85fe6b.zip | |
Store the size the same way as any other OutputSection. NFC.
llvm-svn: 286286
Diffstat (limited to 'lld/ELF/OutputSections.cpp')
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index bd3bec0579e..9b08ef122f1 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -1328,7 +1328,10 @@ template <class ELFT> StringTableSection<ELFT>::StringTableSection(StringRef Name, bool Dynamic) : OutputSectionBase<ELFT>(Name, SHT_STRTAB, Dynamic ? (uintX_t)SHF_ALLOC : 0), - Dynamic(Dynamic) {} + Dynamic(Dynamic) { + // ELF string tables start with a NUL byte, so 1. + this->setSize(1); +} // Adds a string to the string table. If HashIt is true we hash and check for // duplicates. It is optional because the name of global symbols are already @@ -1337,12 +1340,12 @@ StringTableSection<ELFT>::StringTableSection(StringRef Name, bool Dynamic) template <class ELFT> unsigned StringTableSection<ELFT>::addString(StringRef S, bool HashIt) { if (HashIt) { - auto R = StringMap.insert(std::make_pair(S, Size)); + auto R = StringMap.insert(std::make_pair(S, this->getSize())); if (!R.second) return R.first->second; } - unsigned Ret = Size; - Size += S.size() + 1; + unsigned Ret = this->getSize(); + this->setSize(this->getSize() + S.size() + 1); Strings.push_back(S); return Ret; } |

