Say I have this
Code: Select all
/* Link.ld -- Linker script for the kernel - ensure everything goes in the */
/* Correct place. */
/* Original file taken from Bran's Kernel Development */
/* tutorials: http://www.osdever.net/bkerndev/index.php. */
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 = .;
}
question 1) Are linker scripts only meant for the LD linker?
question 2) Is their a windows version of LD linker?
question 3) I am finding most linkers don't support .bin format. So how can I get a .bin file out of my .obj files. I used Visual Studio 2005 to compile them to .obj. I know that VS link does not allow you to link the obj into .bin format.
question 4) Is their a way to make a bin file under windows xp out of obj ? I cann't find any way.
The only way I have seen is using LD and linker scripts but that is in linux. I don't want to have to do my whole os in asm using nasm -f bin ...etc etc would really like to use my c obj files.
Question 5) Is their a linker for nasm under windows ? I can compile to all different formats but unless I am under linux using gcc (gnu compiler). I cann't make the .exe file.
question 6) Does visual studio compiler compile to only OMF/COFF format could I ever get it to compile to ELF?
question 7) Which format is better to use ELF or OBJ for creating an OS? Why?
question If I want to call c functions in a asm program I cann't compile to a bin using nasm ?
Nasm doesn't support external references in bin file format. So then how is it even possible to use nasm to compile into a bin with external c code. (I believe it is not which is why you must have a linker that supports linking to a bin.)
I am also having a little trouble understanding the meaning of some of the lines in the linker script
Code: Select all
.data :
{
data = .; _data = .; __data = .;
*(.data)
*(.rodata)
. = ALIGN(4096);
}
*(your section) what is this for.
And why do you have to align? . = ALIGN(4096);
.text 0x100000 : means put the code segment at 1048576 memory location. What is so special about putting the code segment their? Could you randomly choose any memory location as long as it didn't overlay the GDT, IDT ,...etc etc.
Thanks for any clarity on these question's.