Commit 9097bcc06e

David Rubin <daviru007@icloud.com>
2024-01-14 23:21:30
add `SHT_NOBITS` check
1 parent f0bac80
Changed files (1)
src
src/link/Elf/SharedObject.zig
@@ -84,9 +84,11 @@ pub fn parse(self: *SharedObject, elf_file: *Elf) !void {
     try self.shdrs.ensureTotalCapacityPrecise(gpa, shdrs.len);
 
     for (shdrs, 0..) |shdr, i| {
-        if (self.data.len < shdr.sh_offset or self.data.len < shdr.sh_offset + shdr.sh_size) {
-            try elf_file.reportParseError2(self.index, "corrupted section header", .{});
-            return error.MalformedObject;
+        if (shdr.sh_type != elf.SHT_NOBITS) {
+            if (self.data.len < shdr.sh_offset or self.data.len < shdr.sh_offset + shdr.sh_size) {
+                try elf_file.reportParseError2(self.index, "corrupted section header", .{});
+                return error.MalformedObject;
+            }
         }
         self.shdrs.appendAssumeCapacity(try ElfShdr.fromElf64Shdr(shdr));
         switch (shdr.sh_type) {