Skip to content

Commit

Permalink
[llvm-objcopy] Remove getDecompressedSizeAndAlignment. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Jul 25, 2022
1 parent a053f35 commit 91e2cd4
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions llvm/lib/ObjCopy/ELF/ELFObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,17 +434,6 @@ Error SectionWriter::visit(const OwnedDataSection &Sec) {
return Error::success();
}

template <class ELFT>
static std::tuple<uint64_t, uint64_t>
getDecompressedSizeAndAlignment(ArrayRef<uint8_t> Data) {
const uint64_t DecompressedSize =
reinterpret_cast<const Elf_Chdr_Impl<ELFT> *>(Data.data())->ch_size;
const uint64_t DecompressedAlign =
reinterpret_cast<const Elf_Chdr_Impl<ELFT> *>(Data.data())->ch_addralign;

return std::make_tuple(DecompressedSize, DecompressedAlign);
}

template <class ELFT>
Error ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) {
ArrayRef<uint8_t> Compressed =
Expand Down Expand Up @@ -1714,15 +1703,11 @@ Expected<SectionBase &> ELFBuilder<ELFT>::makeSection(const Elf_Shdr &Shdr) {
if (!Name)
return Name.takeError();

if (Shdr.sh_flags & ELF::SHF_COMPRESSED) {
uint64_t DecompressedSize, DecompressedAlign;
std::tie(DecompressedSize, DecompressedAlign) =
getDecompressedSizeAndAlignment<ELFT>(*Data);
return Obj.addSection<CompressedSection>(
CompressedSection(*Data, DecompressedSize, DecompressedAlign));
}

return Obj.addSection<Section>(*Data);
if (!(Shdr.sh_flags & ELF::SHF_COMPRESSED))
return Obj.addSection<Section>(*Data);
auto *Chdr = reinterpret_cast<const Elf_Chdr_Impl<ELFT> *>(Data->data());
return Obj.addSection<CompressedSection>(
CompressedSection(*Data, Chdr->ch_size, Chdr->ch_addralign));
}
}
}
Expand Down

0 comments on commit 91e2cd4

Please sign in to comment.