[Lldb-commits] [PATCH] D87868: [RFC] When calling the process mmap try to call all found instead of just the first one

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 30 07:13:54 PDT 2020

labath added a comment.

A completely different approach would be to avoid the mmap function completely, and go for the mmap syscall instead.

That is, instead of setting up registers to fake call to mmap and doing a run-to entry point breakpoint, we could set them up to fake a syscall, and then do an instruction-step over a syscall instruction (which we could place at the entry point, or find a suitable one in the binary).

The advantage of that would be that this would work not only in this (sanitizer) case, but also in all other cases where an mmap symbol is not present/functional/unambiguous:

- a bare-bone statically linked binary need not contain an mmap function
- very early in the program startup (before relocations are applied) it may not be safe to call the global mmap
- mmap may be buggy (libc debugging?)

Note that this would not need to be implemented in the lldb client. This sort of thing would be natural to implement in lldb server in response to the `_M` packet. There it would be easy to encode the abi details needed to issue a syscall. The client already prefers this packet, and the existing code could remain as a fallback for platforms not implementing it.

  rG LLVM Github Monorepo



More information about the lldb-commits mailing list