[llvm-dev] [stack protector] -mstack-protector-guard option

Zola Bridges via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 28 12:55:07 PDT 2020


Hi everyone,

I was trying out the new -mstack-protector-guard option
<https://reviews.llvm.org/D88631?id=295457> and I found when I tried to use
it I would get the following error:

/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../x86_64-linux-gnu/bin/ld:
/tmp/example-370eec.o: in function `main':

/home/ce/<source>:1: undefined reference to `__stack_chk_guard'

/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../x86_64-linux-gnu/bin/ld:
/home/ce/<source>:1: undefined reference to `__stack_chk_guard'

Here is a godbolt link to a small example which produces this error:
https://godbolt.org/z/EYYfhM.

I would appreciate any guidance on why I get this error on this small
example. Where does the linker expect the symbol __stack_chk_guard to be
defined? glibc? Another library? Is the flag -mstack-protector-guard
supposed to work "out of the box" so to speak or are there accompanying
upgrades to libraries or other things that I need or other flags I need to
pass along with it? I checked the documentation here:
https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mstack-protector-guard,
however I may be missing something obvious, so please feel free to give me
any thoughts you may have.

Also thanks for working on the -mstack-protector-guard feature in the first
place, Xiang!

Thank you!
Zola Bridges
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201028/3524f4c2/attachment.html>


More information about the llvm-dev mailing list