[lld] r270448 - Remove EhFrameHeader<ELFT>::reserveFde. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon May 23 09:30:41 PDT 2016
Author: ruiu
Date: Mon May 23 11:30:41 2016
New Revision: 270448
URL: http://llvm.org/viewvc/llvm-project?rev=270448&view=rev
Log:
Remove EhFrameHeader<ELFT>::reserveFde. NFC.
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=270448&r1=270447&r2=270448&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon May 23 11:30:41 2016
@@ -713,12 +713,7 @@ template <class ELFT> void DynamicSectio
template <class ELFT>
EhFrameHeader<ELFT>::EhFrameHeader()
- : OutputSectionBase<ELFT>(".eh_frame_hdr", llvm::ELF::SHT_PROGBITS,
- SHF_ALLOC) {
- // It's a 4 bytes of header + pointer to the contents of the .eh_frame section
- // + the number of FDE pointers in the table.
- this->Header.sh_size = 12;
-}
+ : OutputSectionBase<ELFT>(".eh_frame_hdr", SHT_PROGBITS, SHF_ALLOC) {}
// .eh_frame_hdr contains a binary search table of pointers to FDEs.
// Each entry of the search table consists of two values,
@@ -751,18 +746,16 @@ template <class ELFT> void EhFrameHeader
}
}
+template <class ELFT> void EhFrameHeader<ELFT>::finalize() {
+ // .eh_frame_hdr has a 12 bytes header followed by an array of FDEs.
+ this->Header.sh_size = 12 + Out<ELFT>::EhFrame->NumFdes * 8;
+}
+
template <class ELFT>
void EhFrameHeader<ELFT>::addFde(uint32_t Pc, uint32_t FdeVA) {
Fdes.push_back({Pc, FdeVA});
}
-template <class ELFT> void EhFrameHeader<ELFT>::reserveFde() {
- // Each FDE entry is 8 bytes long:
- // The first four bytes are an offset to the initial PC value for the FDE. The
- // last four byte are an offset to the FDE data itself.
- this->Header.sh_size += 8;
-}
-
template <class ELFT>
OutputSection<ELFT>::OutputSection(StringRef Name, uint32_t Type, uintX_t Flags)
: OutputSectionBase<ELFT>(Name, Type, Flags) {
@@ -1108,8 +1101,7 @@ void EhOutputSection<ELFT>::addSectionAu
if (!isFdeLive(FdePiece, Sec, Rels))
continue;
Cie->FdePieces.push_back(&FdePiece);
- if (Out<ELFT>::EhFrameHdr)
- Out<ELFT>::EhFrameHdr->reserveFde();
+ NumFdes++;
}
}
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=270448&r1=270447&r2=270448&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Mon May 23 11:30:41 2016
@@ -349,6 +349,8 @@ public:
void addSection(InputSectionBase<ELFT> *S) override;
+ size_t NumFdes = 0;
+
private:
template <class RelTy>
void addSectionAux(EHInputSection<ELFT> *S, llvm::ArrayRef<RelTy> Rels);
@@ -538,11 +540,9 @@ class EhFrameHeader final : public Outpu
public:
EhFrameHeader();
+ void finalize() override;
void writeTo(uint8_t *Buf) override;
-
void addFde(uint32_t Pc, uint32_t FdeVA);
- void add(EhOutputSection<ELFT> *Sec);
- void reserveFde();
private:
struct FdeData {
More information about the llvm-commits
mailing list