This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: X86_64 cross compiler and generating binaries


Daniel,

Thanks for the hint, I looked at the 1M binary and noticed that the
beginning of the file had the code but at the end was some "stuff". I then
exectued "objdump -D t1" and saw at the "stuff" is an ".eh_frame", not sure
what that is and I need to find out but by changing the objcopy command to:

  objcopy -R .note -R .comment -R .eh_frame -S -O binary t1 t1.bin

The resulting file is 48 bytes and is exactly the data from <main> seen in
the objdump. Quite nice that standard objdump and objcopy work with the
elf64-x86-64 files!

Thanks,

Wink

Ps: Take care of your RSI.

-----Original Message-----
From: Daniel Kegel [mailto:dkegel@google.com] 
Sent: Monday, February 16, 2004 10:36 AM
To: wink saville
Cc: crossgcc@sources.redhat.com
Subject: Re: X86_64 cross compiler and generating binaries


wink saville wrote:
> I'm looking to create a simple kernel for the Amd64 and want to make a 
> boot loader to start with. I have followed the instructions provided 
> here, 
> http://www.nondot.org/sabre/os/files/Booting/CompilingBinaryFilesUsing
> ACompiler.pdf.
> 
> I created a small program, t1.c ...
> 
> When I compile this using a cross compiler created using Kegel's 
> crosstool
> (http://kegel.com/crosstool/) using the following:
> 
>   gcc -c -o t1.o t1.c
>   ld -Ttext 0x0 -e main -o t1 t1.o
>   objcopy -R .note -R .comment -S -O binary t1 t1.bin
> 
> The result is:
> 
>   t1.o   1256 bytes
>   t1     1049835 bytes
>   t1.bin 1048680 bytes
> 
> When I compile it with gcc 3.3.2 (Debian) using the same options... 
> The result is:
> 
>   t1.o   699 bytes
>   t1     4791 bytes
>   t1.bin 51 bytes
> 
> Sooooo, the 1M file is a mite big, any ideas what I'm doing wrong?

I suspect the default load address of x86_64's abi is higher than the one in
x86's abi.  Thus there are about a million zeroes at the start of the t1.bin
compiled for x86_64.

I couldn't find where it says this in
http://www.x86-64.org/documentation/abi.pdf
but I bet that's it.

Running hexdump on both t1's verifies this.  The start address for x86 seems
to be 0x1000 or so, and for x86 it's 0x100000.

- Dan



------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]