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

Options -Wtrampolines and -fstack-clash-protection not universal #277

Closed
david-a-wheeler opened this issue Nov 4, 2023 · 7 comments
Closed

Comments

@david-a-wheeler
Copy link
Contributor

In the compiler option hardening materials, running the new "make" test on clang on MacOS causes failures with clang:

make
cc -O2 -Wall -Wformat=2 -Wconversion -Wtrampolines -Wimplicit-fallthrough  -D_FORTIFY_SOURCE=3  -D_GLIBCXX_ASSERTIONS  -fstack-clash-protection -fstack-protector-strong  -Wl,-z,nodlopen -Wl,-z,noexecstack  -Wl,-z,relro -Wl,-z,now  -fPIE -pie -fPIC -shared     demo.c   -o demo
clang: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
warning: unknown warning option '-Wtrampolines' [-Wunknown-warning-option]
1 warning generated.
ld: unknown option: -z

The -pie problem is known, and resolved by using -fpie. But -Wtrampolines and -fstack-clash-protection are not universal.

@thomasnyman
Copy link
Contributor

The -Wtrampolines issue is fixed by #358. The `-fstack-clash-protection' may just be a compiler version issue.

@siddhesh
Copy link
Contributor

Maybe the -fstack-clash-protection error you're seeing is because the aarch64 support was lacking? That has been added only recently: llvm/llvm-project#66524

@david-a-wheeler
Copy link
Contributor Author

@siddhesh - No, not in my specific case, since it's an Intel-based Mac:

clang --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

@siddhesh
Copy link
Contributor

That's odd, it's been in clang since 2020, so I'm guessing clang 11-ish. I wonder why Apple hasn't enabled it.

@david-a-wheeler
Copy link
Contributor Author

My guess is that Apple is not deploying the latest and greatest versions. That's really common, which is why we identify compiler versions for things.

@SecurityCRob
Copy link
Contributor

Has this been addressed by the C/C++ Compiler Hardening options guide? @gkunz @thomasnyman @david-a-wheeler

@thomasnyman
Copy link
Contributor

The placement of the options in the tl;dr section with respect to the main list and situational options has been addressed. Closing after review in Compiler BP Call 2024-06-27.

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

No branches or pull requests

4 participants