This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gold-linked dragonfly kernel unbootable, likely due to segment page size, alignment


John Marino <binutils@marino.st> writes:

> I have spent a few hours tweaking linker scripts to attempt to link a
> DragonFly BSD kernel that boots, but so far in vain.
>
> I have attached readelf output for kernels built with gnu ld and gold
> to list the program headers, along with the version of the linker
> script I've been using.
>
> This is the x86_64 platform, so the LOAD segment alignment of 0x200000
> is what we want, but gold stubbornly uses 0x1000 over 3 segments
> versus the desired 0x200000 over 2 segments.
>
> I have:
> 1) Tried building gold with a max-page-size of 0x200000 hardcoded in
> x86_64.cc
> 2) Tried -z max-page-size=0x200000
> 3) Tried setting DATA_SEGMENT_ALIGN (0x200000, 0x200000) in the linker
> script
>
> So far nothing has made any difference at all.  At first glance, it
> appears the linkers interpret differently what the minimum page size
> should be.
>
> The other information which may be important is that the first LOAD
> segment of the gold-built kernel has flags of "R" whereas the ld-built
> first LOAD segment has flags of "R E".
>
> I'm pretty sure the only reason the gold-linked kernel won't load is
> due to size and alignment of the LOAD SEGMENTS.  What setting can be
> used to force gold to create two 0x200000 segments like ld does?

I doubt the p_align field of the LOAD segments is relevant here.  I
suspect your problem is that gold is generating an additional LOAD
segment to hold the headers, while GNU ld is not.  That's the first LOAD
segment that gold is generating--the only thing in it is the headers.

It's quite tricky to figure out what to do with the headers when using a
linker script which only describes sections.  It looks like gold and GNU
ld disagree in this case.  I've tweaked gold's behaviour in this area
quite a bit over the years.  I'm not sure what to recommend.  You could
always try linking with -n unless there is some reason not to.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]