Page 3 of 3
Re:basic paging
Posted: Sat Jul 30, 2005 10:08 am
by GLneo
ahh, thx Ushma, ok i've read just about the whole thing and i still have no idea i've tried:
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x1000 : {
code = .; _code = .; __code = .;
MAINo/kern.o (.text)
MAINo/paging.o (.text)
. = ALIGN(0);
}
.text 0xC0000000 : {
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(0);
}
.data : {
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(0);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
bssend = .;
. = ALIGN(0);
}
bsslength = (bssend - bss) / 4;
end = .; _end = .; __end = .;
}
but i don't know what im doing, does any one no allot about linker script ??? MAINo/kern.o, MAINo/paging.o at 0x1000 and the rest at 0xC0000000 ???
Re:basic paging
Posted: Sat Jul 30, 2005 2:49 pm
by Ushma
I haven't tested this, but from my understanding of the manual, you should get something like this:
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.inittext 0x1000 : {
kern.o(.text)
paging.o(.text)
}
.initdata : {
kern.o(.data)
paging.o(.data)
}
.initbss : {
kern.o(.bss)
paging.o(.bss)
}
.text 0xC0000000 : {
*(.text)
}
.data : {
*(.data)
}
.bss :
{
*(.bss)
}
}
Hope that makes some sense and helps.
Re:basic paging
Posted: Sat Jul 30, 2005 5:34 pm
by Ushma
Erg, actually, that's wrong. The 0xC0000000 sections won't actually be at the 0xC0000000 mapped part. It needs to be adjusted for the space that kern.o and paging.o will displace it.
I'm thinking the first section needs padded out some arbitrary space (like a page boundary), and then the second part linked to 0xC0000000 + that.
Hmm... senseless ravings... I *hope* I'm making sense.
Re:basic paging
Posted: Sat Jul 30, 2005 5:45 pm
by GLneo
ahh, sorry it took so long to repliy i just got my stupid winxp computer back runnig, after the linker crashd the system, it said: warning: .text will be of size 0xBFFFF000 then continued any way to make the file and freeze windows, but anyway, thx that did help me the current script is:
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.inittext 0x1000 :
{
MAINo/kern.o(.text)
MAINo/paging.o(.text)
}
.initdata :
{
MAINo/kern.o(.data)
MAINo/paging.o(.data)
}
.initbss :
{
MAINo/kern.o(.bss)
MAINo/paging.o(.bss)
}
.text 0xC0000000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(0);
}
.data :
{
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(0);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
bssend = .;
. = ALIGN(0);
}
bsslength = (bssend - bss) / 4;
end = .; _end = .; __end = .;
}
the above script crashed LD ???
Re:basic paging
Posted: Sat Jul 30, 2005 10:04 pm
by AR
You can try adding physical position tags to the script:
Code: Select all
.inittext 0x100000 : AT(0x100000)
...
.text 0xC0000000 : AT(0x105000)
You should calculate the ATs dynamically with script variables.
Re:basic paging
Posted: Sat Jul 30, 2005 10:43 pm
by GLneo
ok, know my script looks like:
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.inittext 0x1000 : AT(0x1000)
{
MAINo/kern.o(.text)
MAINo/paging.o(.text)
. = ALIGN(4096);
}
.initdata :
{
MAINo/kern.o(.data)
MAINo/paging.o(.data)
. = ALIGN(4096);
}
.initbss :
{
MAINo/kern.o(.bss)
MAINo/paging.o(.bss)
}
.text 0xC0000000 : AT(0x3000)
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(0);
}
.data :
{
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(0);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
bssend = .;
. = ALIGN(0);
}
bsslength = (bssend - bss) / 4;
end = .; _end = .; __end = .;
}
but LD says: "can not find entry symble; defring to "like it normaly does but now instead of saying the entery adderess it locked up ???
Re:basic paging
Posted: Sat Jul 30, 2005 11:04 pm
by AR
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
PHYS = 0x1000;
VIRT = 0xC0000000;
.inittext PHYS : AT(PHYS)
{
__inittext = .;
MAINo/kern.o(.text)
MAINo/paging.o(.text)
. = ALIGN(4096);
__endinittext = .;
}
.initdata : AT(PHYS + __endinittext - __inittext)
{
__initdata = .;
MAINo/kern.o(.data)
MAINo/paging.o(.data)
. = ALIGN(4096);
__endinitdata = .;
}
.initbss : AT(PHYS + __endinitdata - __inittext
{
__initbss = .;
MAINo/kern.o(.bss)
MAINo/paging.o(.bss)
__endinitbss = .;
}
.text VIRT : AT(PHYS + __endinitbss - __inittext)
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(0);
__endtext = .;
}
.data : AT(PHYS + __endinitbss - __inittext + (__endtext - VIRT))
{
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(0);
__enddata = .;
}
.bss : AT(PHYS + __endinitbss - __inittext + (__enddata - VIRT))
{
bss = .; _bss = .; __bss = .;
*(.bss)
bssend = .;
. = ALIGN(0);
}
bsslength = (bssend - bss) / 4;
end = .; _end = .; __end = .;
}
If this doesn't work then you'll have to use ELF which is the only format I know that definitely supports this.
Re:basic paging
Posted: Sun Jul 31, 2005 8:32 pm
by GLneo
ok, this is stupid i'm going to just enable basic paging in my boot sector, then redo it in my kernel(for more control), but i'm very week in asm(i learned enough to wright my boot sector). I hate to ask for some though away code but i've all ready wasted weeks on this :'( , but can i have some, thx ;D
Re:basic paging
Posted: Sun Jul 31, 2005 8:49 pm
by AR
I noticed a mistake in the linkscript, try the new one.
Re:basic paging
Posted: Sun Jul 31, 2005 9:22 pm
by GLneo
ok, at least LD didn't crash but it crashed qemu + bochs said something about running in bogus memory or something, but that is most likely my code, so thx for the script