Skip to content

Revert "[PAC][ELF][AArch64] Support signed personality function pointer" #119331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,9 +1218,6 @@ void CodeGenModule::Release() {
getModule().addModuleFlag(llvm::Module::Min, "ptrauth-elf-got", 1);

if (getTriple().isOSLinux()) {
if (LangOpts.PointerAuthCalls)
getModule().addModuleFlag(llvm::Module::Min, "ptrauth-sign-personality",
1);
assert(getTriple().isOSBinFormatELF());
using namespace llvm::ELF;
uint64_t PAuthABIVersion =
Expand Down
5 changes: 0 additions & 5 deletions clang/test/CodeGen/ptrauth-module-flags.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=OFF
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-elf-got -emit-llvm %s -o - | FileCheck %s --check-prefix=ELFGOT
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm %s -o - | FileCheck %s --check-prefix=PERSONALITY

// ELFGOT: !llvm.module.flags = !{
// ELFGOT-SAME: !1
// ELFGOT: !1 = !{i32 8, !"ptrauth-elf-got", i32 1}

// PERSONALITY: !llvm.module.flags = !{
// PERSONALITY-SAME: !1
// PERSONALITY: !1 = !{i32 8, !"ptrauth-sign-personality", i32 1}

// OFF-NOT: "ptrauth-
8 changes: 1 addition & 7 deletions llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;

void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL,
const MCSymbol *Sym,
const MachineModuleInfo *MMI) const override;

virtual void emitPersonalityValueImpl(MCStreamer &Streamer,
const DataLayout &DL,
const MCSymbol *Sym,
const MachineModuleInfo *MMI) const;
const MCSymbol *Sym) const override;

/// Given a constant with the SectionKind, return a section that it should be
/// placed in.
Expand Down
3 changes: 1 addition & 2 deletions llvm/include/llvm/Target/TargetLoweringObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ class TargetLoweringObjectFile : public MCObjectFileInfo {
virtual void Initialize(MCContext &ctx, const TargetMachine &TM);

virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM,
const MCSymbol *Sym,
const MachineModuleInfo *MMI) const;
const MCSymbol *Sym) const;

/// Emit the module-level metadata that the platform cares about.
virtual void emitModuleMetadata(MCStreamer &Streamer, Module &M) const {}
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ void DwarfCFIException::endModule() {
// Emit indirect reference table for all used personality functions
for (const GlobalValue *Personality : Personalities) {
MCSymbol *Sym = Asm->getSymbol(Personality);
TLOF.emitPersonalityValue(*Asm->OutStreamer, Asm->getDataLayout(), Sym,
Asm->MMI);
TLOF.emitPersonalityValue(*Asm->OutStreamer, Asm->getDataLayout(), Sym);
}
Personalities.clear();
}
Expand Down
10 changes: 1 addition & 9 deletions llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,7 @@ MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol(
}

void TargetLoweringObjectFileELF::emitPersonalityValue(
MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym,
const MachineModuleInfo *MMI) const {
MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym) const {
SmallString<64> NameData("DW.ref.");
NameData += Sym->getName();
MCSymbolELF *Label =
Expand All @@ -432,13 +431,6 @@ void TargetLoweringObjectFileELF::emitPersonalityValue(
Streamer.emitELFSize(Label, E);
Streamer.emitLabel(Label);

emitPersonalityValueImpl(Streamer, DL, Sym, MMI);
}

void TargetLoweringObjectFileELF::emitPersonalityValueImpl(
MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym,
const MachineModuleInfo *MMI) const {
unsigned Size = DL.getPointerSize();
Streamer.emitSymbolValue(Sym, Size);
}

Expand Down
32 changes: 0 additions & 32 deletions llvm/lib/Target/AArch64/AArch64MachineModuleInfo.cpp

This file was deleted.

35 changes: 0 additions & 35 deletions llvm/lib/Target/AArch64/AArch64MachineModuleInfo.h

This file was deleted.

17 changes: 0 additions & 17 deletions llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
//===----------------------------------------------------------------------===//

#include "AArch64TargetObjectFile.h"
#include "AArch64MachineModuleInfo.h"
#include "AArch64TargetMachine.h"
#include "MCTargetDesc/AArch64MCExpr.h"
#include "MCTargetDesc/AArch64TargetStreamer.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/IR/Mangler.h"
Expand All @@ -30,21 +28,6 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx,
SupportDebugThreadLocalLocation = false;
}

void AArch64_ELFTargetObjectFile::emitPersonalityValueImpl(
MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym,
const MachineModuleInfo *MMI) const {
if (!MMI->getObjFileInfo<AArch64MachineModuleInfo>().hasSignedPersonality()) {
TargetLoweringObjectFileELF::emitPersonalityValueImpl(Streamer, DL, Sym,
MMI);
return;
}
auto *TS = static_cast<AArch64TargetStreamer *>(Streamer.getTargetStreamer());
// The value is ptrauth_string_discriminator("personality")
constexpr uint16_t Discriminator = 0x7EAD;
TS->emitAuthValue(MCSymbolRefExpr::create(Sym, getContext()), Discriminator,
AArch64PACKey::IA, /*HasAddressDiversity=*/true);
}

const MCExpr *AArch64_ELFTargetObjectFile::getIndirectSymViaGOTPCRel(
const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV,
int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const {
Expand Down
4 changes: 0 additions & 4 deletions llvm/lib/Target/AArch64/AArch64TargetObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class AArch64_ELFTargetObjectFile : public TargetLoweringObjectFileELF {
MachineModuleInfo *MMI, const MCSymbol *RawSym,
AArch64PACKey::ID Key,
uint16_t Discriminator) const;

void emitPersonalityValueImpl(MCStreamer &Streamer, const DataLayout &DL,
const MCSymbol *Sym,
const MachineModuleInfo *MMI) const override;
};

/// AArch64_MachoTargetObjectFile - This TLOF implementation is used for Darwin.
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Target/AArch64/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ add_llvm_target(AArch64CodeGen
AArch64LoadStoreOptimizer.cpp
AArch64LowerHomogeneousPrologEpilog.cpp
AArch64MachineFunctionInfo.cpp
AArch64MachineModuleInfo.cpp
AArch64MachineScheduler.cpp
AArch64MacroFusion.cpp
AArch64MIPeepholeOpt.cpp
Expand Down
10 changes: 0 additions & 10 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ AArch64TargetStreamer::AArch64TargetStreamer(MCStreamer &S)

AArch64TargetStreamer::~AArch64TargetStreamer() = default;

void AArch64TargetStreamer::emitAuthValue(const MCExpr *Expr,
uint16_t Discriminator,
AArch64PACKey::ID Key,
bool HasAddressDiversity) {
Streamer.emitValueImpl(AArch64AuthMCExpr::create(Expr, Discriminator, Key,
HasAddressDiversity,
Streamer.getContext()),
8);
}

// The constant pool handling is shared by all AArch64TargetStreamer
// implementations.
const MCExpr *AArch64TargetStreamer::addConstantPoolEntry(const MCExpr *Expr,
Expand Down
6 changes: 0 additions & 6 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64TARGETSTREAMER_H
#define LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64TARGETSTREAMER_H

#include "AArch64MCExpr.h"
#include "llvm/MC/MCStreamer.h"

namespace {
Expand Down Expand Up @@ -39,11 +38,6 @@ class AArch64TargetStreamer : public MCTargetStreamer {
void emitNoteSection(unsigned Flags, uint64_t PAuthABIPlatform = -1,
uint64_t PAuthABIVersion = -1);

/// Callback used to emit AUTH expressions (e.g. signed
/// personality function pointer).
void emitAuthValue(const MCExpr *Expr, uint16_t Discriminator,
AArch64PACKey::ID Key, bool HasAddressDiversity);

/// Callback used to implement the .inst directive.
virtual void emitInst(uint32_t Inst);

Expand Down
7 changes: 4 additions & 3 deletions llvm/lib/Target/TargetLoweringObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol(
return TM.getSymbol(GV);
}

void TargetLoweringObjectFile::emitPersonalityValue(
MCStreamer &Streamer, const DataLayout &, const MCSymbol *Sym,
const MachineModuleInfo *MMI) const {}
void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
const DataLayout &,
const MCSymbol *Sym) const {
}

void TargetLoweringObjectFile::emitCGProfileMetadata(MCStreamer &Streamer,
Module &M) const {
Expand Down
39 changes: 0 additions & 39 deletions llvm/test/CodeGen/AArch64/ptrauth-sign-personality.ll

This file was deleted.

1 change: 0 additions & 1 deletion llvm/utils/gn/secondary/llvm/lib/Target/AArch64/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ static_library("LLVMAArch64CodeGen") {
"AArch64MCInstLower.cpp",
"AArch64MIPeepholeOpt.cpp",
"AArch64MachineFunctionInfo.cpp",
"AArch64MachineModuleInfo.cpp",
"AArch64MachineScheduler.cpp",
"AArch64MacroFusion.cpp",
"AArch64PBQPRegAlloc.cpp",
Expand Down
Loading