[all-commits] [llvm/llvm-project] 932e36: [PAC][CodeGen][ELF][AArch64] Support signed GOT

Daniil Kovalev via All-commits all-commits at lists.llvm.org
Sun Oct 27 07:32:40 PDT 2024


  Branch: refs/heads/users/kovdan01/pauth-signed-got-codegen
  Home:   https://github.com/llvm/llvm-project
  Commit: 932e36a43f0f3aa81c55adfc736ce362759f7c28
      https://github.com/llvm/llvm-project/commit/932e36a43f0f3aa81c55adfc736ce362759f7c28
  Author: Daniil Kovalev <dkovalev at accesssoftek.com>
  Date:   2024-10-27 (Sun, 27 Oct 2024)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
    M llvm/lib/Target/AArch64/AArch64FastISel.cpp
    M llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    M llvm/lib/Target/AArch64/AArch64InstrInfo.td
    M llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
    M llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
    M llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
    M llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
    M llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
    M llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
    M llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp
    M llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h
    A llvm/test/CodeGen/AArch64/ptrauth-basic-pic.ll
    A llvm/test/CodeGen/AArch64/ptrauth-elf-globals-pic.ll
    A llvm/test/CodeGen/AArch64/ptrauth-elf-got-function-symbols.ll
    A llvm/test/CodeGen/AArch64/ptrauth-extern-weak.ll
    A llvm/test/CodeGen/AArch64/ptrauth-got-abuse.ll
    A llvm/test/CodeGen/AArch64/ptrauth-tagged-globals-pic.ll
    A llvm/test/MC/AArch64/adrp-auth-relocation.s
    M llvm/test/MC/AArch64/arm64-elf-relocs.s
    M llvm/test/MC/AArch64/ilp32-diagnostics.s

  Log Message:
  -----------
  [PAC][CodeGen][ELF][AArch64] Support signed GOT

This re-applies #96164 after revert in #102434.

Support the following relocations and assembly operators:

- `R_AARCH64_AUTH_ADR_GOT_PAGE` (`:got_auth:` for `adrp`)
- `R_AARCH64_AUTH_LD64_GOT_LO12_NC` (`:got_auth_lo12:` for `ldr`)
- `R_AARCH64_AUTH_GOT_ADD_LO12_NC` (`:got_auth_lo12:` for `add`)

`LOADgotAUTH` pseudo-instruction is introduced which is later expanded to
actual instruction sequence like the following.

```
adrp x16, :got_auth:sym
add x16, x16, :got_auth_lo12:sym
ldr x0, [x16]
autia x0, x16
```

If a resign is requested, like below, `LOADgotPAC` pseudo is used, and GOT
load is lowered similarly to `LOADgotAUTH`.

```
@var = global i32 0
define ptr @resign_globalvar() {
  ret ptr ptrauth (ptr @var, i32 3, i64 43)
}
```

If FPAC bit is not set and resign is requested, a check+trap sequence
similar to one used for `AUT` pseudo is emitted.

Both SelectionDAG and GlobalISel are suppported.
For FastISel, we fall back to SelectionDAG.

Tests starting with 'ptrauth-' have corresponding variants w/o this prefix.

See also specification
https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#appendix-signed-got


  Commit: f0044c35b05295bb49848454136925f61d2c2d02
      https://github.com/llvm/llvm-project/commit/f0044c35b05295bb49848454136925f61d2c2d02
  Author: Daniil Kovalev <dkovalev at accesssoftek.com>
  Date:   2024-10-27 (Sun, 27 Oct 2024)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

  Log Message:
  -----------
  [PAC][CodeGen] Use `emitPtrauthCheckAuthenticatedValue` in `LowerMOVaddrPAC`


  Commit: c1dd585f547abcfad542c1e61a2417344e7d2d7a
      https://github.com/llvm/llvm-project/commit/c1dd585f547abcfad542c1e61a2417344e7d2d7a
  Author: Daniil Kovalev <dkovalev at accesssoftek.com>
  Date:   2024-10-27 (Sun, 27 Oct 2024)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
    M llvm/lib/Target/AArch64/AArch64InstrInfo.td
    M llvm/test/CodeGen/AArch64/ptrauth-extern-weak.ll

  Log Message:
  -----------
  [PAC][CodeGen] Fix handling of extern_weak symbols with signed GOT

Before executing auth instruction on a signed address from a GOT slot,
we must ensure that the address is not zero since zero addresses are not
signed to preserve zero-checks working as expected. A GOT slot might be
filled with zero when we have an undefined weak symbol.


  Commit: a5688e5550e5b7263e0980509037d3ce6e536eec
      https://github.com/llvm/llvm-project/commit/a5688e5550e5b7263e0980509037d3ce6e536eec
  Author: Daniil Kovalev <dkovalev at accesssoftek.com>
  Date:   2024-10-27 (Sun, 27 Oct 2024)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
    M llvm/lib/Target/AArch64/AArch64InstrInfo.td
    M llvm/test/CodeGen/AArch64/ptrauth-basic-pic.ll
    M llvm/test/CodeGen/AArch64/ptrauth-elf-globals-pic.ll
    M llvm/test/CodeGen/AArch64/ptrauth-extern-weak.ll
    M llvm/test/CodeGen/AArch64/ptrauth-got-abuse.ll
    M llvm/test/CodeGen/AArch64/ptrauth-tagged-globals-pic.ll

  Log Message:
  -----------
  [PAC][CodeGen] Emit trap sequence w/o FPAC on LOADgotAUTH expansion


Compare: https://github.com/llvm/llvm-project/compare/932e36a43f0f%5E...a5688e5550e5

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list