ELF64 Compiling - Help Please

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Kieran
Member
Member
Posts: 54
Joined: Mon Apr 11, 2005 11:00 pm

ELF64 Compiling - Help Please

Post by Kieran »

Hi guys, can anyone post a tutorial for compiling to ELF64 format.

I have read some of the tutorials on here, but failed to understand them.
Last edited by Kieran on Sun Dec 09, 2007 3:30 am, edited 1 time in total.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

What is your toolchain? Assuming binutils with elf64 support/nasm v2.00:

Code: Select all

nasm -f elf64 [inputfiles] -o [outputfiles]

or

x86_64-pc-elf-g++ [yourflags] -o [outputfile] -c [inputfile]
then link with:

Code: Select all

x86_64-pc-elf-ld [inputfiles] -o [outputfile]
It really is that simple. Of course, for ld you can specify -T link.ld and have a linker script specifying the output format elf64-x86-64, but if you have followed GCC Cross-Compiler for x86 64, this should be the default. As it stated in the tutorial, you are advised to be familiar with your toolchain first - you can get more familiar by following the standard cross-compiler article before you attempt the x86_64 one.

Cheers,
Adam
Kieran
Member
Member
Posts: 54
Joined: Mon Apr 11, 2005 11:00 pm

Post by Kieran »

Thanks for the reply Adam, I am following the cross-compiler tutorial now. :D
Kieran
Member
Member
Posts: 54
Joined: Mon Apr 11, 2005 11:00 pm

Post by Kieran »

I have tried all of the x86_64 tutorial, including trying the patch listed in the wiki, neither have worked. I just keep getting errors.

Has anyone done this before?
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

Kieran wrote:Has anyone done this before?
Yes, I did it several times (for several gcc & binutils versions) and it always worked perfectly. I wrote a bash script to automagically build a gcc x86 and x86-64 cross-compiler. It can be found in the lightOS svn repository. It is exactly the same as in the wiki iirc. I have tested the script under cygwin and a normal gnu/linux and it worked perfectly for me.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

I followed the guide to the letter and didn't encounter any problems. (I have even adapted it for 68000 targets without problems)

Have you checked the troubleshooting section of the GCC Cross-Compiler page for hints. Many are not limited to a 32-bit x86 toolchain.

If that doesn't work, would you please post the (topmost) error you get?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply