[llvm] 91e2cd4 - [llvm-objcopy] Remove getDecompressedSizeAndAlignment. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 25 00:06:41 PDT 2022
Author: Fangrui Song
Date: 2022-07-25T00:06:36-07:00
New Revision: 91e2cd4fa90b13f0327615b76bd0d027a6c39a65
URL: https://github.com/llvm/llvm-project/commit/91e2cd4fa90b13f0327615b76bd0d027a6c39a65
DIFF: https://github.com/llvm/llvm-project/commit/91e2cd4fa90b13f0327615b76bd0d027a6c39a65.diff
LOG: [llvm-objcopy] Remove getDecompressedSizeAndAlignment. NFC
Added:
Modified:
llvm/lib/ObjCopy/ELF/ELFObject.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
index 9f7408cad3e7..b127e1b43b8e 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -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 =
@@ -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));
}
}
}
More information about the llvm-commits
mailing list