[Lldb-commits] [PATCH] D144528: [lldb] Warn when Mach-O files have overlapping segments

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 22 13:17:30 PST 2023


bulbazord added a comment.

In D144528#4145593 <https://reviews.llvm.org/D144528#4145593>, @jasonmolenda wrote:

> I'm OK with giving this a try.  SectionLoadList::SetSectionLoadAddress specifically notes that there are cases were sections overlap in the virtual address space.  All of the binaries in the shared cache have a single LINKEDIT segment that is shared, and each binary's mach-o `LC_SYMTAB`/`LC_DYSYMTAB` load command will point to different part of that same LINKEDIT.  From lldb's perspective, that means every Module in the shared cache has a LINKEDIT Section that overlaps with all the others.
>
> LINKEDIT is special in that nothing in TEXT/DATA refers to anything in it.  The dynamic linker (ld.so, dyld) needs to process it on userland processes, and the debugger needs to read it to create a symbol table, but it basically doesn't need to be loaded in memory at all until you make a call to an external binary and the dynamic linker needs to do something.  With the Darwin kernel (xnu), it's not loaded in memory at all, it only exists in the original binary file that is processed into the in-memory kernel image.
>
> tl;dr it's fine if LINKEDIT's "overlap" because lldb will never need to take an addr_t and figure out which Section it is located in.  (because an addr_t in the LINKEDIT segment of the shared cache would point to EVERY ObjectFile in the shared cache, if it was all reported correctly.)
>
> We may find that enabling this warning fires for some unintended situation that we're not looking at right now, but we can re-evaluate if that turns out to be the case.

Out of curiosity, is the scenario you're describing not already handled by `DynamicLoaderDarwin::UpdateImageLoadAddress`? That method specifically checks to see if a section is `__LINKEDIT` to figure out if we should be emitting a warning. Should I be doing the same thing here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144528/new/

https://reviews.llvm.org/D144528



More information about the lldb-commits mailing list