Elf woes

Programming, for all ages and all languages.
Post Reply
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Elf woes

Post by lukem95 »

windows sucks, im using DJGPP for my testbed/compiler/linker and it works fine for my needs, compiles my kernel perfectly etc.

but i have implemented ELF relocation, and im struggling to create my own ELF for testing purposes, does anybody know a method i can compile and link my own files?

or... at my most desperate (until i find a solution), does anybody have a flat linked elf (32 bit) that does very little (i.e. prints a character to screen, simply returns etc) that i could use to test it in full?

Lukem95
~ Lukem95 [ Cake ]
Release: 0.08b
Image
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post by Craze Frog »

You can create normal elf files with the correct version of gnu ld and fasm or gcc.
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

c:\djgpp\bin/ld.exe: target i586-elf not found
I get this error when trying to link though.
OUTPUT_FORMAT(i586-elf)
ENTRY(start)
SECTIONS
{
.text 0x100000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}

.data :
{
data = .; _data = .; __data = .;
*(.data)
*(.rodata)
. = ALIGN(4096);
}

.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}

end = .; _end = .; __end = .;
}
This is my link.ld script, it works fine for COFF, however i havn't implemented that yet, so its very little use to me except for my kernel.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

windows sucks, im using DJGPP for my testbed/compiler/linker and it works fine for my needs, compiles my kernel perfectly etc.
interesting that you start with a blank statement about windows, and then admit your not using it... (DJGPP is an old DOS program, and doesnt even work properly with windows)
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

well im sorry for that then, i had no idea lol

i actually started using a computer with windows 98, and soon graduated to XP. I'm running vista on my laptop now. I've only been using pc's regularly since i was 11, 4 and a half years ago, so you can possibly understand why im not too familiar with DOS or what its native programs are?
~ Lukem95 [ Cake ]
Release: 0.08b
Image
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Post by quok »

You'll need to follow the GCC Cross Compiler tutorial found on the wiki. As said before, DJGPP is an old DOS program that doesn't work right with Windows, and as you correctly pointed out, it doesn't support the ELF file format.

You could also download Cygwin (which is Unix tools, compiled to run on Windows), but even then you'd need a cross compiler because Cygwin by default does not output ELF files.
Laksen
Member
Member
Posts: 140
Joined: Fri Nov 09, 2007 3:30 am
Location: Aalborg, Denmark

Post by Laksen »

Well I don't know if it'll be enough for your problem but I simply link to a pei-i386 object using some win32 ld and then call
objcopy -I pei-i386 -O elf32-i386 kernelpe.obj kernel.elf
Post Reply