[llvm] [ARM] Fix __stack_chk_guard access when non-zero "PIC Level" is used with static relocation model (PR #70014)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 10:06:02 PDT 2023


================
@@ -104,11 +104,12 @@ void ARMInstrInfo::expandLoadStackGuard(MachineBasicBlock::iterator MI) const {
   const GlobalValue *GV =
       cast<GlobalValue>((*MI->memoperands_begin())->getValue());
 
-  if (!Subtarget.useMovt() || Subtarget.isGVInGOT(GV)) {
----------------
MaskRay wrote:

`isGVInGOT` is defined as

```
bool ARMSubtarget::isGVInGOT(const GlobalValue *GV) const {
  return isTargetELF() && TM.isPositionIndependent() &&
         !TM.shouldAssumeDSOLocal(*GV->getParent(), GV);
}
```

I believe the function name is misleading and `TM.isPositionIndependent() &&` probably should be removed, so I avoid using it.
However, removing `TM.isPositionIndependent() &&` from the function uncovers other problems, so I do not touch `ARMSubtarget::isGVInGOT`.

https://github.com/llvm/llvm-project/pull/70014


More information about the llvm-commits mailing list