
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. Reviewed By: nickdesaulniers Differential Revision: https://reviews.llvm.org/D150841
34 lines
1.8 KiB
LLVM
34 lines
1.8 KiB
LLVM
; RUN: llc -filetype=obj -relocation-model=pic --verify-machineinstrs -print-after=postrapseudos < %s 2>&1 | FileCheck -check-prefix=CHECK-POST-RA %s
|
|
; RUN: llc -filetype=obj -relocation-model=pic --verify-machineinstrs -print-after=arm-pseudo < %s 2>&1 | FileCheck -check-prefix=CHECK-POST-AP %s
|
|
|
|
; CHECK-POST-RA: $r12 = t2LDRLIT_ga_pcrel target-flags(arm-got) @__stack_chk_guard
|
|
; CHECK-POST-AP: $r12 = t2LDRpci %const.0, 14, $noreg
|
|
|
|
target triple = "thumbv7-unknown-linux-android23"
|
|
|
|
%"class.v8::internal::Assembler" = type {}
|
|
%"class.v8::internal::Operand" = type { %"class.v8::internal::Register", %"class.v8::internal::Register", i32, i32, %"union.v8::internal::Operand::Value" }
|
|
%"class.v8::internal::Register" = type {}
|
|
%"union.v8::internal::Operand::Value" = type { i32, [20 x i8] }
|
|
%"class.v8::internal::wasm::LiftoffAssembler" = type {}
|
|
|
|
declare void @_ZN2v88internal9Assembler3addENS0_8RegisterES2_RKNS0_7OperandENS0_4SBitENS0_9ConditionE(ptr, [1 x i32], [1 x i32], ptr, i32, i32)
|
|
|
|
; Function Attrs: ssp
|
|
define void @_ZN2v88internal4wasm16LiftoffAssembler13emit_i32_addiENS0_8RegisterES3_i(ptr %0, [1 x i32] %1, [1 x i32] %2, i32 %3) #0 {
|
|
%5 = alloca %"class.v8::internal::Operand", align 8
|
|
%6 = getelementptr %"class.v8::internal::Operand", ptr %5
|
|
%7 = getelementptr %"class.v8::internal::Operand", ptr %5
|
|
%8 = getelementptr %"class.v8::internal::Operand", ptr %5
|
|
%9 = getelementptr %"class.v8::internal::Operand", ptr %5
|
|
%10 = getelementptr %"class.v8::internal::Operand", ptr %5, i32 0, i32 4, i32 0
|
|
store i32 %3, ptr %10, align 4
|
|
call void @_ZN2v88internal9Assembler3addENS0_8RegisterES2_RKNS0_7OperandENS0_4SBitENS0_9ConditionE(ptr %0, [1 x i32] %1, [1 x i32] %2, ptr %5, i32 0, i32 2)
|
|
ret void
|
|
}
|
|
|
|
attributes #0 = { ssp }
|
|
|
|
!llvm.module.flags = !{!0}
|
|
!0 = !{i32 7, !"PIC Level", i32 2}
|