Skip to content

Commit 96bcc47

Browse files
committed
[ARM] Honour -mno-movt in stack protector handling
When -mno-movt is passed to Clang, the ARM codegen correctly avoids movt/movw pairs to take the address of __stack_chk_guard in the stack protector code emitted into the function pro- and epilogues. However, the Thumb2 codegen fails to do so, and happily emits movw/movt pairs unless it is generating an ELF binary and the symbol might be in a different DSO. Let's incorporate a check for useMovt() in the logic here, so movt/movw are never emitted when -mno-movt is specified. Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 848cec1 commit 96bcc47

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Target/ARM/Thumb2InstrInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ void Thumb2InstrInfo::expandLoadStackGuard(
264264
}
265265

266266
const auto *GV = cast<GlobalValue>((*MI->memoperands_begin())->getValue());
267-
if (MF.getSubtarget<ARMSubtarget>().isTargetELF() && !GV->isDSOLocal())
267+
const ARMSubtarget &Subtarget = MF.getSubtarget<ARMSubtarget>();
268+
if ((Subtarget.isTargetELF() && !GV->isDSOLocal()) || !Subtarget.useMovt())
268269
expandLoadStackGuardBase(MI, ARM::t2LDRLIT_ga_pcrel, ARM::t2LDRi12);
269270
else if (MF.getTarget().isPositionIndependent())
270271
expandLoadStackGuardBase(MI, ARM::t2MOV_ga_pcrel, ARM::t2LDRi12);

0 commit comments

Comments
 (0)