AlgorithMan-de / wyoos

Source codes for the "Write your own Operating System" video-series on YouTube
http://wyoos.org
GNU General Public License v3.0
719 stars 222 forks source link

gdt.cpp:(.text+0xa2): undefined reference to `__stack_chk_fail_local' #15

Open mashaole opened 4 years ago

mashaole commented 4 years ago

After writing the gdt.cpp file and calling the class in kernel.cpp and "make run" i get this error, is there a solution to this ?but the gdt.o is created but i cant compile the .bin file

Juha3141 commented 4 years ago

add "-fno-stack-protector" in GCCPARAMS. then you can fix this error(my english isn't good enough)

sloganking commented 4 years ago

I am also having this issue. @devjuha adding "-fno-stack-protector" in GCCPARAMS does not fix this for me.

Edit:

I have tried this on Linux Mint 19.1 and Manjaro Linux

mashaole commented 4 years ago

@devjuha im using Linux Mint 19.2 Cinnamon 32 bit

add "-fno-stack-protector" in GCCPARAMS. then you can fix this error(my english isn't good enough)

im using 32bit Linux mint 19.2 Cinnamon

Juha3141 commented 4 years ago

i want to see that code. could you upload for me?

mashaole commented 4 years ago

i want to see that code. could you upload for me?

https://github.com/mashaole/MashwareOS

Juha3141 commented 4 years ago

i want to see that code. could you upload for me?

https://github.com/mashaole/MashwareOS

what is your compiler version? i'm using gcc 9.2.1 but compile was not complete. as version is 2.33.1. error message: g++ -c -o gdt.o gdt.cpp

gdt.cpp: In constructor ‘GlobalDescriptorTable::GlobalDescriptorTable()’: gdt.cpp:14:22: error: cast from ‘GlobalDescriptorTable*’ to ‘uint32_t’ {aka ‘unsigned int’} loses precision [-fpermissive] 14 | i[0] = (uint32_t)this; | ^~~~

Juha3141 commented 4 years ago

i want to see that code. could you upload for me?

https://github.com/mashaole/MashwareOS

i think you should define __stack_chk_fail_local in gdt.cpp

sloganking commented 4 years ago

Ok, so adding -fno-stack-protector in the makefile's GCCPARAMS AND adding

uint32_t __stack_chk_fail_local(){
    return 0;
}

in gdt.cpp has fixed my problem. Interestingly, I can now take away the __stack_chk_fail_local() function I declared in gdt.cpp and the compiler no longer raises any errors. So the issue is fixed for me but I don't understand this behavior.

Edit:

My fix works for me on both Linux Mint 19.2 and Manjaro Linux.

A link to my repo https://github.com/sloganking/My-Own-OS

Edit:

add the above function to whatever file your compiler says has an error without it, not just gdt.cpp. The compiler tells me a different file needs it when I add new files or build this repo instead.

Juha3141 commented 4 years ago

Ok, so adding "-fno-stack-protector" in the makefile's GCCPARAMS AND adding

uint32_t __stack_chk_fail_local(){
    return 0;
}

in gdt.cpp has fixed my problem. Interestingly, I can now take away the __stack_chk_fail_local() function I declared in gdt.cpp and the compiler no longer raises any errors. So the issue is fixed for me but I don't understand this behavior.

Edit:

My fix works for me on both Linux Mint 19.2 and Manjaro Linux.

A link to my repo https://github.com/SleepingFox88/My-Own-OS

i think very thankful because your problem was fixed!

sloganking commented 4 years ago

@devjuha Yes, thank you very much.

PF94 commented 2 years ago

Ok, so adding -fno-stack-protector in the makefile's GCCPARAMS AND adding

uint32_t __stack_chk_fail_local(){
    return 0;
}

in gdt.cpp has fixed my problem. Interestingly, I can now take away the __stack_chk_fail_local() function I declared in gdt.cpp and the compiler no longer raises any errors. So the issue is fixed for me but I don't understand this behavior.

Edit:

My fix works for me on both Linux Mint 19.2 and Manjaro Linux.

A link to my repo https://github.com/sloganking/My-Own-OS

Edit:

add the above function to whatever file your compiler says has an error without it, not just gdt.cpp. The compiler tells me a different file needs it when I add new files or build this repo instead.

Ayyy, this works.