[lld] r286405 - Split OutputSection ctor. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 9 14:32:42 PST 2016
Author: ruiu
Date: Wed Nov 9 16:32:42 2016
New Revision: 286405
URL: http://llvm.org/viewvc/llvm-project?rev=286405&view=rev
Log:
Split OutputSection ctor. NFC.
Modified:
lld/trunk/ELF/OutputSections.cpp
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=286405&r1=286404&r2=286405&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Nov 9 16:32:42 2016
@@ -906,20 +906,27 @@ void EhFrameHeader<ELFT>::addFde(uint32_
Fdes.push_back({Pc, FdeVA});
}
+template <class ELFT> static uint64_t getEntsize(uint32_t Type) {
+ switch (Type) {
+ case SHT_RELA:
+ return sizeof(typename ELFT::Rela);
+ case SHT_REL:
+ return sizeof(typename ELFT::Rel);
+ case SHT_MIPS_REGINFO:
+ return sizeof(Elf_Mips_RegInfo<ELFT>);
+ case SHT_MIPS_OPTIONS:
+ return sizeof(Elf_Mips_Options<ELFT>) + sizeof(Elf_Mips_RegInfo<ELFT>);
+ case SHT_MIPS_ABIFLAGS:
+ return sizeof(Elf_Mips_ABIFlags<ELFT>);
+ default:
+ return 0;
+ }
+}
+
template <class ELFT>
OutputSection<ELFT>::OutputSection(StringRef Name, uint32_t Type, uintX_t Flags)
: OutputSectionBase<ELFT>(Name, Type, Flags) {
- if (Type == SHT_RELA)
- this->Entsize = sizeof(Elf_Rela);
- else if (Type == SHT_REL)
- this->Entsize = sizeof(Elf_Rel);
- else if (Type == SHT_MIPS_REGINFO)
- this->Entsize = sizeof(Elf_Mips_RegInfo<ELFT>);
- else if (Type == SHT_MIPS_OPTIONS)
- this->Entsize =
- sizeof(Elf_Mips_Options<ELFT>) + sizeof(Elf_Mips_RegInfo<ELFT>);
- else if (Type == SHT_MIPS_ABIFLAGS)
- this->Entsize = sizeof(Elf_Mips_ABIFlags<ELFT>);
+ this->Entsize = getEntsize<ELFT>(Type);
}
template <class ELFT> void OutputSection<ELFT>::finalize() {
More information about the llvm-commits
mailing list