| ... | @@ -367,10 +367,12 @@ fn detectAllocCollision(self: *Elf, start: u64, size: u64) ?u64 { | ... | @@ -367,10 +367,12 @@ fn detectAllocCollision(self: *Elf, start: u64, size: u64) ?u64 { |
| 367 | } | 367 | } |
| 368 | } | 368 | } |
| 369 | | 369 | |
| 370 | for (self.shdrs.items) |section| { | 370 | for (self.shdrs.items) |shdr| { |
| 371 | const increased_size = padToIdeal(section.sh_size); | 371 | // SHT_NOBITS takes no physical space in the output file so set its size to 0. |
| 372 | const test_end = section.sh_offset + increased_size; | 372 | const sh_size = if (shdr.sh_type == elf.SHT_NOBITS) 0 else shdr.sh_size; |
| 373 | if (end > section.sh_offset and start < test_end) { | 373 | const increased_size = padToIdeal(sh_size); |
| | 374 | const test_end = shdr.sh_offset + increased_size; |
| | 375 | if (end > shdr.sh_offset and start < test_end) { |
| 374 | return test_end; | 376 | return test_end; |
| 375 | } | 377 | } |
| 376 | } | 378 | } |