Follow-up Comment #2, bug #34539 (project grub):

i think the latest comment contains typos.  gold will use the wrong address if
you specify "-Wl,-Ttext,8200" (namely, it'll use 0x2008 and not 0x8200).  it
will work fine if you prefix the address with a hex value like
"-Wl,-Ttext,0x8200".

$ gcc -o 1.img -ffreestanding -Wl,-Ttext,8200 1.S -nostdlib -m32
$ readelf -S 1.img | grep text
  [ 1] .text             PROGBITS        00002008 001008 000000 00  AX  0   0 
4
$ gcc -o 1.img -ffreestanding -Wl,-Ttext,0x8200 1.S -nostdlib -m32
$ readelf -S 1.img | grep text
  [ 1] .text             PROGBITS        00008200 000200 000000 00  AX  0   0 
4

upstream bug:
http://sourceware.org/bugzilla/show_bug.cgi?id=14187

it's trivial to workaround in grub2: add a 0x prefix to addresses with the
-Ttext flag.  a quick grep shows at least:
configure.ac:      CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC}
${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?34539>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


_______________________________________________
Bug-grub mailing list
Bug-grub@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-grub

Reply via email to