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


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/CompilingBinaryFilesUsingACompiler.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]