VALUE_CODEGENOPT(TLSSize, 8, 0)
/// The default stack protector guard offset to use.
-VALUE_CODEGENOPT(StackProtectorGuardOffset, 32, (unsigned)-1)
+VALUE_CODEGENOPT(StackProtectorGuardOffset, 32, INT_MAX)
/// Number of path components to strip when emitting checks. (0 == full
/// filename)
MarshallingInfoString<CodeGenOpts<"StackProtectorGuard">>;
def mstack_protector_guard_offset_EQ : Joined<["-"], "mstack-protector-guard-offset=">, Group<m_Group>, Flags<[CC1Option]>,
HelpText<"Use the given offset for addressing the stack-protector guard">,
- MarshallingInfoInt<CodeGenOpts<"StackProtectorGuardOffset">, "(unsigned)-1">;
+ MarshallingInfoInt<CodeGenOpts<"StackProtectorGuardOffset">, "INT_MAX">;
def mstack_protector_guard_reg_EQ : Joined<["-"], "mstack-protector-guard-reg=">, Group<m_Group>, Flags<[CC1Option]>,
HelpText<"Use the given reg for addressing the stack-protector guard">,
MarshallingInfoString<CodeGenOpts<"StackProtectorGuardReg">, [{"none"}]>;
if (!EffectiveTriple.isX86())
D.Diag(diag::err_drv_unsupported_opt_for_target)
<< A->getAsString(Args) << TripleStr;
- unsigned Offset;
+ int Offset;
if (Value.getAsInteger(10, Offset)) {
D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Value;
return;
std::string getBBSections();
std::string getStackProtectorGuard();
-unsigned getStackProtectorGuardOffset();
+int getStackProtectorGuardOffset();
std::string getStackProtectorGuardReg();
unsigned getTLSSize();
unsigned XRayOmitFunctionIndex : 1;
/// Stack protector guard offset to use.
- unsigned StackProtectorGuardOffset = -1U;
+ int StackProtectorGuardOffset = INT_MAX;
/// Stack protector guard mode to use, e.g. tls, global.
StackProtectorGuards StackProtectorGuard =
CGOPT(bool, XCOFFTracebackTable)
CGOPT(std::string, BBSections)
CGOPT(std::string, StackProtectorGuard)
-CGOPT(unsigned, StackProtectorGuardOffset)
+CGOPT(int, StackProtectorGuardOffset)
CGOPT(std::string, StackProtectorGuardReg)
CGOPT(unsigned, TLSSize)
CGOPT(bool, EmulatedTLS)
cl::init("none"));
CGBINDOPT(StackProtectorGuardReg);
- static cl::opt<unsigned> StackProtectorGuardOffset(
+ static cl::opt<int> StackProtectorGuardOffset(
"stack-protector-guard-offset", cl::desc("Stack protector guard offset"),
- cl::init((unsigned)-1));
+ cl::init(INT_MAX));
CGBINDOPT(StackProtectorGuardOffset);
static cl::opt<unsigned> TLSSize(
}
static Constant* SegmentOffset(IRBuilder<> &IRB,
- unsigned Offset, unsigned AddressSpace) {
+ int Offset, unsigned AddressSpace) {
return ConstantExpr::getIntToPtr(
ConstantInt::get(Type::getInt32Ty(IRB.getContext()), Offset),
Type::getInt8PtrTy(IRB.getContext())->getPointerTo(AddressSpace));
} else {
unsigned AddressSpace = getAddressSpace();
// Specially, some users may customize the base reg and offset.
- unsigned Offset = getTargetMachine().Options.StackProtectorGuardOffset;
+ int Offset = getTargetMachine().Options.StackProtectorGuardOffset;
// If we don't set -stack-protector-guard-offset value:
// %fs:0x28, unless we're using a Kernel code model, in which case
// it's %gs:0x28. gs:0x14 on i386.
- if (Offset == (unsigned)-1)
+ if (Offset == INT_MAX)
Offset = (Subtarget.is64Bit()) ? 0x28 : 0x14;
const auto &GuardReg = getTargetMachine().Options.StackProtectorGuardReg;
if (Subtarget.isTargetAndroid()) {
// %fs:0x48, unless we're using a Kernel code model, in which case it's %gs:
// %gs:0x24 on i386
- unsigned Offset = (Subtarget.is64Bit()) ? 0x48 : 0x24;
+ int Offset = (Subtarget.is64Bit()) ? 0x48 : 0x24;
return SegmentOffset(IRB, Offset, getAddressSpace());
}
; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-reg=fs -o - < %s | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-reg=gs -o - < %s | FileCheck --check-prefix=CHECK-GS %s
; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-offset=20 -o - < %s | FileCheck --check-prefix=CHECK-OFFSET %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-offset=-20 -o - < %s | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s
; CHECK-TLS-FS-40: movq %fs:40, %rax
; CHECK-TLS-FS-40: movq %fs:40, %rax
; CHECK-OFFSET-NEXT: .cfi_def_cfa_offset 32
; CHECK-OFFSET-NEXT: callq __stack_chk_fail
+; CHECK-NEGATIVE-OFFSET: movl $4294967276, %eax # imm = 0xFFFFFFEC
+; CHECK-NEGATIVE-OFFSET: movq %fs:(%rax), %rcx
+; CHECK-NEGATIVE-OFFSET: movq %fs:(%rax), %rax
+; CHECK-NEGATIVE-OFFSET-NEXT: cmpq 16(%rsp), %rax
+; CHECK-NEGATIVE-OFFSET-NEXT: jne .LBB0_2
+; CHECK-NEGATIVE-OFFSET: .LBB0_2:
+; CHECK-NEGATIVE-OFFSET-NEXT: .cfi_def_cfa_offset 32
+; CHECK-NEGATIVE-OFFSET-NEXT: callq __stack_chk_fail
+
; CHECK-GLOBAL: movq __stack_chk_guard(%rip), %rax
; CHECK-GLOBAL: movq __stack_chk_guard(%rip), %rax
; CHECK-GLOBAL-NEXT: cmpq 16(%rsp), %rax