qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] hw/core/loader: do not check for regions overla


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] hw/core/loader: do not check for regions overlap
Date: Sun, 23 Jul 2017 23:22:45 +0100

On 23 July 2017 at 23:11, Hua Yanghao <address@hidden> wrote:
>> Suppose we have these two segments:
>>  SEGMENT 1: start 0x1000, end 0x2fff, data all 0xff
>>  SEGMENT 2: start 0x2000, end 0x3fff, data all 0x00
>>
>> Clearly for the memory 0x1000..0x1fff we want the 0xff
>> data, and for 0x3000..0x3fff we want 0x00.
>> But for the memory 0x2000..0x2fff which is in
>> both segment 1 and segment 2, should QEMU load
>> 0xff or 0x00 bytes ?
>>
>> We shouldn't pick randomly or just do whatever our
>> implementation "happens to do" -- we need to look
>> at what the ELF spec says must happen and do that.
> I don't see how linker could allow that to happen.
> If two section overlaps one of them should be of NOLOAD type.
> Otherwise linker complains the overlapping of LMA.

I have seen ELF files which have this overlap and
where both segments are PT_LOAD. (I think in the cases
I've seen the contents in both segments agree rather than
being different data, but a loader is not going to be
expected to do a comparison of the file data.)

> So for me just ignore NOLOAD section would do the trick.

We already ignore all the ELF segments which are not
of type PT_LOAD:
http://git.qemu.org/?p=qemu.git;a=blob;f=include/hw/elf_ops.h;h=a172a6068a48e233dd802043b3304a9e0a5d3be6;hb=HEAD#l353

If you're hitting this error case then I think the
affected segments must both be of type PT_LOAD.
(If you're not sure you can post here the output
of running 'objdump -p' on the binary or otherwise
show us the program header.)

PS: you're consistently saying "section", but in the
ELF format "section" and "segment" are two different
things. QEMU doesn't actually look at the section table.
In an ELF file, sections are used by the linker, but a
program loader like QEMU (or the Linux kernel)
looks only at the segment table in the program header.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]