Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mashaole opened this issue Oct 30, 2019 · 11 comments
Open

Comments

@mashaole
Copy link

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
Copy link

Juha3141 commented Nov 6, 2019

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

@sloganking
Copy link

sloganking commented Nov 14, 2019

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
Copy link
Author

mashaole commented Nov 14, 2019

@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
Copy link

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

@mashaole
Copy link
Author

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

https://github.com/mashaole/MashwareOS

@Juha3141
Copy link

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
Copy link

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
Copy link

sloganking commented Nov 21, 2019

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
Copy link

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
Copy link

@devjuha Yes, thank you very much.

@PF94
Copy link

PF94 commented Feb 1, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants