3.1 git: ld: error: dot may not move backward
Hello,
current git (bbd9d6f7fbb0305c9a592bf05a32e87eb364a4ff)
[arekm@ixion-pld linux]$ gcc -v
Reading specs from /usr/lib64/gcc/x86_64-pld-linux/4.6.1/specs COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-pld-linux/4.6.1/lto-wrapper
Target: x86_64-pld-linux
Configured with: ../configure --prefix=/usr --with-local-prefix=/usr/local -- libdir=/usr/lib64 --libexecdir=/usr/lib64 --infodir=/usr/share/info -- mandir=/usr/share/man --x-libraries=/usr/lib64 --enable-checking=release -- enable-gnu-unique-object --enable-shared --enable-threads=posix --enable- linker-build-id --enable-linux-futex --enable- languages=c,c++,fortran,objc,obj-c++,ada,java --enable-libgomp --enable- libmudflap --enable-c99 --enable-long-long --enable-decimal-float=yes -- enable-nls --disable-werror --enable-lto --enable-plugin --disable-cld --with- gnu-as --with-gnu-ld --with-demangler-in-ld --with-system-zlib --with- slibdir=/lib64 --without-system-libunwind --enable-cmath --with-long- double-128 --with-gxx-include-dir=/usr/include/c++/4.6.1 --disable-libstdcxx- pch --enable-__cxa_atexit --enable-libstdcxx-allocator=new --enable-libjava- multilib=no --disable-gconf-peer --enable-java-awt=xlib,gtk --enable-libgcj -- enable-libgcj-multifile --enable-libgcj-database --enable-gtk-cairo --enable- jni --enable-xmlj --enable-bootstrap --with-pkgversion=PLD-Linux --with- bugurl=http://bugs.pld-linux.org x86_64-pld-linux
Thread model: posix
gcc version 4.6.1 20110714 (release) (PLD-Linux)
[arekm@ixion-pld linux]$ ld -v
GNU gold (Linux/GNU Binutils 2.21.53.0.1.20110716) 1.11
and at make bzImage
ld -m elf_x86_64 --build-id -o .tmp_vmlinux1 -T arch/x86/kernel/vmlinux.ldsarch/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/power/built-in.o arch/x86/video/built-in.o net/built-in.o -- end-group
ld: error: dot may not move backward
ld: error: dot may not move backward
ld: error: load segment overlap [0x1800000 -> 0x18850e0] and [0x1884000 -> 0x1884c10]
bisect ends with:
9fd67b4ed0714ab718f1f9bd14c344af336a6df7 is the first bad commit commit 9fd67b4ed0714ab718f1f9bd14c344af336a6df7
Author: Andy Lutomirski <[email protected]> Date: Sun Jun 5 13:50:19 2011 -0400
x86-64: Give vvars their own page
Move vvars out of the vsyscall page into their own page and mark it NX.
Without this patch, an attacker who can force a daemon to call some fixed address could wait until the time contains, say, 0xCD80, and then execute the current time.
Link:
http://lkml.kernel.org/r/b1460f81dc4463d66ea3f2b5ce240f58d48effec.1307292171.git.luto@mit.edu
:040000 040000 24ebbf4a851e35bfe4c65074f9e51a20c6ac54c8288ec01e5b8ccff746962f40e0e9310a31800c5d M arch
bisect run success
[arekm@ixion-pld linux]$ git bisect log
git bisect start
# bad: [bbd9d6f7fbb0305c9a592bf05a32e87eb364a4ff] Merge branch 'for-linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
git bisect bad bbd9d6f7fbb0305c9a592bf05a32e87eb364a4ff
# good: [02f8c6aee8df3cdc935e9bdd4f2d020306035dbe] Linux 3.0
git bisect good 02f8c6aee8df3cdc935e9bdd4f2d020306035dbe
# good: [cd6340199f65cad63262db0fd561bdcfd69df3bd] bnx2: Close device if tx_timeout reset fails
git bisect good cd6340199f65cad63262db0fd561bdcfd69df3bd
# good: [22a3b9771117d566def0150ea787fcc95f16e724] Merge branch 'for-linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
git bisect good 22a3b9771117d566def0150ea787fcc95f16e724
# good: [4d4abdcb1dee03a4f9d6d2021622ed07e14dfd17] Merge branch 'perf-core- for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
git bisect good 4d4abdcb1dee03a4f9d6d2021622ed07e14dfd17
# good: [3e0b8df79ddb8955d2cce5e858972a9cfe763384] Merge branch 'x86-uv-for- linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
git bisect good 3e0b8df79ddb8955d2cce5e858972a9cfe763384
# good: [12ad3ab66103e6582ca69c0c9de18b13487eaaef] superblock: move pin_sb_for_writeback() to fs/super.c
git bisect good 12ad3ab66103e6582ca69c0c9de18b13487eaaef
# good: [10d9f309d88ca7f47133d57e99b72810f119f75b] get rid of useless dget_parent() in btrfs rename() and link()
git bisect good 10d9f309d88ca7f47133d57e99b72810f119f75b
# bad: [98eedc3a9dbf90cecb91093d2a7fa083942b7d13] Document the vDSO and add a reference parser
git bisect bad 98eedc3a9dbf90cecb91093d2a7fa083942b7d13
# bad: [5cec93c216db77c45f7ce970d46283bcb1933884] x86-64: Emulate legacy vsyscalls
git bisect bad 5cec93c216db77c45f7ce970d46283bcb1933884
# bad: [0d7b8547fb67d5c2a7d954c56b3715b0e708be4a] x86-64: Remove kernel.vsyscall64 sysctl
git bisect bad 0d7b8547fb67d5c2a7d954c56b3715b0e708be4a
# good: [8b4777a4b50cb0c84c1152eac85d24415fb6ff7d] x86-64: Document some of entry_64.S
git bisect good 8b4777a4b50cb0c84c1152eac85d24415fb6ff7d
# bad: [9fd67b4ed0714ab718f1f9bd14c344af336a6df7] x86-64: Give vvars their own page
git bisect bad 9fd67b4ed0714ab718f1f9bd14c344af336a6df7
Signature · 2 lines
Arkadiusz Miśkiewicz PLD/Linux Team arekm / maven.pl http://ftp.pld-linux.org/
Quoted 34 lines · Arkadiusz Miskiewicz
Hello,
current git (
bbd9d6f7fbb0305c9a592bf05a32e87eb364a4ff)[arekm@ixion-pld linux]$ gcc -v
Reading specs from/usr/lib64/gcc/x86_64-pld-linux/4.6.1/specsCOLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-pld-linux/4.6.1/lto-wrapper
Target: x86_64-pld-linux
Configured with: ../configure --prefix=/usr --with-local-prefix=/usr/local -- libdir=/usr/lib64 --libexecdir=/usr/lib64 --infodir=/usr/share/info -- mandir=/usr/share/man --x-libraries=/usr/lib64 --enable-checking=release -- enable-gnu-unique-object --enable-shared --enable-threads=posix --enable- linker-build-id --enable-linux-futex --enable- languages=c,c++,fortran,objc,obj-c++,ada,java --enable-libgomp --enable- libmudflap --enable-c99 --enable-long-long --enable-decimal-float=yes -- enable-nls --disable-werror --enable-lto --enable-plugin --disable-cld --with- gnu-as --with-gnu-ld --with-demangler-in-ld --with-system-zlib --with- slibdir=/lib64 --without-system-libunwind --enable-cmath --with-long- double-128 --with-gxx-include-dir=/usr/include/c++/4.6.1 --disable-libstdcxx- pch --enable-__cxa_atexit --enable-libstdcxx-allocator=new --enable-libjava- multilib=no --disable-gconf-peer --enable-java-awt=xlib,gtk --enable-libgcj -- enable-libgcj-multifile --enable-libgcj-database --enable-gtk-cairo --enable- jni --enable-xmlj --enable-bootstrap --with-pkgversion=PLD-Linux --with- bugurl=http://bugs.pld-linux.org x86_64-pld-linux
Thread model: posix
gcc version 4.6.1 20110714 (release) (PLD-Linux)[arekm@ixion-pld linux]$ ld -v
GNU gold (Linux/GNU Binutils 2.21.53.0.1.20110716) 1.11and at make bzImage
Quoted 13 lines
ld -m
elf_x86_64--build-id -o .tmp_vmlinux1 -Tarch/x86/kernel/vmlinux.ldsarch/x86/kernel/head_64.oarch/x86/kernel/head64.oarch/x86/kernel/head.oarch/x86/kernel/init_task.oinit/built-in.o--start-groupusr/built-in.oarch/x86/built-in.okernel/built-in.omm/built-in.ofs/built-in.oipc/built-in.osecurity/built-in.ocrypto/built-in.oblock/built-in.olib/lib.aarch/x86/lib/lib.alib/built-in.oarch/x86/lib/built-in.odrivers/built-in.osound/built-in.ofirmware/built-in.oarch/x86/pci/built-in.oarch/x86/power/built-in.oarch/x86/video/built-in.onet/built-in.o-- end-group
ld: error: dot may not move backward
ld: error: dot may not move backward
ld: error: load segment overlap [0x1800000->0x18850e0] and [0x1884000->0x1884c10]
Please note that ld.bfd links just fine. I've opened a gold bug here:
http://sourceware.org/bugzilla/show_bug.cgi?id=13019
Signature · 1 line
Markus
cover Fix x86-64 linker script when using gold
In reply to Arkadiusz Miskiewicz[resent because I misspelled linux-kernel the first time.]
We were hitting two bugs:
http://sourceware.org/bugzilla/show_bug.cgi?id=13019
http://sourceware.org/bugzilla/show_bug.cgi?id=13023
The former was really a bug on the linker script that neither the old bfd linker nor the kernel loader cared about. It caused gold to bail, though.
The second is, I think, a legitimate bug in gold. But rather than regressing on current gold versions, we can work around it.
This is what I get for messing with the linker script :-/
Andy Lutomirski (2):
x86-64: Move the "user" vsyscall segment out of the data segment.
x86-64: Work around gold bug 13023
arch/x86/kernel/vmlinux.lds.S | 46 ++++++++++++++++++++++------------------ 1 files changed, 25 insertions(+), 21 deletions(-)
Signature · 1 line
1.7.6
PATCH RESEND 1/2 x86-64: Move the "user" vsyscall segment out of the data segment.
The kernel's loader doesn't seem to care, but gold complains.
--- arch/x86/kernel/vmlinux.lds.S | 36 ++++++++++++++++++------------------ 1 files changed, 18 insertions(+), 18 deletions(-)
arch/x86/kernel/vmlinux.lds.S +18 -18
@@ -154,6 +154,24 @@ SECTIONS #ifdef CONFIG_X86_64 + . = ALIGN(PAGE_SIZE); + __vvar_page = .; + + .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) { + + /* Place all vvars at the offsets in asm/vvar.h. */ +#define EMIT_VVAR(name, offset) \ + . = offset; \ + *(.vvar_ ## name) +#define __VVAR_KERNEL_LDS +#include <asm/vvar.h> +#undef __VVAR_KERNEL_LDS +#undef EMIT_VVAR + + } :data + + . = ALIGN(__vvar_page + PAGE_SIZE, PAGE_SIZE); + #define VSYSCALL_ADDR (-10*1024*1024) #define VLOAD_OFFSET (VSYSCALL_ADDR - __vsyscall_0 + LOAD_OFFSET)
@@ -162,7 +180,6 @@ SECTIONS #define VVIRT_OFFSET (VSYSCALL_ADDR - __vsyscall_0) #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET) - . = ALIGN(4096); __vsyscall_0 = .; . = VSYSCALL_ADDR;
@@ -185,23 +202,6 @@ SECTIONS #undef VVIRT_OFFSET #undef VVIRT - __vvar_page = .; - - .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) { - - /* Place all vvars at the offsets in asm/vvar.h. */ -#define EMIT_VVAR(name, offset) \ - . = offset; \ - *(.vvar_ ## name) -#define __VVAR_KERNEL_LDS -#include <asm/vvar.h> -#undef __VVAR_KERNEL_LDS -#undef EMIT_VVAR - - } :data - - . = ALIGN(__vvar_page + PAGE_SIZE, PAGE_SIZE); - #endif /* CONFIG_X86_64 */ /* Init code and data - will be freed after init */
Signature · 1 line
1.7.6
PATCH RESEND 2/2 x86-64: Work around gold bug 13023
In reply to Andy LutomirskiGold has trouble assigning numbers to the location counter inside of an output section description. The bug was triggered by 9fd67b4ed0714ab718f1f9bd14c344af336a6df7, which consolidated all of the vsyscall sections into a single section. The workaround is IMO still nicer than the old way of doing it.
This produces an apparently valid kernel image and passes my vdso tests on both GNU ld version 2.21.51.0.6-2.fc15 20110118 and GNU gold (version 2.21.51.0.6-2.fc15 20110118) 1.10 as distributed by Fedora 15.
--- arch/x86/kernel/vmlinux.lds.S | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)
arch/x86/kernel/vmlinux.lds.S +10 -6
@@ -158,10 +158,12 @@ SECTIONS __vvar_page = .; .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) { + /* work around gold bug 13023 */ + __vvar_beginning_hack = .; - /* Place all vvars at the offsets in asm/vvar.h. */ -#define EMIT_VVAR(name, offset) \ - . = offset; \ + /* Place all vvars at the offsets in asm/vvar.h. */ +#define EMIT_VVAR(name, offset) \ + . = __vvar_beginning_hack + offset; \ *(.vvar_ ## name) #define __VVAR_KERNEL_LDS #include <asm/vvar.h>
@@ -184,15 +186,17 @@ SECTIONS . = VSYSCALL_ADDR; .vsyscall : AT(VLOAD(.vsyscall)) { + /* work around gold bug 13023 */ + __vsyscall_beginning_hack = .; *(.vsyscall_0) - . = 1024; + . = __vsyscall_beginning_hack + 1024; *(.vsyscall_1) - . = 2048; + . = __vsyscall_beginning_hack + 2048; *(.vsyscall_2) - . = 4096; /* Pad the whole page. */ + . = __vsyscall_beginning_hack + 4096; /* Pad the whole page. */ } :user =0xcc . = ALIGN(__vsyscall_0 + PAGE_SIZE, PAGE_SIZE);
Signature · 1 line
1.7.6