This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
x86-64: LD default ELF section file offset == LMA ?
- From: Etienne Lorrain <etienne_lorrain at yahoo dot fr>
- To: binutils at sourceware dot org
- Date: Fri, 3 Apr 2009 12:27:51 +0000 (GMT)
- Subject: x86-64: LD default ELF section file offset == LMA ?
- Reply-to: etienne_lorrain at yahoo dot fr
Hello,
I just have few assembly instructions in a 64 bits ELF file, and
this ELF file is 1114728 bytes...
Here is what I do (PC is 32 bits Debian, crosscompile -m64):
etienne@cygne:~/projet/gujin$ cat hello_64bits.s
.file "hello_64bits.c"
#APP
.text
.code32
.global _start
_start:
mov $0xB8000,%edi
add $640,%edi
mov $msg1,%esi
mov $0x17,%ah
1:
lodsb %ds:(%esi),%al
cmpb $0,%al
je 2f
stosw %ax,%es:(%edi)
jmp 1b
2:
mov $msg2,%esi
1:
lodsb %ds:(%esi),%al
cmpb $0,%al
je .
stosw %ax,%es:(%edi)
jmp 1b
#NO_APP
.globl msg1
.section .rodata
.align 32
.type msg1, @object
.size msg1, 34
msg1:
.string "Hello protected-mode text world! "
.globl msg2
.data
.align 32
.type msg2, @object
.size msg2, 35
msg2:
.string "(ELF64 file) ... please reboot ..."
.ident "GCC: (Debian 4.3.3-3) 4.3.3"
.section .note.GNU-stack,"",@progbits
etienne@cygne:~/projet/gujin$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.3-3' --with-bugurl=file
:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --pref
ix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettex
t --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --progra
m-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--enable-targets=all --enable-cld --with-tune=generic --enable-checking=release --build=i
486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.3 (Debian 4.3.3-3)
etienne@cygne:~/projet/gujin$ gcc -m64 -Wl,-Ttext=0x110000 -nostartfiles -nodefaultlibs hello_64bits.s hello_64bits.elf
etienne@cygne:~/projet/gujin$ ls -l hello_64bits.elf
-rwxr-xr-x 1 etienne etienne 1114728 2009-04-03 13:13 hello_64bits.elf
etienne@cygne:~/projet/gujin$ objdump -h hello_64bits.elf
hello_64bits.elf: file format elf64-x86-64
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000029 0000000000110000 0000000000110000 00110000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .rodata 00000022 0000000000110040 0000000000110040 00110040 2**5
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .data 00000023 0000000000310080 0000000000310080 00110080 2**5
CONTENTS, ALLOC, LOAD, DATA
3 .comment 0000001d 0000000000000000 0000000000000000 001100a3 2**0
CONTENTS, READONLY
etienne@cygne:~/projet/gujin$ ld --version
GNU ld (GNU Binutils for Debian) 2.19.1
Copyright 2007 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
etienne@cygne:~/projet/gujin$
Is that the intended behaviour?
Thanks,
Etienne.