[llvm] MachOObjectFile: Don't limit `getSectionSize` to object's file size (PR #197286)

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 11:56:13 PDT 2026


JDevlieghere wrote:

Ok, I think I finally understand the problem you're trying to solve: a .dSYM deliberately keeps section metadata while dropping much of the section content, so its file is smaller than the sections it describes. And the problem you're trying to solve is that currently we conflate "how big is the section" with "how many bites are in it". I'm supportive of fixing that of course.

My remaining concern is that this now removes the check that the original change was defending against. The parse-time "section extends past the end of the file" check you're relying on is explicitly skipped for MH_DSYM and MH_DYLIB_STUB. After this change getSize() returns that raw size, while getContents() still clamps via substr, and various callers rely on getSize while going through the getContents buffer. 

So what I'd like to see is (1) a test that exercises this (i.e. a crash or trips up with Asan) and (2) a fix for that.

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


More information about the llvm-commits mailing list