[llvm] [LLVM] Add zstd and zlib compressed frame magic to LLVM magic (PR #222773)

Yaxun Liu via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 11:05:28 PDT 2026


================
@@ -270,6 +270,21 @@ file_magic llvm::identify_magic(StringRef Magic) {
       return file_magic::coff_object;
     break;
 
+  case 0x28: // Zstandard compressed frame magic 0xFD2FB528, little-endian.
+    if (startswith(Magic, "\x28\xb5\x2f\xfd"))
+      return file_magic::zstd;
+    break;
+
+  case 0x78: {
----------------
yxsamliu wrote:

Could we recognize all valid zlib headers here? The current check only accepts the `0x78` headers emitted by LLVM, so valid streams with a smaller window or a preset dictionary are reported as unknown. We could check `CM == 8`, `CINFO <= 7`, and FCHECK instead.

https://github.com/llvm/llvm-project/pull/222773


More information about the llvm-commits mailing list