• Peter Collingbourne's avatar
    Compute base addresses from program headers while reading /proc/self/maps. · c4d37a78
    Peter Collingbourne authored
    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.
    c4d37a78
symbolize.cc 30.9 KB