I had my font named that because inside the kernel folder, I have a folder called font, which is where the file is. Thanks though.Octocontrabass wrote: The symbol name depends on the file name. Your font is named "font/unifont.sfn" instead of "console.sfn", so you need to replace "_binary_console_sfn_start" with "_binary_font_unifont_sfn_start".
How to make a GDT?
Re: How to make a GDT?
Re: How to make a GDT?
I'm now getting this error.
I'm assuming that the linker.ld file needs to be modified. Am I correct?
Code: Select all
mkdir -p /home/linuxlite/workspace/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/workspace/CCOS-new/sysroot/usr/include/.
mkdir -p /home/linuxlite/workspace/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/workspace/CCOS-new/sysroot/usr/include/.
mkdir -p /home/linuxlite/workspace/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/workspace/CCOS-new/sysroot/usr/include/.
mkdir -p /home/linuxlite/workspace/CCOS-new/sysroot/usr/lib
cp libk.a /home/linuxlite/workspace/CCOS-new/sysroot/usr/lib
mkdir -p /home/linuxlite/workspace/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/workspace/CCOS-new/sysroot/usr/include/.
x86_64-elf-gcc --sysroot=/home/linuxlite/workspace/CCOS-new/sysroot -isystem=/usr/include -T arch/x86_64/linker.ld -o myos.kernel -O2 -g -Wall -Wextra -ffreestanding -mcmodel=kernel -mno-red-zone arch/x86_64/crti.o arch/x86_64/crtbegin.o arch/x86_64/tty.o kernel/kernel.o unifont.o -nostdlib -lk -lgcc arch/x86_64/crtend.o arch/x86_64/crtn.o
/home/linuxlite/opt/cross/lib/gcc/x86_64-elf/12.2.0/../../../../x86_64-elf/bin/ld: warning: myos.kernel has a LOAD segment with RWX permissions
`.eh_frame' referenced in section `.text' of arch/x86_64/crtbegin.o: defined in discarded section `.eh_frame' of arch/x86_64/crtbegin.o
`.eh_frame' referenced in section `.text' of arch/x86_64/crtbegin.o: defined in discarded section `.eh_frame' of arch/x86_64/crtbegin.o
arch/x86_64/crtbegin.o: in function `deregister_tm_clones':
crtstuff.c:(.text+0x1): relocation truncated to fit: R_X86_64_32 against symbol `__TMC_END__' defined in .dtors section in myos.kernel
crtstuff.c:(.text+0x18): relocation truncated to fit: R_X86_64_32 against `.tm_clone_table'
arch/x86_64/crtbegin.o: in function `register_tm_clones':
crtstuff.c:(.text+0x31): relocation truncated to fit: R_X86_64_32 against symbol `__TMC_END__' defined in .dtors section in myos.kernel
crtstuff.c:(.text+0x5a): relocation truncated to fit: R_X86_64_32 against `.tm_clone_table'
arch/x86_64/crtbegin.o: in function `__do_global_dtors_aux':
crtstuff.c:(.text+0x88): relocation truncated to fit: R_X86_64_32 against `.dtors'
crtstuff.c:(.text+0x8e): relocation truncated to fit: R_X86_64_32 against symbol `__DTOR_END__' defined in .dtors section in arch/x86_64/crtend.o
arch/x86_64/crtbegin.o: in function `frame_dummy':
crtstuff.c:(.text+0x10c): relocation truncated to fit: R_X86_64_32 against `.bss'
kernel/kernel.o: in function `_start':
/home/linuxlite/workspace/CCOS-new/kernel/kernel/kernel.c:7:(.text+0xc): relocation truncated to fit: R_X86_64_32 against `.rodata.str1.1'
arch/x86_64/crtend.o: in function `__do_global_ctors_aux':
crtstuff.c:(.text+0x13): relocation truncated to fit: R_X86_64_32 against `.ctors'
collect2: error: ld returned 1 exit status
make: *** [Makefile:57: myos.kernel] Error 1
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How to make a GDT?
This didn't work. I got (what I think is) the same thing.Octocontrabass wrote: You need to build your libgcc with either -mcmodel=large or -mcmodel=kernel.
Code: Select all
mkdir -p /home/linuxlite/help/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/help/CCOS-new/sysroot/usr/include/.
mkdir -p /home/linuxlite/help/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/help/CCOS-new/sysroot/usr/include/.
mkdir -p /home/linuxlite/help/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/help/CCOS-new/sysroot/usr/include/.
x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -MD -c stdio/printf.c -o stdio/printf.libk.o -std=gnu11 -O2 -g -ffreestanding -Wall -Wextra -D__is_libc -Iinclude -D__is_libk
x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -MD -c string/memcmp.c -o string/memcmp.libk.o -std=gnu11 -O2 -g -ffreestanding -Wall -Wextra -D__is_libc -Iinclude -D__is_libk
x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -MD -c string/memcpy.c -o string/memcpy.libk.o -std=gnu11 -O2 -g -ffreestanding -Wall -Wextra -D__is_libc -Iinclude -D__is_libk
x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -MD -c string/memmove.c -o string/memmove.libk.o -std=gnu11 -O2 -g -ffreestanding -Wall -Wextra -D__is_libc -Iinclude -D__is_libk
x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -MD -c string/memset.c -o string/memset.libk.o -std=gnu11 -O2 -g -ffreestanding -Wall -Wextra -D__is_libc -Iinclude -D__is_libk
x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -MD -c string/strlen.c -o string/strlen.libk.o -std=gnu11 -O2 -g -ffreestanding -Wall -Wextra -D__is_libc -Iinclude -D__is_libk
x86_64-elf-ar rcs libk.a stdio/printf.libk.o stdio/putchar.libk.o stdio/puts.libk.o stdlib/abort.libk.o string/memcmp.libk.o string/memcpy.libk.o string/memmove.libk.o string/memset.libk.o string/strlen.libk.o
mkdir -p /home/linuxlite/help/CCOS-new/sysroot/usr/lib
cp libk.a /home/linuxlite/help/CCOS-new/sysroot/usr/lib
mkdir -p /home/linuxlite/help/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/help/CCOS-new/sysroot/usr/include/.
x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -MD -c arch/x86_64/tty.c -o arch/x86_64/tty.o -std=gnu11 -O2 -g -Wall -Wextra -ffreestanding -mcmodel=kernel -mno-red-zone -D__is_kernel -Iinclude
arch/x86_64/tty.c: In function 'terminal_initialize':
arch/x86_64/tty.c:14:18: warning: assignment to 'ssfn_font_t *' from incompatible pointer type 'volatile unsigned char *' [-Wincompatible-pointer-types]
14 | ssfn_src = &_binary_unifont_sfn_start; /* the bitmap font to use */
| ^
arch/x86_64/tty.c: In function 'terminal_putchar':
arch/x86_64/tty.c:32:29: warning: passing argument 1 of 'terminal_putentryat' makes pointer from integer without a cast [-Wint-conversion]
32 | terminal_putentryat(c);
| ^
| |
| char
arch/x86_64/tty.c:23:32: note: expected 'char *' but argument is of type 'char'
23 | void terminal_putentryat(char *s) {
| ~~~~~~^
x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -T arch/x86_64/linker.ld -o myos.kernel -O2 -g -Wall -Wextra -ffreestanding -mcmodel=kernel -mno-red-zone arch/x86_64/crti.o arch/x86_64/crtbegin.o arch/x86_64/tty.o kernel/kernel.o unifont.o -nostdlib -lk -lgcc arch/x86_64/crtend.o arch/x86_64/crtn.o
/home/linuxlite/opt/cross/lib/gcc/x86_64-elf/12.2.0/../../../../x86_64-elf/bin/ld: warning: myos.kernel has a LOAD segment with RWX permissions
`.eh_frame' referenced in section `.text' of arch/x86_64/crtbegin.o: defined in discarded section `.eh_frame' of arch/x86_64/crtbegin.o
`.eh_frame' referenced in section `.text' of arch/x86_64/crtbegin.o: defined in discarded section `.eh_frame' of arch/x86_64/crtbegin.o
arch/x86_64/crtbegin.o: in function `deregister_tm_clones':
crtstuff.c:(.text+0x1): relocation truncated to fit: R_X86_64_32 against symbol `__TMC_END__' defined in .dtors section in myos.kernel
crtstuff.c:(.text+0x18): relocation truncated to fit: R_X86_64_32 against `.tm_clone_table'
arch/x86_64/crtbegin.o: in function `register_tm_clones':
crtstuff.c:(.text+0x31): relocation truncated to fit: R_X86_64_32 against symbol `__TMC_END__' defined in .dtors section in myos.kernel
crtstuff.c:(.text+0x5a): relocation truncated to fit: R_X86_64_32 against `.tm_clone_table'
arch/x86_64/crtbegin.o: in function `__do_global_dtors_aux':
crtstuff.c:(.text+0x88): relocation truncated to fit: R_X86_64_32 against `.dtors'
crtstuff.c:(.text+0x8e): relocation truncated to fit: R_X86_64_32 against symbol `__DTOR_END__' defined in .dtors section in arch/x86_64/crtend.o
arch/x86_64/crtbegin.o: in function `frame_dummy':
crtstuff.c:(.text+0x10c): relocation truncated to fit: R_X86_64_32 against `.bss'
kernel/kernel.o: in function `_start':
/home/linuxlite/workspace/CCOS-new/kernel/kernel/kernel.c:7:(.text+0xc): relocation truncated to fit: R_X86_64_32 against `.rodata.str1.1'
arch/x86_64/crtend.o: in function `__do_global_ctors_aux':
crtstuff.c:(.text+0x13): relocation truncated to fit: R_X86_64_32 against `.ctors'
collect2: error: ld returned 1 exit status
make: *** [Makefile:57: myos.kernel] Error 1
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How to make a GDT?
I don't think Make is aware that you've rebuilt/reinstalled libgcc. Delete crtbegin.o and crtend.o and try again.
Re: How to make a GDT?
That didn't work. Here is the output.Octocontrabass wrote: I don't think Make is aware that you've rebuilt/reinstalled libgcc. Delete crtbegin.o and crtend.o and try again.
Code: Select all
mkdir -p /home/linuxlite/help/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/help/CCOS-new/sysroot/usr/include/.
mkdir -p /home/linuxlite/help/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/help/CCOS-new/sysroot/usr/include/.
mkdir -p /home/linuxlite/help/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/help/CCOS-new/sysroot/usr/include/.
mkdir -p /home/linuxlite/help/CCOS-new/sysroot/usr/lib
cp libk.a /home/linuxlite/help/CCOS-new/sysroot/usr/lib
mkdir -p /home/linuxlite/help/CCOS-new/sysroot/usr/include
cp -R --preserve=timestamps include/. /home/linuxlite/help/CCOS-new/sysroot/usr/include/.
OBJ=`x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -O2 -g -Wall -Wextra -ffreestanding -mcmodel=kernel -mno-red-zone -print-file-name=crtbegin.o` && cp "$OBJ" arch/x86_64/crtbegin.o
OBJ=`x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -O2 -g -Wall -Wextra -ffreestanding -mcmodel=kernel -mno-red-zone -print-file-name=crtend.o` && cp "$OBJ" arch/x86_64/crtend.o
x86_64-elf-gcc --sysroot=/home/linuxlite/help/CCOS-new/sysroot -isystem=/usr/include -T arch/x86_64/linker.ld -o myos.kernel -O2 -g -Wall -Wextra -ffreestanding -mcmodel=kernel -mno-red-zone arch/x86_64/crti.o arch/x86_64/crtbegin.o arch/x86_64/tty.o kernel/kernel.o unifont.o -nostdlib -lk -lgcc arch/x86_64/crtend.o arch/x86_64/crtn.o
/home/linuxlite/opt/cross/lib/gcc/x86_64-elf/12.2.0/../../../../x86_64-elf/bin/ld: warning: myos.kernel has a LOAD segment with RWX permissions
`.eh_frame' referenced in section `.text' of arch/x86_64/crtbegin.o: defined in discarded section `.eh_frame' of arch/x86_64/crtbegin.o
`.eh_frame' referenced in section `.text' of arch/x86_64/crtbegin.o: defined in discarded section `.eh_frame' of arch/x86_64/crtbegin.o
kernel/kernel.o: in function `_start':
/home/linuxlite/workspace/CCOS-new/kernel/kernel/kernel.c:7:(.text+0xc): relocation truncated to fit: R_X86_64_32 against `.rodata.str1.1'
collect2: error: ld returned 1 exit status
make: *** [Makefile:57: myos.kernel] Error 1
Re: How to make a GDT?
I didn't read your problem alot but I guess this happens while you are trying to switch your OS from 32 bit to 64 bit.
- When switching to 64 bit mode, if you want the address of a label you must add the "rel" prefix to relocateable symbols like the ones declared in the data and bss section. This will make nasm generate a 64 bit relocation entry.
So instead of :
Type :
- When switching to 64 bit mode, if you want the address of a label you must add the "rel" prefix to relocateable symbols like the ones declared in the data and bss section. This will make nasm generate a 64 bit relocation entry.
So instead of :
Code: Select all
mov eax, [SomeVariable]
Code: Select all
mov eax, [rel SomeVariable]
Last edited by devc1 on Thu Oct 20, 2022 9:29 am, edited 1 time in total.
Re: How to make a GDT?
Yes.devc1 wrote: I didn't read your problem alot but I guess this happens while you are trying to switch your OS from 32 bit to 64 bit.
I'm not sure what you mean by this. I am not using nasm. I'm using the BOOTBOOT protocol. It starts my kernel in long mode at the start.devc1 wrote: - When switching to 32 bit mode, if you want the address of a label you must add the "rel" prefix to relocateable symbols like the ones declared in the data and bss section. This will make nasm generate a 64 bit relocation entry.
So instead of :Type :Code: Select all
mov eax, [SomeVariable]
Code: Select all
mov eax, [rel SomeVariable]
Re: How to make a GDT?
Can you provide a link to your OS in github ?
Re: How to make a GDT?
I can. I've been having some trouble with Github lately, so my code isn't there. I will upload have to upload the code sometime later. Sorry about that. The link is https://github.com/zap8600/CCOS-new.devc1 wrote:Can you provide a link to your OS in github ?
Re: How to make a GDT?
However as I said before, the following message means that you're accessing the 32 bit relocated address of this symbol instead of the 64 bit one. Are you using your own CRT? If not then it is probably that your CRT is 32 bit and the linker only relocates 64 bit symbols.
relocation truncated to fit: R_X86_64_32 against symbol `__TMC_END__'
relocation truncated to fit: R_X86_64_32 against symbol `__TMC_END__'
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How to make a GDT?
Looks like you need to delete kernel.o too.zap8600 wrote:That didn't work.
Re: How to make a GDT?
libc /libgcc has nothing to do with this. The errors clearly came from his code.devc1 wrote:However as I said before, the following message means that you're accessing the 32 bit relocated address of this symbol instead of the 64 bit one. Are you using your own CRT? If not then it is probably that your CRT is 32 bit and the linker only relocates 64 bit symbols.
relocation truncated to fit: R_X86_64_32 against symbol `__TMC_END__'
You need to delete kernel.o so that gets rebuilt.
Re: How to make a GDT?
Are you talking about the crtn.S and crti.S files? If so, then I am using x86_64 files.devc1 wrote:However as I said before, the following message means that you're accessing the 32 bit relocated address of this symbol instead of the 64 bit one. Are you using your own CRT? If not then it is probably that your CRT is 32 bit and the linker only relocates 64 bit symbols.
relocation truncated to fit: R_X86_64_32 against symbol `__TMC_END__'
Re: How to make a GDT?
Like I said in my above post, it has nothing to do with that. Try deleting kernel.o and see what that does.