* [qemu-riscv] Error mapping file: Invalid argument
@ 2025-03-10 14:52 Chu, Benson
2025-03-10 15:55 ` Peter Maydell
0 siblings, 1 reply; 2+ messages in thread
From: Chu, Benson @ 2025-03-10 14:52 UTC (permalink / raw)
To: qemu-devel@nongnu.org
[-- Attachment #1: Type: text/plain, Size: 714 bytes --]
Hello all,
I am working on a linker for the RISC-V target, and I was trying to use qemu-riscv32 to test my linker.
However, I have noticed that qemu-riscv32 has some restrictions about how the program can be laid out in memory, and getting my linker to place the program in a way that qemu-riscv32 will accept is very annoying.
By my understanding, for each segment to be loaded, offset into the ELF file must match the offset into a target page, which seems to be 4KiB.
I noticed that GNU ld and LLVM's lld both follow this placement by default. Is there some ABI that's being conformed to for this? Is there any documentation describing why placement needs to be done this way?
Thanks!
Benson
[-- Attachment #2: Type: text/html, Size: 2845 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [qemu-riscv] Error mapping file: Invalid argument
2025-03-10 14:52 [qemu-riscv] Error mapping file: Invalid argument Chu, Benson
@ 2025-03-10 15:55 ` Peter Maydell
0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2025-03-10 15:55 UTC (permalink / raw)
To: Chu, Benson; +Cc: qemu-devel@nongnu.org
On Mon, 10 Mar 2025 at 15:27, Chu, Benson <b-chu1@ti.com> wrote:
> I am working on a linker for the RISC-V target, and I was trying
> to use qemu-riscv32 to test my linker.
> However, I have noticed that qemu-riscv32 has some restrictions
> about how the program can be laid out in memory, and getting my
> linker to place the program in a way that qemu-riscv32 will
> accept is very annoying.
>
> By my understanding, for each segment to be loaded, offset into
> the ELF file must match the offset into a target page, which
> seems to be 4KiB.
>
> I noticed that GNU ld and LLVM’s lld both follow this placement
> by default. Is there some ABI that’s being conformed to for this?
> Is there any documentation describing why placement needs to be
> done this way?
I think that is part of the standard SysV ELF ABI, usually
described as the p_offset and p_vaddr having to be
"congruent modulo the page size". The underlying reason is
that you want to be able to mmap() the pages of the executable
file directly into RAM and have them be at the right alignment
and offset.
thanks
-- PMM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-10 15:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 14:52 [qemu-riscv] Error mapping file: Invalid argument Chu, Benson
2025-03-10 15:55 ` Peter Maydell
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).