[PATCH] D24987: [ELF] Use MaxPageSize for aligning PT_LOAD

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 4 13:06:22 PDT 2016


On 4 November 2016 at 15:53, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
> On 2 November 2016 at 17:17, Ed Maste <emaste at freebsd.org> wrote:
>> emaste added a comment.
>>
>> This change broke linking the FreeBSD kernel with lld, which relies on MAXPAGESIZE to set the kernel's phys addr. See https://svnweb.freebsd.org/base/head/sys/conf/ldscript.amd64?revision=303442&view=markup#l9
>
>
> Sorry, but looking at it in not clear why it requires the max page to
> be 0x200000. It should work with other values too, no?

>From your reply in the other thread I am guessing that the problem is

* The kernel needs some memory available at the low address.
* If the kernel is loaded at 4k, there is only 4k available and that
is not enough.

If that is the case, it seems the correct fix is to just replace

kernphys = CONSTANT (MAXPAGESIZE);

with

kernphys = 0x200000;

or some other constant. You mentioned 640 kb, so maybe 0xa0000 would work too.

The annoyance of using a 2MB page is that it pretty much requires that
the pages be overlapped an disk, otherwise the minimal executable is 6
MB. The overlap then means that some data will be mapped as
executable.

Cheers,
Rafael


More information about the llvm-commits mailing list