• Gustavo Niemeyer's avatar
    ld: fix ELF strip by removing overlap of sections · cf143e9d
    Gustavo Niemeyer authored
    The gosymtab and gopclntab sections were pointing to the proper
    data, but that data was already owned by the rodata section.
    Some ELF references explicitly prohibit multiple sections from
    owning the same data, and strip behaves accordingly.
    
    The data for these sections was moved to after rodata, and the
    gosymtab and gopclntab sections now own their respective ranges.
    
    This change makes strip happy both with and without -s being
    provided at link time.  Note that it won't remove these sections
    because they are still allocated, and that's by design since
    they are necessary at runtime for generating proper backtraces
    and similar introspection operations.
    
    Unlike the previous behavior, -s will now maintain zero-sized
    gosymtab and gopclntab sections.  This makes the implementation
    slightly cleaner.
    
    Fixes #1242.
    
    NOTE: Tested on Linux amd64/386/arm only.
    
    R=ality, rsc
    CC=golang-dev
    https://golang.org/cl/4639077
    cf143e9d
data.c 18.8 KB