a mobius question

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.
Jarklin

a mobius question

Post 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.
nullify

Re:a mobius question

Post 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.
Tim

Re:a mobius question

Post by Tim »

That's right. &scode is the virtual address of the start of the kernel image.
Jarklin

Re:a mobius question

Post 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
Tim

Re:a mobius question

Post 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.
Jarklin

Re:a mobius question

Post by Jarklin »

Thanks tim.

One last question: what is for bss section?
nullify

Re:a mobius question

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:a mobius question

Post 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.
jarklin

Re:a mobius question

Post 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)
}
}
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:a mobius question

Post 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.
jarklin

Re:a mobius question

Post 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 )
Tim

Re:a mobius question

Post 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.
jarlin

Re:a mobius question

Post 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??
Tim

Re:a mobius question

Post by Tim »

I don't know. I've never used the ELF format.
jarklin

Re:a mobius question

Post 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?
Post Reply