[Bug ld/11628] New: "ld -Ttext-segment=ORG" does not set PT_LOAD.p_vaddr

2010-05-24 Thread jreiser at BitWagon dot com
Sometimes ld uses the default builtin loader script to set the origin of the
text segment despite the commandline parameter -Ttext-segment=ORG.  In
particular: binutils-2.20.1 on OpenSolaris (SunOS opensolaris 5.11 snv_111b
i86pc i386 i86pc Solaris) when configured and built to handle 64-bit binaries
via "./configure --enable-64-bit-bfd=yes".  -Ttext-segment fails for 64-bit,
works for 32-bit.

Test case:
-start.s
_start: .globl _start
hlt
-
$ gcc -m32 -c -o start32.o start.s
$ gcc -m64 -c -o start64.o start.s
$ ld-2.20.1 -Ttext-segment=0x9000 -o start32 start32.o
$ readelf --segments start32 | grep LOAD
  LOAD   0x00 0x9000 0x9000 0x00055 0x00055 R E 0x1000
## WORKS because p_vaddr is 0x9000, default is 0x08048000.

$ ld-2.20.1 --oformat elf64-x86-64 -m elf_x86_64 -Ttext-segment=0x567000 -o
start64 start64.o
$ readelf --segments start64 | grep LOAD
  LOAD   0x 0x0040 0x0040
### FAILS because p_vaddr is the default 0x40, should be the specified 
0x567000.

-- 
   Summary: "ld -Ttext-segment=ORG" does not set PT_LOAD.p_vaddr
   Product: binutils
   Version: 2.20
Status: NEW
  Severity: normal
  Priority: P2
 Component: ld
AssignedTo: unassigned at sources dot redhat dot com
ReportedBy: jreiser at BitWagon dot com
CC: bug-binutils at gnu dot org
 GCC build triplet: i386-pc-solaris2.11
  GCC host triplet: i386-pc-solaris2.11
GCC target triplet: i386-pc-solaris2.11


http://sourceware.org/bugzilla/show_bug.cgi?id=11628

--- You are receiving this mail because: ---
You are on the CC list for the bug, or are watching someone who is.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/11628] "ld -Ttext-segment=ORG" does not set PT_LOAD.p_vaddr

2010-05-24 Thread jreiser at BitWagon dot com

--- Additional Comments From jreiser at BitWagon dot com  2010-05-24 15:22 
---
Arrggg.  Must also specify "-z max-page-size=0x1000".  There should be a
warning about this (-Ttext-segment not a multiple of the max-page-size.)

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11628

--- You are receiving this mail because: ---
You are on the CC list for the bug, or are watching someone who is.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/11628] "ld -Ttext-segment=ORG" does not set PT_LOAD.p_vaddr

2010-05-24 Thread hjl dot tools at gmail dot com

--- Additional Comments From jreiser at BitWagon dot com  2010-05-24 15:25 
---
Subject: Re:  New: "ld -Ttext-segment=ORG" does not set PT_LOAD.p_vaddr

> Sometimes ld uses the default builtin loader script to set the origin of the
> text segment despite the commandline parameter -Ttext-segment=ORG.

Forgot to specify "-z max-page-size=0x1000".  ld should warn when
-Ttext-segment is not a multiple of max-page-size.


--- Additional Comments From hjl dot tools at gmail dot com  2010-05-24 
18:26 ---
A patch is posted at

http://sourceware.org/ml/binutils/2010-05/msg00294.html

-- 
   What|Removed |Added

  GCC build triplet|i386-pc-solaris2.11 |
   GCC host triplet|i386-pc-solaris2.11 |
 GCC target triplet|i386-pc-solaris2.11 |


http://sourceware.org/bugzilla/show_bug.cgi?id=11628

--- You are receiving this mail because: ---
You are on the CC list for the bug, or are watching someone who is.

___
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils