Created attachment 5857 [details] output of "readelf -lSW ./vmlinux" When I try to build the latest kernel git tree with gold I get this error: ld -m elf_x86_64 --build-id -o vmlinux -T arch/x86/kernel/vmlinux.lds arch/x86/kernel/head_64.o arch/x86/kernel/head64.o arch/x86/kernel/head.o arch/x86/kernel/init_task.o init/built-in.o --start-group usr/built-in.o arch/x86/built-in.o kernel/built-in.o mm/built-in.o fs/built-in.o ipc/built-in.o security/built-in.o crypto/built-in.o block/built-in.o lib/lib.a arch/x86/lib/lib.a lib/built-in.o arch/x86/lib/built-in.o drivers/built-in.o sound/built-in.o firmware/built-in.o arch/x86/pci/built-in.o arch/x86/video/built-in.o net/built-in.o --end-group .tmp_kallsyms2.o ld: error: dot may not move backward ld: error: dot may not move backward ld: error: load segment overlap [0x1800000 -> 0x18940e0] and [0x1893000 -> 0x1893c10] ld.bfd links without any problems. The output of "readelf -lSW ./vmlinux" is attached. Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x200000 0xffffffff81000000 0x0000000001000000 0x7d1000 0x7d1000 R E 0x200000 LOAD 0xa00000 0xffffffff81800000 0x0000000001800000 0x0940e0 0x0940e0 RW 0x200000 LOAD 0xc00000 0xffffffffff600000 0x0000000001893000 0x001000 0x001000 R E 0x200000 LOAD 0xe00000 0x0000000000000000 0x0000000001895000 0x012500 0x012500 RW 0x200000 LOAD 0xea8000 0xffffffff818a8000 0x00000000018a8000 0x085000 0x152000 RWE 0x200000 NOTE 0x71bb34 0xffffffff8151bb34 0x000000000151bb34 0x000024 0x000024 0x4
(I'm the author of the kernel patch that triggered this.) It looks like two phdrs do indeed overlap. The fix to the linker script is trivial. The errors "ld: error: dot may not move backward" are still there, though. It would be nice if gold (or ld.bfd, for that matter) would give some context for the error...
What is the change to the linker script that causes this to happen?
(In reply to comment #2) > What is the change to the linker script that causes this to happen? http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9fd67b4ed0714ab718f1f9bd14c344af336a6df7 The segment overlap error is correct and I'll fix it in the linker script. The dot error looks like a bug. This construct in SECTIONS is the problem, I think: .vsyscall { *(.vsyscall_0) . = 1024; *(.vsyscall_1) } AFAICT the bfd linker thinks that assignments to . inside a section are section-relative but gold thinks they're absolute. The documentation reference is escaping me at the moment.
(In reply to comment #3) > (In reply to comment #2) > > What is the change to the linker script that causes this to happen? > > http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9fd67b4ed0714ab718f1f9bd14c344af336a6df7 > > The segment overlap error is correct and I'll fix it in the linker script. The > dot error looks like a bug. > > This construct in SECTIONS is the problem, I think: > > .vsyscall { > *(.vsyscall_0) > > . = 1024; > *(.vsyscall_1) > } > > AFAICT the bfd linker thinks that assignments to . inside a section are > section-relative but gold thinks they're absolute. The documentation reference > is escaping me at the moment. I filed bug 13023 for the dot problem. I'm not convinced that the segment overlap is a real bug as opposed to gold just being a little stricter than the bfd linker.
With the dot problem split out as a separate bug (and fixed), and the segment overlap problem acknowledged as a problem with the script, I think this bug can be closed.