linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] Fix binfmt_flat loader for RISC-V
@ 2021-04-17  1:10 Damien Le Moal
  2021-04-17  1:10 ` [PATCH v4 1/2] binfmt_flat: allow not offsetting data start Damien Le Moal
  2021-04-17  1:10 ` [PATCH v4 2/2] riscv: Disable data start offset in flat binaries Damien Le Moal
  0 siblings, 2 replies; 11+ messages in thread
From: Damien Le Moal @ 2021-04-17  1:10 UTC (permalink / raw)
  To: uclinux-dev, Greg Ungerer, Palmer Dabbelt, linux-riscv
  Cc: linux-kernel, Anup Patel, Christoph Hellwig

RISC-V NOMMU flat binaries cannot tolerate a gap between the text and
data section as the toolchain fully resolves at compile time the PC
relative global pointer (__global_pointer$ value loaded in the gp
register). Without a relocation entry provided, the flat bin loader
cannot fix the value if a gap is introduced and user executables fail
to run.

This series fixes this problem by allowing an architecture to request
the flat loader to suppress the offset of the data start section.
Combined with the use of elf2flt "-r" option to mark the flat
executables with the FLAT_FLAG_RAM flag, the text and data sections are
loaded contiguously in memory, without a change in their relative
position from compile time.

The first patch fixes binfmt_flat flat_load_file() using the new
configuration option CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET. The
second patch enables this new option for RISCV NOMMU builds.

These patches do not change the binfmt_flat loader behavior for other
architectures.

Changes from v3:
* Renamed the configuration option from
  CONFIG_BINFMT_FLAT_NO_TEXT_DATA_GAP to
  CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET to clarify that only the
  offseting of the data section start is suppressed.
* Do not force loding to RAM (contiguously) if the flat binary does not
  have the FLAT_FLAG_RAM flag set.
* Updated commit messages to reflect above changes.

Changes from v2:
* Updated distribution list
* Added Palmer ack-by tag

Changes from v1:
* Replace FLAT_TEXT_DATA_NO_GAP macro with
  CONFIG_BINFMT_FLAT_NO_TEXT_DATA_GAP config option (patch 1).
* Remove the addition of riscv/include/asm/flat.h and set
  CONFIG_BINFMT_FLAT_NO_TEXT_DATA_GAP for RISCV and !MMU

Damien Le Moal (2):
  binfmt_flat: allow not offsetting data start
  riscv: Disable data start offset in flat binaries

 arch/riscv/Kconfig |  1 +
 fs/Kconfig.binfmt  |  3 +++
 fs/binfmt_flat.c   | 19 ++++++++++++++-----
 3 files changed, 18 insertions(+), 5 deletions(-)

-- 
2.30.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-04-23  6:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-17  1:10 [PATCH v4 0/2] Fix binfmt_flat loader for RISC-V Damien Le Moal
2021-04-17  1:10 ` [PATCH v4 1/2] binfmt_flat: allow not offsetting data start Damien Le Moal
2021-04-17  4:52   ` Greg Ungerer
2021-04-17  4:54     ` Damien Le Moal
2021-04-18  2:38       ` Greg Ungerer
2021-04-22 12:00         ` Damien Le Moal
2021-04-23  4:04           ` Palmer Dabbelt
2021-04-23  5:38             ` Greg Ungerer
2021-04-23  6:44               ` Palmer Dabbelt
2021-04-17  1:10 ` [PATCH v4 2/2] riscv: Disable data start offset in flat binaries Damien Le Moal
2021-04-17  4:56   ` Greg Ungerer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).