[PATCH] D150841: [IR] Make stack protector symbol dso_local according to -f[no-]direct-access-external-data
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 17 22:50:34 PDT 2023
MaskRay created this revision.
MaskRay added reviewers: ardb, nickdesaulniers, pengfei, xiangzhangllvm.
Herald added subscribers: bd1976llvm, hiraditya, krytarowski, arichardson, nemanjai, emaste.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
There are two motivations.
`-fno-pic -fstack-protector -mstack-protector-guard=global` created
`__stack_chk_guard` is referenced directly on all ELF OSes except FreeBSD.
This patch allows referencing the symbol indirectly with
-fno-direct-access-external-data.
Some Linux kernel folks want
`-fno-pic -fstack-protector -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__stack_chk_guard`
created `__stack_chk_guard` to be referenced directly, avoiding
R_X86_64_REX_GOTPCRELX (even if the relocation may be optimized out by the linker).
https://github.com/llvm/llvm-project/issues/60116
Why they need this isn't so clear to me.
---
Add module flag "direct-access-external-data" and set the dso_local property of
the stack protector symbol. The module flag can benefit other LLVMCodeGen
synthesized symbols that are not represented in LLVM IR.
Nowadays, with `-fno-pic` being uncommon, ideally we should set
"direct-access-external-data" when it is true. However, doing so would require
~90 clang/test tests to be updated, which are too much.
As a compromise, we set "direct-access-external-data" only when it's different
from the implied default value.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D150841
Files:
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/dso-local-executable.c
llvm/include/llvm/IR/Module.h
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/IR/Module.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/AArch64/arm64_32.ll
llvm/test/CodeGen/AArch64/stack-guard-sve.ll
llvm/test/CodeGen/AArch64/stack-guard-vaarg.ll
llvm/test/CodeGen/AArch64/stack_guard_remat.ll
llvm/test/CodeGen/ARM/expand-pseudos.ll
llvm/test/CodeGen/ARM/stack-guard-rwpi.ll
llvm/test/CodeGen/ARM/stack_guard_remat.ll
llvm/test/CodeGen/Inputs/stack-guard-reassign.ll
llvm/test/CodeGen/PowerPC/stack-guard-oob.ll
llvm/test/CodeGen/Thumb/stack_guard_remat.ll
llvm/test/CodeGen/Thumb2/stack_guard_remat.ll
llvm/test/CodeGen/X86/2009-04-14-IllegalRegs.ll
llvm/test/CodeGen/X86/2010-09-17-SideEffectsInChain.ll
llvm/test/CodeGen/X86/stack-protector-3.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150841.523271.patch
Type: text/x-patch
Size: 17556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230518/41c82419/attachment.bin>
More information about the llvm-commits
mailing list