[lld] r259946 - ELF: Make EHOutputSection::readEntryLength a non-member function.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 5 14:56:03 PST 2016
Author: ruiu
Date: Fri Feb 5 16:56:03 2016
New Revision: 259946
URL: http://llvm.org/viewvc/llvm-project?rev=259946&view=rev
Log:
ELF: Make EHOutputSection::readEntryLength a non-member function.
This function did not use any fields of the class.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=259946&r1=259945&r2=259946&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Feb 5 16:56:03 2016
@@ -964,6 +964,31 @@ uint8_t EHOutputSection<ELFT>::getFdeEnc
}
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>::addSectionAu
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>::addSectionAu
}
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;
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=259946&r1=259945&r2=259946&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Fri Feb 5 16:56:03 2016
@@ -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;
More information about the llvm-commits
mailing list