• Masahiro Yamada's avatar
    modpost: use more reliable way to get fromsec in section_rel(a)() · 5419aa2a
    Masahiro Yamada authored
    The section name of Rel and Rela starts with ".rel" and ".rela"
    respectively (but, I do not know whether this is specification or
    convention).
    
    For example, ".rela.text" holds relocation entries applied to the
    ".text" section.
    
    So, the code chops the ".rel" or ".rela" prefix to get the name of
    the section to which the relocation applies.
    
    However, I do not like to skip 4 or 5 bytes blindly because it is
    potential memory overrun.
    
    The ELF specification provides a more reliable way to do this.
    
     - The sh_info field holds extra information, whose interpretation
       depends on the section type
    
     - If the section type is SHT_REL or SHT_RELA, the sh_info field holds
       the section header index of the section to which the relocation
       applies.
    Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
    5419aa2a
modpost.c 66.6 KB