Skip to content
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

[lld][AArch64][ELF][PAC] Support AUTH relocations and AUTH ELF marking #72714

Merged
merged 45 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c493d78
[lld][AArch64][ELF][PAC] Support AUTH relocations and AUTH ELF marking
kovdan01 Sep 28, 2023
589c645
Address trivial review comments
kovdan01 Dec 12, 2023
a021f15
Merge branch 'main' into pauth-lld-20240109
kovdan01 Jan 9, 2024
d341159
Use `pack-relative-relocs` for both regular and auth relr relocs
kovdan01 Jan 9, 2024
b791da9
Rename aarch64-ptrauth.s to aarch64-reloc-pauth.s
kovdan01 Jan 9, 2024
b95dcf8
Remove unneeded test directives
kovdan01 Jan 9, 2024
594f8a0
Do not emit AUTH relocations in read-only sections
kovdan01 Jan 11, 2024
d793c0c
Merge branch 'main' into pauth-lld
kovdan01 Jan 27, 2024
acb1730
Apply fix from 37efa70 accidently deleted in d793c0c
kovdan01 Jan 31, 2024
de73eae
Address review comments
kovdan01 Jan 31, 2024
321a6a9
Merge branch 'main' into pauth-lld
kovdan01 Feb 15, 2024
aff3a96
Address several review comments
kovdan01 Feb 15, 2024
4e53afa
Address several review comments
kovdan01 Feb 15, 2024
ec1c632
Address review comments
kovdan01 Feb 17, 2024
2136ad1
Simplify RelocationScanner::processAux
MaskRay Feb 20, 2024
9ea8c5c
Fix error message in a read-only section when the symbol is local
MaskRay Feb 20, 2024
e3a64d2
Simplify aarch64-reloc-pauth.s
MaskRay Feb 20, 2024
865c983
Force dynamic relocation in -no-pie mode
MaskRay Feb 20, 2024
1448a4a
Address the following review comments:
kovdan01 Feb 27, 2024
203f61e
Use `relocs` instead of `relocsVec` inside `lock(relocMutex)` scope
kovdan01 Feb 28, 2024
1b8c52b
Allow arbitrary offset for dynamic section: no need to rely on it in …
kovdan01 Feb 28, 2024
e9b5337
Fix relocs with wide addends for non-preemptible symbols
kovdan01 Feb 28, 2024
aec9155
Merge branch 'main' into pauth-lld
kovdan01 Mar 8, 2024
b215b0d
Address review comments
kovdan01 Mar 8, 2024
90dbcf4
Merge branch 'main' into pauth-lld
kovdan01 Mar 18, 2024
d32b8e3
Address some review comments
kovdan01 Mar 18, 2024
978ed06
Use `.note.gnu.property` instead of `.note.AARCH64-PAUTH-ABI-tag`
kovdan01 Mar 18, 2024
ec04d8c
Merge branch 'main' into pauth-lld-new
kovdan01 Mar 19, 2024
728c933
Rename PAuth ABI Tag to PAuth ABI Core Info
kovdan01 Mar 19, 2024
4409838
Update comments
kovdan01 Mar 19, 2024
128831c
Rename PAuth ABI compatibility info to PAuth ABI core info
kovdan01 Mar 19, 2024
83eddae
Merge branch 'main' into pauth-lld & resolve conflict after 691b97c88…
kovdan01 Mar 25, 2024
08c749d
Merge branch 'main' into pauth-lld & fix conflict after 276335389133d…
kovdan01 Mar 29, 2024
e4a37a6
Merge branch 'main' into pauth-lld
kovdan01 Apr 2, 2024
05cf361
Delete RELR-related changes
kovdan01 Apr 2, 2024
eb02b6a
Merge branch 'main' into pauth-lld
kovdan01 Apr 3, 2024
f459527
Simplify a short/long message with just "invalid"
MaskRay Apr 3, 2024
2846e76
[test] add --implicit-check-not=error and avoid expensive .* regex
MaskRay Apr 3, 2024
45fcbb9
add release note
MaskRay Apr 3, 2024
0eb272a
Mention `R_AARCH64_AUTH_RELATIVE` in release notes
kovdan01 Apr 3, 2024
964e9fe
Add `-z pauth-report` description to lld's man page
kovdan01 Apr 3, 2024
2e8ec83
Remove unneeded blank line
kovdan01 Apr 3, 2024
99df511
Update test run line for `-z pauth-report`
kovdan01 Apr 3, 2024
b6e0e28
Merge branch 'main' into pauth-lld
kovdan01 Apr 4, 2024
cbc380a
Add single quotes around `referenceFileName`
kovdan01 Apr 4, 2024
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
5 changes: 5 additions & 0 deletions lld/ELF/Arch/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ RelExpr AArch64::getRelExpr(RelType type, const Symbol &s,
case R_AARCH64_MOVW_UABS_G2:
case R_AARCH64_MOVW_UABS_G2_NC:
case R_AARCH64_MOVW_UABS_G3:
case R_AARCH64_AUTH_ABS64:
return R_ABS;
case R_AARCH64_TLSDESC_ADR_PAGE21:
return R_AARCH64_TLSDESC_PAGE;
Expand Down Expand Up @@ -395,6 +396,10 @@ void AArch64::relocate(uint8_t *loc, const Relocation &rel,
case R_AARCH64_PREL64:
write64(loc, val);
break;
case R_AARCH64_AUTH_ABS64:
checkIntUInt(loc, val, 32, rel);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkIntUInt can be an assert(isInt<32>(val)) thanks to isInt<32>(sym.getVA(addend))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I just realize that this is related to isStaticLinkTimeConstant. See the main comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I just realized -no-pie was not handled properly, thanks for bringing attention to this. I've applied the commit 865c983 from your branch, thanks.

P.S. Code here becomes changed after e9b5337

write32(loc, val);
break;
case R_AARCH64_ADD_ABS_LO12_NC:
or32AArch64Imm(loc, val);
break;
Expand Down
4 changes: 4 additions & 0 deletions lld/ELF/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ struct Config {
llvm::StringRef cmseOutputLib;
StringRef zBtiReport = "none";
StringRef zCetReport = "none";
StringRef zPauthReport = "none";
llvm::StringRef ltoBasicBlockSections;
std::pair<llvm::StringRef, llvm::StringRef> thinLTOObjectSuffixReplace;
llvm::StringRef thinLTOPrefixReplaceOld;
Expand Down Expand Up @@ -275,6 +276,7 @@ struct Config {
bool relocatable;
bool relrGlibc = false;
bool relrPackDynRelocs = false;
bool relrPackAuthDynRelocs = false;
llvm::DenseSet<llvm::StringRef> saveTempsArgs;
llvm::SmallVector<std::pair<llvm::GlobPattern, uint32_t>, 0> shuffleSections;
bool singleRoRx;
Expand Down Expand Up @@ -492,6 +494,8 @@ struct Ctx {
void reset();

llvm::raw_fd_ostream openAuxiliaryFile(llvm::StringRef, std::error_code &);

SmallVector<uint8_t, 0> aarch64PauthAbiTag;
};

LLVM_LIBRARY_VISIBILITY extern Ctx ctx;
Expand Down
57 changes: 55 additions & 2 deletions lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cstdlib>
#include <tuple>
#include <utility>
Expand Down Expand Up @@ -459,6 +460,8 @@ static void checkOptions() {
error("-z force-bti only supported on AArch64");
if (config->zBtiReport != "none")
error("-z bti-report only supported on AArch64");
if (config->zPauthReport != "none")
error("-z pauth-report only supported on AArch64");
MaskRay marked this conversation as resolved.
Show resolved Hide resolved
}

if (config->emachine != EM_386 && config->emachine != EM_X86_64 &&
Expand Down Expand Up @@ -558,6 +561,7 @@ constexpr const char *knownZFlags[] = {
"nognustack",
"nokeep-text-section-prefix",
"nopack-relative-relocs",
"nopack-relative-auth-relocs",
"norelro",
"noseparate-code",
"nostart-stop-gc",
Expand All @@ -566,6 +570,7 @@ constexpr const char *knownZFlags[] = {
"origin",
"pac-plt",
"pack-relative-relocs",
"pack-relative-auth-relocs",
MaskRay marked this conversation as resolved.
Show resolved Hide resolved
"rel",
"rela",
"relro",
Expand All @@ -583,7 +588,7 @@ constexpr const char *knownZFlags[] = {
static bool isKnownZFlag(StringRef s) {
return llvm::is_contained(knownZFlags, s) ||
s.starts_with("common-page-size=") || s.starts_with("bti-report=") ||
s.starts_with("cet-report=") ||
s.starts_with("cet-report=") || s.starts_with("pauth-report=") ||
s.starts_with("dead-reloc-in-nonalloc=") ||
s.starts_with("max-page-size=") || s.starts_with("stack-size=") ||
s.starts_with("start-stop-visibility=");
Expand Down Expand Up @@ -1514,7 +1519,8 @@ static void readConfigs(opt::InputArgList &args) {
}

auto reports = {std::make_pair("bti-report", &config->zBtiReport),
std::make_pair("cet-report", &config->zCetReport)};
std::make_pair("cet-report", &config->zCetReport),
std::make_pair("pauth-report", &config->zPauthReport)};
for (opt::Arg *arg : args.filtered(OPT_z)) {
std::pair<StringRef, StringRef> option =
StringRef(arg->getValue()).split('=');
Expand Down Expand Up @@ -1671,6 +1677,9 @@ static void readConfigs(opt::InputArgList &args) {
getPackDynRelocs(args);
}

config->relrPackAuthDynRelocs = getZFlag(
args, "pack-relative-auth-relocs", "nopack-relative-auth-relocs", false);

if (auto *arg = args.getLastArg(OPT_symbol_ordering_file)){
if (args.hasArg(OPT_call_graph_ordering_file))
error("--symbol-ordering-file and --call-graph-order-file "
Expand Down Expand Up @@ -2639,6 +2648,47 @@ static uint32_t getAndFeatures() {
return ret;
}

static void getAarch64PauthInfo() {
if (ctx.objectFiles.empty())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete redundant empty check

Copy link
Contributor Author

@kovdan01 kovdan01 Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted, thanks, see aff3a96

return;

auto NonEmptyIt = std::find_if(
ctx.objectFiles.begin(), ctx.objectFiles.end(),
[](const ELFFileBase *f) { return !f->aarch64PauthAbiTag.empty(); });
if (NonEmptyIt == ctx.objectFiles.end())
MaskRay marked this conversation as resolved.
Show resolved Hide resolved
return;

ctx.aarch64PauthAbiTag = (*NonEmptyIt)->aarch64PauthAbiTag;
StringRef F1 = (*NonEmptyIt)->getName();
for (ELFFileBase *F : ArrayRef(ctx.objectFiles)) {
MaskRay marked this conversation as resolved.
Show resolved Hide resolved
StringRef F2 = F->getName();
const SmallVector<uint8_t, 0> &D1 = ctx.aarch64PauthAbiTag;
const SmallVector<uint8_t, 0> &D2 = F->aarch64PauthAbiTag;
if (D1.empty() != D2.empty()) {
auto Helper = [](StringRef Report, const Twine &Msg) {
if (Report == "warning")
warn(Msg);
else if (Report == "error")
error(Msg);
};

Helper(config->zPauthReport,
(D1.empty() ? F1.str() : F2.str()) +
" has no AArch64 PAuth compatibility info while " +
(D1.empty() ? F2.str() : F1.str()) +
" has one; either all or no input files must have it");
}

if (!D1.empty() && !D2.empty() &&
!std::equal(D1.begin(), D1.end(), D2.begin(), D2.end()))
errorOrWarn(
"incompatible values of AArch64 PAuth compatibility info found"
"\n" +
F1 + ": 0x" + toHex(ArrayRef(D1.data(), D1.size())) + "\n" + F2 +
": 0x" + toHex(ArrayRef(D2.data(), D2.size())));
}
}

static void initSectionsAndLocalSyms(ELFFileBase *file, bool ignoreComdats) {
switch (file->ekind) {
case ELF32LEKind:
Expand Down Expand Up @@ -2976,6 +3026,9 @@ void LinkerDriver::link(opt::InputArgList &args) {
// contain a hint to tweak linker's and loader's behaviors.
config->andFeatures = getAndFeatures();

if (config->emachine == EM_AARCH64)
getAarch64PauthInfo();
MaskRay marked this conversation as resolved.
Show resolved Hide resolved

// The Target instance handles target-specific stuff, such as applying
// relocations or writing a PLT section. It also contains target-dependent
// values such as a default image base address.
Expand Down
44 changes: 44 additions & 0 deletions lld/ELF/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,44 @@ template <class ELFT> static uint32_t readAndFeatures(const InputSection &sec) {
return featuresSet;
}

// Extract compatibility info for aarch64 pointer authentication from the
// .note.AARCH64-PAUTH-ABI-tag section and write it to the corresponding ObjFile
// field. See the following ABI documentation:
// https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#elf-marking
template <class ELFT>
static void readAArch64PauthAbiTag(const InputSection &sec, ObjFile<ELFT> &f) {
using Elf_Nhdr = typename ELFT::Nhdr;
using Elf_Note = typename ELFT::Note;
ArrayRef<uint8_t> data = sec.content();
auto reportError = [&](const Twine &msg) {
errorOrWarn(toString(sec.file) + ":(" + sec.name + "): " + msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unneeded helper. Just use lld::toString(const InputSectionBase *sec)

Copy link
Contributor Author

@kovdan01 kovdan01 Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks, see 4e53afa

};

auto *nhdr = reinterpret_cast<const Elf_Nhdr *>(data.data());
if (data.size() < sizeof(Elf_Nhdr) ||
data.size() < nhdr->getSize(sec.addralign)) {
reportError("section is too short");
return;
}

Elf_Note note(*nhdr);
if (nhdr->n_type != NT_ARM_TYPE_PAUTH_ABI_TAG)
reportError("invalid type field value " + Twine(nhdr->n_type) + " (" +
Twine(NT_ARM_TYPE_PAUTH_ABI_TAG) + " expected)");
if (note.getName() != "ARM")
reportError("invalid name field value " + note.getName() +
" (ARM expected)");

ArrayRef<uint8_t> desc = note.getDesc(sec.addralign);
if (desc.size() < 16) {
reportError("too short AArch64 PAuth compatibility info "
MaskRay marked this conversation as resolved.
Show resolved Hide resolved
"(at least 16 bytes expected)");
return;
}

f.aarch64PauthAbiTag = SmallVector<uint8_t, 0>(iterator_range(desc));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change aarch64PauthAbiTag to an ArrayRef<uint8_t> to save memory

Copy link
Contributor Author

@kovdan01 kovdan01 Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed both in ELFFileBase and Ctx, thanks, see aff3a96

}

template <class ELFT>
InputSectionBase *ObjFile<ELFT>::getRelocTarget(uint32_t idx,
const Elf_Shdr &sec,
Expand Down Expand Up @@ -1020,6 +1058,12 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx,
return &InputSection::discarded;
}

if (config->emachine == EM_AARCH64 &&
name == ".note.AARCH64-PAUTH-ABI-tag") {
readAArch64PauthAbiTag<ELFT>(InputSection(*this, sec, name), *this);
return &InputSection::discarded;
}

// Split stacks is a feature to support a discontiguous stack,
// commonly used in the programming language Go. For the details,
// see https://gcc.gnu.org/wiki/SplitStacks. An object file compiled
Expand Down
1 change: 1 addition & 0 deletions lld/ELF/InputFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class ELFFileBase : public InputFile {
public:
uint32_t andFeatures = 0;
bool hasCommonSyms = false;
SmallVector<uint8_t, 0> aarch64PauthAbiTag;
};

// .o file.
Expand Down
26 changes: 26 additions & 0 deletions lld/ELF/Relocations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,32 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
}
}

if (config->emachine == EM_AARCH64 && type == R_AARCH64_AUTH_ABS64) {
// Assume relocations from relocatable objects are RELA.
assert(RelTy::IsRela);
std::lock_guard<std::mutex> lock(relocMutex);
// For a preemptible symbol, we can't use a relative relocation. For an
// undefined symbol, we can't compute offset at link-time and use a relative
// relocation. Use a symbolic relocation instead.
Partition &part = sec->getPartition();
if (sym.isPreemptible || sym.isUndefined()) {
part.relaDyn->addSymbolReloc(type, *sec, offset, sym, addend, type);
} else if (part.relrAuthDyn && sec->addralign >= 2 && offset % 2 == 0 &&
isInt<32>(sym.getVA(addend))) {
// Implicit addend is below 32-bits so we can use the compressed
// relative relocation section. The R_AARCH64_AUTH_RELATIVE
// has a smaller addend fielf as bits [63:32] encode the signing-schema.
sec->addReloc({expr, type, offset, addend, &sym});
part.relrAuthDyn->relocsVec[parallel::getThreadIndex()].push_back(
{sec, offset});
} else {
part.relaDyn->addReloc({R_AARCH64_AUTH_RELATIVE, sec, offset,
DynamicReloc::AddendOnlyWithTargetVA, sym, addend,
R_ABS});
}
return;
}

MaskRay marked this conversation as resolved.
Show resolved Hide resolved
// If the relocation does not emit a GOT or GOTPLT entry but its computation
// uses their addresses, we need GOT or GOTPLT to be created.
//
Expand Down
44 changes: 38 additions & 6 deletions lld/ELF/SyntheticSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,29 @@ void GnuPropertySection::writeTo(uint8_t *buf) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks, see 2e8ec83

size_t GnuPropertySection::getSize() const { return config->is64 ? 32 : 28; }

AArch64PauthAbiTag::AArch64PauthAbiTag()
: SyntheticSection(llvm::ELF::SHF_ALLOC, llvm::ELF::SHT_NOTE,
config->wordsize, ".note.AARCH64-PAUTH-ABI-tag") {}

bool AArch64PauthAbiTag::isNeeded() const {
return !ctx.aarch64PauthAbiTag.empty();
}

void AArch64PauthAbiTag::writeTo(uint8_t *buf) {
const SmallVector<uint8_t, 0> &data = ctx.aarch64PauthAbiTag;
write32(buf, 4); // Name size
write32(buf + 4, data.size()); // Content size
write32(buf + 8, NT_ARM_TYPE_PAUTH_ABI_TAG); // Type
memcpy(buf + 12, "ARM", 4); // Name string
memcpy(buf + 16, data.data(), data.size());
memset(buf + 16 + data.size(), 0, getSize() - 16 - data.size()); // Padding
}

size_t AArch64PauthAbiTag::getSize() const {
return alignToPowerOf2(16 + ctx.aarch64PauthAbiTag.size(),
config->is64 ? 8 : 4);
}

BuildIdSection::BuildIdSection()
: SyntheticSection(SHF_ALLOC, SHT_NOTE, 4, ".note.gnu.build-id"),
hashSize(getHashSize()) {}
Expand Down Expand Up @@ -1406,6 +1429,12 @@ DynamicSection<ELFT>::computeContents() {
addInt(config->useAndroidRelrTags ? DT_ANDROID_RELRENT : DT_RELRENT,
sizeof(Elf_Relr));
}
if (part.relrAuthDyn && part.relrAuthDyn->getParent() &&
!part.relrAuthDyn->relocs.empty()) {
addInSec(DT_AARCH64_AUTH_RELR, *part.relrAuthDyn);
addInt(DT_AARCH64_AUTH_RELRSZ, part.relrAuthDyn->getParent()->size);
addInt(DT_AARCH64_AUTH_RELRENT, sizeof(Elf_Relr));
}
// .rel[a].plt section usually consists of two parts, containing plt and
// iplt relocations. It is possible to have only iplt relocations in the
// output. In that case relaPlt is empty and have zero offset, the same offset
Expand Down Expand Up @@ -1717,10 +1746,13 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *buf) {
}
}

RelrBaseSection::RelrBaseSection(unsigned concurrency)
: SyntheticSection(SHF_ALLOC,
config->useAndroidRelrTags ? SHT_ANDROID_RELR : SHT_RELR,
config->wordsize, ".relr.dyn"),
RelrBaseSection::RelrBaseSection(unsigned concurrency, bool isAArch64Auth)
: SyntheticSection(
SHF_ALLOC,
isAArch64Auth
? SHT_AARCH64_AUTH_RELR
: (config->useAndroidRelrTags ? SHT_ANDROID_RELR : SHT_RELR),
config->wordsize, isAArch64Auth ? ".relr.auth.dyn" : ".relr.dyn"),
relocsVec(concurrency) {}

void RelrBaseSection::mergeRels() {
Expand Down Expand Up @@ -1988,8 +2020,8 @@ bool AndroidPackedRelocationSection<ELFT>::updateAllocSize() {
}

template <class ELFT>
RelrSection<ELFT>::RelrSection(unsigned concurrency)
: RelrBaseSection(concurrency) {
RelrSection<ELFT>::RelrSection(unsigned concurrency, bool isAArch64Auth)
: RelrBaseSection(concurrency, isAArch64Auth) {
this->entsize = config->wordsize;
}

Expand Down
19 changes: 16 additions & 3 deletions lld/ELF/SyntheticSections.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ class GnuPropertySection final : public SyntheticSection {
size_t getSize() const override;
};

// .note.AARCH64-PAUTH-ABI-tag section. See
// https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#elf-marking
class AArch64PauthAbiTag final : public SyntheticSection {
public:
AArch64PauthAbiTag();
void writeTo(uint8_t *buf) override;
size_t getSize() const override;
bool isNeeded() const override;
};

// .note.gnu.build-id section.
class BuildIdSection : public SyntheticSection {
// First 16 bytes are a header.
Expand Down Expand Up @@ -543,7 +553,8 @@ class RelocationBaseSection : public SyntheticSection {
static bool classof(const SectionBase *d) {
return SyntheticSection::classof(d) &&
(d->type == llvm::ELF::SHT_RELA || d->type == llvm::ELF::SHT_REL ||
d->type == llvm::ELF::SHT_RELR);
d->type == llvm::ELF::SHT_RELR ||
d->type == llvm::ELF::SHT_AARCH64_AUTH_RELR);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHT_AARCH64_AUTH_RELR needs a emachine check.

Copy link
Contributor Author

@kovdan01 kovdan01 Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, thanks, see de73eae

}
int32_t dynamicTag, sizeDynamicTag;
SmallVector<DynamicReloc, 0> relocs;
Expand Down Expand Up @@ -599,7 +610,7 @@ struct RelativeReloc {

class RelrBaseSection : public SyntheticSection {
public:
RelrBaseSection(unsigned concurrency);
RelrBaseSection(unsigned concurrency, bool isAArch64Auth = false);
void mergeRels();
bool isNeeded() const override {
return !relocs.empty() ||
Expand All @@ -617,7 +628,7 @@ template <class ELFT> class RelrSection final : public RelrBaseSection {
using Elf_Relr = typename ELFT::Relr;

public:
RelrSection(unsigned concurrency);
RelrSection(unsigned concurrency, bool isAArch64Auth = false);

bool updateAllocSize() override;
size_t getSize() const override { return relrRelocs.size() * this->entsize; }
Expand Down Expand Up @@ -1319,6 +1330,7 @@ struct Partition {
std::unique_ptr<PackageMetadataNote> packageMetadataNote;
std::unique_ptr<RelocationBaseSection> relaDyn;
std::unique_ptr<RelrBaseSection> relrDyn;
std::unique_ptr<RelrBaseSection> relrAuthDyn;
std::unique_ptr<VersionDefinitionSection> verDef;
std::unique_ptr<SyntheticSection> verNeed;
std::unique_ptr<VersionTableSection> verSym;
Expand Down Expand Up @@ -1363,6 +1375,7 @@ struct InStruct {
std::unique_ptr<StringTableSection> strTab;
std::unique_ptr<SymbolTableBaseSection> symTab;
std::unique_ptr<SymtabShndxSection> symTabShndx;
std::unique_ptr<AArch64PauthAbiTag> aarch64PauthAbiTag;

void reset();
};
Expand Down
Loading