Page 1 of 2
a mobius question
Posted: Mon Nov 03, 2003 5:46 pm
by Jarklin
Hi tim,
I'm checkin mobius source code, and i have something i can't found.
where is declared _scode variable? and what it contains?
thanks.
Re:a mobius question
Posted: Mon Nov 03, 2003 6:14 pm
by nullify
My guess is that its a symbol exported by the kernel linker script. It probably contains the address of the start of the code section of the kernel.
Re:a mobius question
Posted: Tue Nov 04, 2003 1:35 pm
by Tim
That's right. &scode is the virtual address of the start of the kernel image.
Re:a mobius question
Posted: Tue Nov 04, 2003 2:58 pm
by Jarklin
hi,
well, i don't know much about linker scripts. i see this "_scode = __image_base__;" what is __image_base__ , or better where can i find a simple tutorial about linker scripts?
thanks
Re:a mobius question
Posted: Tue Nov 04, 2003 4:31 pm
by Tim
__image_base__ is defined by Cygwin ld to be the address specified with the --image-base command line option.
Somebody posted a link to a tutorial on linker scripts recently. Use the Search function to find it.
Re:a mobius question
Posted: Tue Nov 04, 2003 5:29 pm
by Jarklin
Thanks tim.
One last question: what is for bss section?
Re:a mobius question
Posted: Tue Nov 04, 2003 6:12 pm
by nullify
It is used to store uninitialized data. (for example, global variables that you don't initially assign a value to when you declare them)
Code: Select all
int x = 0; // data section
int y; // bss section
Re:a mobius question
Posted: Wed Nov 05, 2003 4:37 am
by Pype.Clicker
your binary file will not store any byte for the .bss ('Below Stack Segment'), however, the loader will have to make sure that there's enough space to hold the binary image *plus* the BSS section and will have to ensure the memory assigned to the BSS is zeroed before running the program.
Re:a mobius question
Posted: Thu Nov 06, 2003 8:12 am
by jarklin
Ok.
One more question ( i know these one may be a silly question ):
I'm using gcc and ld.. but don't know how to link kernel to use 0xd000000 address, but it will be loaded at 0x100000. ( i'm not talkin about GDT or mangle pointer, only ld,gcc parameters.. ) I use these link script:
OUTPUT_FORMAT("elf32-i386")
ENTRY(AsmStart)
SECTIONS
{
stext = 0xc0000000;
.text 0xc0000000 +0x1000: {
*(.text)
*(.rodata*)
}
.data : {
*(.data)
}
.bss :
{
*(.bss)
}
}
Re:a mobius question
Posted: Thu Nov 06, 2003 8:58 am
by Pype.Clicker
i'd be tempted to say that your linker does not have to worry about where in physical memory the kernel will be loaded as soon as the loader does the correct job in order to make the image appear at the requested virtual address.
Re:a mobius question
Posted: Thu Nov 06, 2003 2:32 pm
by jarklin
well,
well, tim's memory manmagement1 tell to link the kernel to words at the virtual address X but it really will be loaded at Y. And 'till you got paggin enabled, you should do something to cheat the kernel. I don't know how compile the kernel to do this ( work in the virtual address X, and load it a the Y real address )
Re:a mobius question
Posted: Thu Nov 06, 2003 4:39 pm
by Tim
I use PE, which doesn't know about physical addresses. The physical address is determined only by the loader. I understand that ELF knows what physical address it wants to be loaded at, which messes things up.
Re:a mobius question
Posted: Thu Nov 06, 2003 4:52 pm
by jarlin
yeah, that's my problem wich i don't know how to solve. How can i link the kernel,in elf32 format, to work at 0xC0000000 virutal address, but load it at 0x100000??
Re:a mobius question
Posted: Thu Nov 06, 2003 6:23 pm
by Tim
I don't know. I've never used the ELF format.
Re:a mobius question
Posted: Thu Nov 06, 2003 6:40 pm
by jarklin
anyone knows it???
is it possible to outputs PE format with ld? i'm confused about that. And i try this i know it works
But even, i'm confused about this. How can i tell ld to link a kernel to work at this address? is like i have in the 'link script' posted before?