diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-02-17 05:06:40 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-02-17 05:06:40 +0000 |
| commit | c2e863a0d8dc2c5b9025e3fec787c541afe0ef49 (patch) | |
| tree | d943e7ea5a25b640d980b8d1183222722ae5c202 /lld/ELF/OutputSections.cpp | |
| parent | 874e7aee29857930f6a8572b9b367757810957fc (diff) | |
| download | bcm5719-llvm-c2e863a0d8dc2c5b9025e3fec787c541afe0ef49.tar.gz bcm5719-llvm-c2e863a0d8dc2c5b9025e3fec787c541afe0ef49.zip | |
Use an accurate type instead of unsigned.
These values are offsets in the string table (which must fit in
host computer's memory space), so size_t is better than unsigned.
llvm-svn: 261065
Diffstat (limited to 'lld/ELF/OutputSections.cpp')
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 2a385502cb9..828a0053bbd 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -473,11 +473,11 @@ static bool includeInGnuHashTable(SymbolBody *B) { template <class ELFT> void GnuHashTableSection<ELFT>::addSymbols( - std::vector<std::pair<SymbolBody *, unsigned>> &Symbols) { - std::vector<std::pair<SymbolBody *, unsigned>> NotHashed; + std::vector<std::pair<SymbolBody *, size_t>> &Symbols) { + std::vector<std::pair<SymbolBody *, size_t>> NotHashed; NotHashed.reserve(Symbols.size()); HashedSymbols.reserve(Symbols.size()); - for (const std::pair<SymbolBody *, unsigned> &P : Symbols) { + for (const std::pair<SymbolBody *, size_t> &P : Symbols) { SymbolBody *B = P.first; if (includeInGnuHashTable(B)) HashedSymbols.push_back( @@ -1386,14 +1386,13 @@ template <class ELFT> void SymbolTableSection<ELFT>::finalize() { else if (Config->EMachine == EM_MIPS) std::stable_sort(Symbols.begin(), Symbols.end(), sortMipsSymbols); size_t I = 0; - for (const std::pair<SymbolBody *, unsigned> &P : Symbols) + for (const std::pair<SymbolBody *, size_t> &P : Symbols) P.first->DynsymIndex = ++I; } template <class ELFT> -void SymbolTableSection<ELFT>::addSymbol(SymbolBody *Body) { - Symbols.push_back( - std::make_pair(Body, StrTabSec.addString(Body->getName(), false))); +void SymbolTableSection<ELFT>::addSymbol(SymbolBody *B) { + Symbols.push_back({B, StrTabSec.addString(B->getName(), false)}); } template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *Buf) { @@ -1412,7 +1411,7 @@ void SymbolTableSection<ELFT>::writeLocalSymbols(uint8_t *&Buf) { // Iterate over all input object files to copy their local symbols // to the output symbol table pointed by Buf. for (const std::unique_ptr<ObjectFile<ELFT>> &File : Table.getObjectFiles()) { - for (const std::pair<const Elf_Sym *, unsigned> &P : File->KeptLocalSyms) { + for (const std::pair<const Elf_Sym *, size_t> &P : File->KeptLocalSyms) { const Elf_Sym *Sym = P.first; auto *ESym = reinterpret_cast<Elf_Sym *>(Buf); @@ -1454,9 +1453,9 @@ void SymbolTableSection<ELFT>::writeGlobalSymbols(uint8_t *Buf) { // Write the internal symbol table contents to the output symbol table // pointed by Buf. auto *ESym = reinterpret_cast<Elf_Sym *>(Buf); - for (const std::pair<SymbolBody *, unsigned> &P : Symbols) { + for (const std::pair<SymbolBody *, size_t> &P : Symbols) { SymbolBody *Body = P.first; - unsigned SymIdx = P.second; + size_t StrOff = P.second; unsigned char Type = STT_NOTYPE; uintX_t Size = 0; @@ -1470,7 +1469,7 @@ void SymbolTableSection<ELFT>::writeGlobalSymbols(uint8_t *Buf) { ESym->setBindingAndType(getSymbolBinding(Body), Type); ESym->st_size = Size; - ESym->st_name = SymIdx; + ESym->st_name = StrOff; ESym->setVisibility(Body->getVisibility()); ESym->st_value = Body->getVA<ELFT>(); |

