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

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 6 16:03:35 PST 2016


On Sun, Nov 6, 2016 at 3:44 PM, Ed Maste via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> On 4 November 2016 at 21:08, Rafael EspĂ­ndola
> <rafael.espindola at gmail.com> wrote:
>>
>> I think so. The full picture is that bfd has two page sizes,
>> COMMONPAGESIZE and MAXPAGESIZE. MAXPAGESIZE is used almost everywhere.
>> To avoid ending up with a 4 MB binary, the pages overlap on disk. For
>> example, with a trivial binary with just a .quad of data and text I
>> get
>>
>>   LOAD           0x000000 0x0000000000000000 0x0000000000000000
>> 0x0001e8 0x0001e8 R E 0x200000
>>   LOAD           0x000f50 0x0000000000200f50 0x0000000000200f50
>> 0x0000b8 0x0000b8 RW  0x200000
>>
>> So at runtime the will be two mappings, one at base and one at base +
>> 0x200000, but they will point to offset 0 of the file.
>>
>> The COMMONPAGESIZE is only used by DATA_SEGMENT_ALIGN. It is the
>> actual page size that is expected at runtime and the logic in
>> DATA_SEGMENT_ALIGN is to try to save a page in memory by wasting one
>> on disk.
>
> OK. Do you know what gold does?
>

I don't exactly remember what gold does, but I want to point out that
last time Michael and I tried to link the FreeBSD kernel with gold,
gold produced a broken binary (i.e. the kernel crashed).

-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare


More information about the llvm-commits mailing list