Hi, all. While trying to build GRUB on illumos [*-pc-solaris2.11], I've found that for different absolute addresses (-Wl,-Ttext -Wl,<ADDR>) objcopy -O binary produces different objects files, but it is expected to be the same.
Test script see at the bottom. I've checked it with binutils 2.22 on Debian and on Gentoo with different compilers. Debian's binutils have this problem, Gentoo: Gentoo: # ./objcopy-test + CC='gcc -m32' + OBJCOPY=objcopy + cat + gcc -m32 -c conftest.c -o conftest.o + for link_addr in 2000 8000 7C00 + gcc -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000 conftest.o -o conftest.exec.2000 /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000002000 + objcopy -O binary conftest.exec.2000 conftest.2000 + for link_addr in 2000 8000 7C00 + gcc -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000 conftest.o -o conftest.exec.8000 /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000008000 + objcopy -O binary conftest.exec.8000 conftest.8000 + for link_addr in 2000 8000 7C00 + gcc -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00 conftest.o -o conftest.exec.7C00 /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000007c00 + objcopy -O binary conftest.exec.7C00 conftest.7C00 + md5sum conftest.2000 conftest.7C00 conftest.8000 05349871a5ab8bb0c860d3109d65f58d conftest.2000 05349871a5ab8bb0c860d3109d65f58d conftest.7C00 05349871a5ab8bb0c860d3109d65f58d conftest.8000 + exit 0 Debian (testing): # ./objcopy-test + CC=gcc -m32 + OBJCOPY=objcopy + cat + gcc -m32 -c conftest.c -o conftest.o + gcc -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000 conftest.o -o conftest.exec.2000 /usr/bin/ld.bfd.real: warning: cannot find entry symbol _start; defaulting to 0000000000002000 + objcopy -O binary conftest.exec.2000 conftest.2000 + gcc -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000 conftest.o -o conftest.exec.8000 /usr/bin/ld.bfd.real: warning: cannot find entry symbol _start; defaulting to 0000000000008000 + objcopy -O binary conftest.exec.8000 conftest.8000 + gcc -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00 conftest.o -o conftest.exec.7C00 /usr/bin/ld.bfd.real: warning: cannot find entry symbol _start; defaulting to 0000000000007c00 + objcopy -O binary conftest.exec.7C00 conftest.7C00 + md5sum conftest.2000 conftest.7C00 conftest.8000 c2d829df4c6a7e335ab0e6a944ec87a3 conftest.2000 a6a514773337be95da81db75cdd011ba conftest.7C00 5883efd0da029145374269a65f8d689b conftest.8000 + exit 0 I've event tested it on OpenIndiana (binutils 2.19, GCC 4.4): # LD_ALTEXEC=/usr/bin/gld ./objcopy-test + CC='gcc -m32' + OBJCOPY=objcopy + cat + 1> conftest.c 0<< \EOF void cmain (void) { *((int *) 0x1000) = 2; } EOF + gcc -m32 -c conftest.c -o conftest.o + gcc -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000 conftest.o -o conftest.exec.2000 /usr/bin/gld: warning: cannot find entry symbol _start; defaulting to 0000000000002000 + objcopy -O binary conftest.exec.2000 conftest.2000 + gcc -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000 conftest.o -o conftest.exec.8000 /usr/bin/gld: warning: cannot find entry symbol _start; defaulting to 0000000000008000 + objcopy -O binary conftest.exec.8000 conftest.8000 + gcc -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00 conftest.o -o conftest.exec.7C00 /usr/bin/gld: warning: cannot find entry symbol _start; defaulting to 0000000000007c00 + objcopy -O binary conftest.exec.7C00 conftest.7C00 + md5sum conftest.2000 conftest.7C00 conftest.8000 42a9a3664e7dc9327f62aa111493b7b0 conftest.2000 42a9a3664e7dc9327f62aa111493b7b0 conftest.7C00 42a9a3664e7dc9327f62aa111493b7b0 conftest.8000 + exit 0 Could you check this out (run the script)? I'm thinking it could be cause by one of Debian patches. Here the test script (from GRUB's configure): ======================== >8 ========================== #!/bin/sh set -u set -e set -x CC=${CC-gcc -m32} OBJCOPY=${OBJCOPY-objcopy} cat > conftest.c <<\EOF void cmain (void) { *((int *) 0x1000) = 2; } EOF $CC -c conftest.c -o conftest.o for link_addr in 2000 8000 7C00; do $CC -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec.$link_addr $OBJCOPY -O binary conftest.exec.$link_addr conftest.$link_addr done md5sum conftest.[0-9]* exit 0 ======================== 8< ========================== -- To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/CALL-Q8w0Nyx9XDK=NW0oo+buRkSmt+cm=p7rk0y52ppmurv...@mail.gmail.com