diff options
author | Rui Ueyama <ruiu@google.com> | 2016-02-05 22:56:03 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2016-02-05 22:56:03 +0000 |
commit | c0c92609c443e793f8072eadb5f54d0eccf8f852 (patch) | |
tree | 567c5decdeda7a0a991a8b2b25ed865c470f50d5 | |
parent | 95708931cf993a3831e34a135c4e887eec4910b5 (diff) | |
download | bcm5719-llvm-c0c92609c443e793f8072eadb5f54d0eccf8f852.tar.gz bcm5719-llvm-c0c92609c443e793f8072eadb5f54d0eccf8f852.zip |
ELF: Make EHOutputSection::readEntryLength a non-member function.
This function did not use any fields of the class.
llvm-svn: 259946
-rw-r--r-- | lld/ELF/OutputSections.cpp | 53 | ||||
-rw-r--r-- | lld/ELF/OutputSections.h | 1 |
2 files changed, 26 insertions, 28 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 3c0f58ea44d..1caf452488c 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -964,6 +964,31 @@ uint8_t EHOutputSection<ELFT>::getFdeEncoding(ArrayRef<uint8_t> D) { } template <class ELFT> +static typename ELFFile<ELFT>::uintX_t readEntryLength(ArrayRef<uint8_t> D) { + const endianness E = ELFT::TargetEndianness; + + if (D.size() < 4) + fatal("Truncated CIE/FDE length"); + uint64_t Len = read32<E>(D.data()); + if (Len < UINT32_MAX) { + if (Len > (UINT32_MAX - 4)) + fatal("CIE/FIE size is too large"); + if (Len + 4 > D.size()) + fatal("CIE/FIE ends past the end of the section"); + return Len + 4; + } + + if (D.size() < 12) + fatal("Truncated CIE/FDE length"); + Len = read64<E>(D.data() + 4); + if (Len > (UINT64_MAX - 12)) + fatal("CIE/FIE size is too large"); + if (Len + 12 > D.size()) + fatal("CIE/FIE ends past the end of the section"); + return Len + 12; +} + +template <class ELFT> template <bool IsRela> void EHOutputSection<ELFT>::addSectionAux( EHInputSection<ELFT> *S, @@ -985,7 +1010,7 @@ void EHOutputSection<ELFT>::addSectionAux( unsigned Index = S->Offsets.size(); S->Offsets.push_back(std::make_pair(Offset, -1)); - uintX_t Length = readEntryLength(D); + uintX_t Length = readEntryLength<ELFT>(D); // If CIE/FDE data length is zero then Length is 4, this // shall be considered a terminator and processing shall end. if (Length == 4) @@ -1039,32 +1064,6 @@ void EHOutputSection<ELFT>::addSectionAux( } template <class ELFT> -typename EHOutputSection<ELFT>::uintX_t -EHOutputSection<ELFT>::readEntryLength(ArrayRef<uint8_t> D) { - const endianness E = ELFT::TargetEndianness; - - if (D.size() < 4) - fatal("Truncated CIE/FDE length"); - uint64_t Len = read32<E>(D.data()); - if (Len < UINT32_MAX) { - if (Len > (UINT32_MAX - 4)) - fatal("CIE/FIE size is too large"); - if (Len + 4 > D.size()) - fatal("CIE/FIE ends past the end of the section"); - return Len + 4; - } - - if (D.size() < 12) - fatal("Truncated CIE/FDE length"); - Len = read64<E>(D.data() + 4); - if (Len > (UINT64_MAX - 12)) - fatal("CIE/FIE size is too large"); - if (Len + 12 > D.size()) - fatal("CIE/FIE ends past the end of the section"); - return Len + 12; -} - -template <class ELFT> void EHOutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C) { auto *S = cast<EHInputSection<ELFT>>(C); const Elf_Shdr *RelSec = S->RelocSection; diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index ffb338625e6..a7b67484c94 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -337,7 +337,6 @@ public: private: uint8_t getFdeEncoding(ArrayRef<uint8_t> D); - uintX_t readEntryLength(ArrayRef<uint8_t> D); std::vector<EHInputSection<ELFT> *> Sections; std::vector<Cie<ELFT>> Cies; |