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.
GLneo
Post
by GLneo » Sat Jul 30, 2005 10:08 am
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 ???
Ushma
Post
by Ushma » Sat Jul 30, 2005 2:49 pm
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.
Ushma
Post
by Ushma » Sat Jul 30, 2005 5:34 pm
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.
GLneo
Post
by GLneo » Sat Jul 30, 2005 5:45 pm
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 ???
AR
Post
by AR » Sat Jul 30, 2005 10:04 pm
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.
GLneo
Post
by GLneo » Sat Jul 30, 2005 10:43 pm
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 ???
AR
Post
by AR » Sat Jul 30, 2005 11:04 pm
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.
GLneo
Post
by GLneo » Sun Jul 31, 2005 8:32 pm
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
AR
Post
by AR » Sun Jul 31, 2005 8:49 pm
I noticed a mistake in the linkscript, try the new one.
GLneo
Post
by GLneo » Sun Jul 31, 2005 9:22 pm
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