This is the mail archive of the 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

On 2/21/2012 04:39, Ian Lance Taylor wrote:

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.


For sure the additional LOAD segment is causing a (or the) problem. When DragonFly moved to binutils 2.20 up from 2.17, a third LOAD segment appeared on x86_64 rendering the kernel unbootable. In that case, it was related to the starting address changing from 0x100000 to 0x200000 on x86_64 and updating that resulted in only two LOAD segments again.

With gold, we're getting three LOAD segments in both i386 and x86_64.

A gold-linked boot loader also fails, and it's linked with the -N option, but I haven't looked at the cause of that failure. It may or may not be the same issue. These are the only two things (the boot loader and the kernel) that seem to fail as a result of being linked with gold.

Anyway, something must have changed in header handling between gold from binutils 2.21 and binutils 2.22 with regards to headers, because a kernel and boot loader linked with gold from 2.21 did boot and function.

So this header handling behavior is hard-coded into gold? There's no switch, no script option, no build default that could be used/changed to get the header handling to match what gnu ld is doing? I'm a little nervous about turning off page alignment at this time.

Also I'm curious why gold is defaulting to 0x1000 page alignment on x86_64 when the same script on gnu ld results in alignment at 0x200000.
(i386 has alignment of 0x1000 on both linkers though)


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