binfmt_flat: allow not offsetting data start
authorDamien Le Moal <damien.lemoal@wdc.com>
Sat, 17 Apr 2021 01:10:08 +0000 (10:10 +0900)
committerGreg Ungerer <gerg@linux-m68k.org>
Sun, 18 Apr 2021 23:56:37 +0000 (09:56 +1000)
commit04d82a6d0881ef1ab1e9f66f10805177ee2fb1e8
tree24c5ead3c1bb507a8682a01b98a278eb95108adb
parentbf05bf16c76bb44ab5156223e1e58e26dfe30a88
binfmt_flat: allow not offsetting data start

Commit 2217b9826246 ("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: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
fs/Kconfig.binfmt
fs/binfmt_flat.c