-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compute base addresses from program headers while reading /proc/self/… #261
Conversation
Addressed comments from Chromium review (https://chromium-review.googlesource.com/752753). |
…maps. This cherry picks this glog change: google/glog#261 with a reimplementation of the program header reading logic for the sandboxed symbolizer. This should cause unsymbolized stack traces to contain the correct addresses for binaries linked with lld. Bug: 772559 Change-Id: Ief9cbb463b3b4c32149da893c89c2eefd76b05d4 Reviewed-on: https://chromium-review.googlesource.com/752753 Commit-Queue: Peter Collingbourne <[email protected]> Reviewed-by: Mark Mentovai <[email protected]> Cr-Commit-Position: refs/heads/master@{#513956}
…oc/self/maps." This reverts commit 6f903f3. Reason for revert: https://build.chromium.org/p/chromium.linux/builders/Android%20Clang%20Builder%20%28dbg%29/builds/104887 Original change's description: > Compute base addresses from program headers while reading /proc/self/maps. > > This cherry picks this glog change: > google/glog#261 > with a reimplementation of the program header reading logic for the > sandboxed symbolizer. > > This should cause unsymbolized stack traces to contain the correct > addresses for binaries linked with lld. > > Bug: 772559 > Change-Id: Ief9cbb463b3b4c32149da893c89c2eefd76b05d4 > Reviewed-on: https://chromium-review.googlesource.com/752753 > Commit-Queue: Peter Collingbourne <[email protected]> > Reviewed-by: Mark Mentovai <[email protected]> > Cr-Commit-Position: refs/heads/master@{#513956} [email protected],[email protected],[email protected] Change-Id: Ie02672bcfb2d28729530d61975083ba2187efd4e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 772559 Reviewed-on: https://chromium-review.googlesource.com/753864 Reviewed-by: Sky Malice <[email protected]> Commit-Queue: Sky Malice <[email protected]> Cr-Commit-Position: refs/heads/master@{#513978}
…oc/self/maps." This is a reland of 6f903f3 Fixed Android build issue. Original change's description: > Compute base addresses from program headers while reading /proc/self/maps. > > This cherry picks this glog change: > google/glog#261 > with a reimplementation of the program header reading logic for the > sandboxed symbolizer. > > This should cause unsymbolized stack traces to contain the correct > addresses for binaries linked with lld. > > Bug: 772559 > Change-Id: Ief9cbb463b3b4c32149da893c89c2eefd76b05d4 > Reviewed-on: https://chromium-review.googlesource.com/752753 > Commit-Queue: Peter Collingbourne <[email protected]> > Reviewed-by: Mark Mentovai <[email protected]> > Cr-Commit-Position: refs/heads/master@{#513956} Bug: 772559 Change-Id: Id6a8c62c0b05a7d12f817e389c7b96223fec8073 Reviewed-on: https://chromium-review.googlesource.com/754232 Reviewed-by: Mark Mentovai <[email protected]> Commit-Queue: Peter Collingbourne <[email protected]> Cr-Commit-Position: refs/heads/master@{#514018}
could we have test for this? I tried CC=/path/to/clang CXX=/path/to/clang++ ./configure && make && make check-TESTS |
src/symbolize.cc
Outdated
ElfW(Ehdr) ehdr; | ||
if (flags_start[0] == 'r' && | ||
ReadFromOffsetExact(mem_fd, &ehdr, sizeof(ElfW(Ehdr)), start_address) && | ||
memcmp(ehdr.e_ident, ELFMAG, SELFMAG) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment for this? I think this is skipping non-text maps for usual cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in fact skipping non-readable maps. I've added a comment.
This PR and https://chromium-review.googlesource.com/c/chromium/src/+/752753 look great to me. I hope no project except Chromium is using InstallSymbolizeCallback. Quick google search seems to suggest there's no other code which uses InstallSymbolizeCallback. However, in case there're hidden users of this APIs, could you clearly mention this changes the semantics of InstallSymbolizeCallback? I'd like to send the message to glog's list after we merge this PR. |
…maps. We previously had logic to compute the base address from program headers as part of symbolization. The problem is that we need a correct base address earlier in order to adjust a PC into the image's address space, as these addresses can appear in unsymbolized output. There was previously an assumption that only the mapping that was lowest in the address space did not need to be adjusted. This assumption is not guaranteed (for example, the kernel may choose to map an ET_DYN lowest) and in fact turned out to be wrong in binaries linked with lld because the first mapping is read-only. The solution is to move the program header reading logic into the code that reads /proc/self/maps. There is a change in semantics for clients that install a callback using the InstallSymbolizeOpenObjectFileCallback function. Any such clients will need to return a correct base address from the callback by reading program headers using code similar to that in the function OpenObjectFileContainingPcAndGetStartAddress.
Done. The test makes sure that PIEs mapped at low addresses can be symbolized correctly.
I've added a note to the commit message. |
Thanks! |
…maps. This cherry picks this glog change: google/glog#261 with a reimplementation of the program header reading logic for the sandboxed symbolizer. This should cause unsymbolized stack traces to contain the correct addresses for binaries linked with lld. Bug: 772559 Change-Id: Ief9cbb463b3b4c32149da893c89c2eefd76b05d4 Reviewed-on: https://chromium-review.googlesource.com/752753 Commit-Queue: Peter Collingbourne <[email protected]> Reviewed-by: Mark Mentovai <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#513956} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 6f903f3a228bc8e10cd7bda76342954feb3000c5
…oc/self/maps." This reverts commit 6f903f3a228bc8e10cd7bda76342954feb3000c5. Reason for revert: https://build.chromium.org/p/chromium.linux/builders/Android%20Clang%20Builder%20%28dbg%29/builds/104887 Original change's description: > Compute base addresses from program headers while reading /proc/self/maps. > > This cherry picks this glog change: > google/glog#261 > with a reimplementation of the program header reading logic for the > sandboxed symbolizer. > > This should cause unsymbolized stack traces to contain the correct > addresses for binaries linked with lld. > > Bug: 772559 > Change-Id: Ief9cbb463b3b4c32149da893c89c2eefd76b05d4 > Reviewed-on: https://chromium-review.googlesource.com/752753 > Commit-Queue: Peter Collingbourne <[email protected]> > Reviewed-by: Mark Mentovai <[email protected]> > Cr-Commit-Position: refs/heads/master@{#513956} [email protected],[email protected],[email protected] Change-Id: Ie02672bcfb2d28729530d61975083ba2187efd4e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 772559 Reviewed-on: https://chromium-review.googlesource.com/753864 Reviewed-by: Sky Malice <[email protected]> Commit-Queue: Sky Malice <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#513978} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 65c533858f1d0c507e91b34f64fce93f5d1cf595
…oc/self/maps." This is a reland of 6f903f3a228bc8e10cd7bda76342954feb3000c5 Fixed Android build issue. Original change's description: > Compute base addresses from program headers while reading /proc/self/maps. > > This cherry picks this glog change: > google/glog#261 > with a reimplementation of the program header reading logic for the > sandboxed symbolizer. > > This should cause unsymbolized stack traces to contain the correct > addresses for binaries linked with lld. > > Bug: 772559 > Change-Id: Ief9cbb463b3b4c32149da893c89c2eefd76b05d4 > Reviewed-on: https://chromium-review.googlesource.com/752753 > Commit-Queue: Peter Collingbourne <[email protected]> > Reviewed-by: Mark Mentovai <[email protected]> > Cr-Commit-Position: refs/heads/master@{#513956} Bug: 772559 Change-Id: Id6a8c62c0b05a7d12f817e389c7b96223fec8073 Reviewed-on: https://chromium-review.googlesource.com/754232 Reviewed-by: Mark Mentovai <[email protected]> Commit-Queue: Peter Collingbourne <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#514018} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 1a3ed318cbbe2b53d9d6410a376e75439b9e6007
Compute base addresses from program headers while reading /proc/self/maps.
…maps.
We previously had logic to compute the base address from program
headers as part of symbolization. The problem is that we need a correct
base address earlier in order to adjust a PC into the image's address
space, as these addresses can appear in unsymbolized output.
There was previously an assumption that only the mapping that
was lowest in the address space did not need to be adjusted. This
assumption is not guaranteed (for example, the kernel may choose to
map an ET_DYN lowest) and in fact turned out to be wrong in binaries
linked with lld because the first mapping is read-only.
The solution is to move the program header reading logic into the
code that reads /proc/self/maps.