[llvm] Fix compression header size check in ELF writer (PR #66888)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 03:45:08 PDT 2023


https://github.com/myxoid created https://github.com/llvm/llvm-project/pull/66888

The test had 32-bit and 64-bit header sizes the wrong way around.

>From adcdce901648b2f645675e0de6b8f95b2e2d2c6f Mon Sep 17 00:00:00 2001
From: Giuliano Procida <gprocida at google.com>
Date: Wed, 20 Sep 2023 11:18:01 +0100
Subject: [PATCH] Fix compression header size check in ELF writer

The test had 32-bit and 64-bit header sizes the wrong way around.
---
 llvm/lib/MC/ELFObjectWriter.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 816aa21321095df..cd2634910e9a1de 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -842,7 +842,7 @@ bool ELFWriter::maybeWriteCompression(
     uint32_t ChType, uint64_t Size,
     SmallVectorImpl<uint8_t> &CompressedContents, Align Alignment) {
   uint64_t HdrSize =
-      is64Bit() ? sizeof(ELF::Elf32_Chdr) : sizeof(ELF::Elf64_Chdr);
+      is64Bit() ? sizeof(ELF::Elf64_Chdr) : sizeof(ELF::Elf32_Chdr);
   if (Size <= HdrSize + CompressedContents.size())
     return false;
   // Platform specific header is followed by compressed data.



More information about the llvm-commits mailing list