• Damien Le Moal's avatar
    binfmt_flat: allow not offsetting data start · 04d82a6d
    Damien Le Moal authored
    Commit 2217b982 ("binfmt_flat: revert "binfmt_flat: don't offset
    the data start"") restored offsetting the start of the data section by
    a number of words defined by MAX_SHARED_LIBS. As a result, since
    MAX_SHARED_LIBS is never 0, a gap between the text and data sections
    always exists. For architectures which cannot support a such gap
    between the text and data sections (e.g. riscv nommu), flat binary
    programs cannot be executed.
    
    To allow an architecture to request no data start offset to allow for
    contiguous text and data sections for binaries flagged with
    FLAT_FLAG_RAM, introduce the new config option
    CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET. Using this new option, the
    macro DATA_START_OFFSET_WORDS is conditionally defined in binfmt_flat.c
    to MAX_SHARED_LIBS for architectures tolerating or needing the data
    start offset (CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET disabled case)
    and to 0 when CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET is enabled.
    DATA_START_OFFSET_WORDS is used in load_flat_file() to calculate the
    data section length and start position.
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
    Signed-off-by: default avatarGreg Ungerer <gerg@linux-m68k.org>
    04d82a6d
binfmt_flat.c 28.5 KB