[llvm] Support decompressing the SHT_LLVM_BB_ADDR_MAP section. (PR #142825)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 4 12:27:10 PDT 2025
================
@@ -782,6 +783,26 @@ decodeBBAddrMapImpl(const ELFFile<ELFT> &EF,
if (!ContentsOrErr)
return ContentsOrErr.takeError();
ArrayRef<uint8_t> Content = *ContentsOrErr;
+
+ // Decompress the section if needed.
+ std::unique_ptr<uint8_t[]> DecompressedContent;
+ if (Sec.sh_flags & llvm::ELF::SHF_COMPRESSED) {
+ Expected<StringRef> SectionNameOrErr = EF.getSectionName(Sec);
+ if (!SectionNameOrErr)
+ return SectionNameOrErr.takeError();
+ auto DecompressorOrErr =
+ Decompressor::create(*SectionNameOrErr, toStringRef(*ContentsOrErr),
+ EF.isLE(), ELFT::Is64Bits);
+ if (!DecompressorOrErr)
+ return DecompressorOrErr.takeError();
+ size_t DecompressedSize = DecompressorOrErr->getDecompressedSize();
+ DecompressedContent = std::make_unique<uint8_t[]>(DecompressedSize);
+ if (Error Err = DecompressorOrErr->decompress(
+ {DecompressedContent.get(), size_t(DecompressedSize)}))
----------------
boomanaiden154 wrote:
The `size_t` cast seems unnecessary here given `DecompressedSize` is already `size_t`?
https://github.com/llvm/llvm-project/pull/142825
More information about the llvm-commits
mailing list