OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 11:01 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 294 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9, 10 ... 20  Next
Author Message
 Post subject: Re: How to make a GDT?
PostPosted: Wed Oct 19, 2022 7:19 pm 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
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".

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.


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Wed Oct 19, 2022 7:42 pm 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
I'm now getting this error.
Code:
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

I'm assuming that the linker.ld file needs to be modified. Am I correct?


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Wed Oct 19, 2022 7:54 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5143
You need to build your libgcc with either -mcmodel=large or -mcmodel=kernel.


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Wed Oct 19, 2022 10:26 pm 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
Octocontrabass wrote:

This didn't work. I got (what I think is) the same thing.
Code:
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

Am I just being dumb?


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Wed Oct 19, 2022 10:48 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5143
I don't think Make is aware that you've rebuilt/reinstalled libgcc. Delete crtbegin.o and crtend.o and try again.


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Thu Oct 20, 2022 12:28 am 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
Octocontrabass wrote:
I don't think Make is aware that you've rebuilt/reinstalled libgcc. Delete crtbegin.o and crtend.o and try again.

That didn't work. Here is the output.
Code:
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


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Thu Oct 20, 2022 9:15 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
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 :
Code:
mov eax, [SomeVariable]

Type :
Code:
mov eax, [rel SomeVariable]


Last edited by devc1 on Thu Oct 20, 2022 9:29 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Thu Oct 20, 2022 9:24 am 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
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.

Yes.

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 :
Code:
mov eax, [SomeVariable]

Type :
Code:
mov eax, [rel SomeVariable]


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.


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Thu Oct 20, 2022 9:28 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
Can you provide a link to your OS in github ?


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Thu Oct 20, 2022 9:46 am 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
devc1 wrote:
Can you provide a link to your OS in github ?

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.


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Thu Oct 20, 2022 9:53 am 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
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__'


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Thu Oct 20, 2022 10:09 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5143
zap8600 wrote:
That didn't work.

Looks like you need to delete kernel.o too.


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Thu Oct 20, 2022 10:13 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
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__'

libc /libgcc has nothing to do with this. The errors clearly came from his code.

You need to delete kernel.o so that gets rebuilt.

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Thu Oct 20, 2022 10:39 am 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
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__'

Are you talking about the crtn.S and crti.S files? If so, then I am using x86_64 files.


Top
 Profile  
 
 Post subject: Re: How to make a GDT?
PostPosted: Thu Oct 20, 2022 12:01 pm 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
Like I said in my above post, it has nothing to do with that. Try deleting kernel.o and see what that does.

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 294 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8, 9, 10 ... 20  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 83 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group