Compute base addresses from program headers while reading /proc/self/maps.
authorPeter Collingbourne <pcc@google.com>
Thu, 2 Nov 2017 23:53:21 +0000 (16:53 -0700)
committerPeter Collingbourne <pcc@google.com>
Wed, 8 Nov 2017 22:15:02 +0000 (14:15 -0800)
commitc4d37a78cc8aeeb68ae09d37152114fac24c0cea
treed4f00fac3db75a0fda16db13eb56c85d218ee0b4
parentd72e3be82c832601e1d8f6fba580d2edf8be13da
Compute base addresses from program headers while reading /proc/self/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.
Makefile.am
src/symbolize.cc