Page 1 of 1
Elf woes
Posted: Mon Dec 31, 2007 7:48 am
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
Posted: Mon Dec 31, 2007 11:07 am
by Craze Frog
You can create normal elf files with the correct version of gnu ld and fasm or gcc.
Posted: Mon Dec 31, 2007 11:16 am
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.
Posted: Mon Dec 31, 2007 11:26 am
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)
Posted: Mon Dec 31, 2007 11:34 am
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?
Posted: Mon Dec 31, 2007 11:52 am
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.
Posted: Wed Jan 02, 2008 9:50 am
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