[lld] [NFC] [lld] [MTE] Rename MemtagDescriptors to MemtagGlobalDescriptors (PR #77300)
Mitch Phillips via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 8 04:58:10 PST 2024
https://github.com/hctim updated https://github.com/llvm/llvm-project/pull/77300
>From e463c850851384b0f75939243f9ad5d64455cc1e Mon Sep 17 00:00:00 2001
From: Mitch Phillips <mitchp at google.com>
Date: Mon, 8 Jan 2024 13:17:39 +0100
Subject: [PATCH 1/2] [NFC] [lld] [MTE] Rename MemtagDescriptors to
MemtagGlobalDescriptors
Requested in https://github.com/llvm/llvm-project/pull/77078, I agree
that we may as well be unambiguous.
---
lld/ELF/Relocations.cpp | 2 +-
lld/ELF/SyntheticSections.cpp | 18 +++++++++---------
lld/ELF/SyntheticSections.h | 6 +++---
lld/ELF/Writer.cpp | 8 ++++----
4 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 210b4d1eb1a7a6..07de69fb5318ce 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1669,7 +1669,7 @@ void elf::postScanRelocations() {
return;
if (sym.isTagged() && sym.isDefined())
- mainPart->memtagDescriptors->addSymbol(sym);
+ mainPart->memtagGlobalDescriptors->addSymbol(sym);
if (!sym.needsDynReloc())
return;
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 19fced5aff9221..b0bcb6178f2ba0 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1454,9 +1454,9 @@ DynamicSection<ELFT>::computeContents() {
addInt(DT_AARCH64_MEMTAG_MODE, config->androidMemtagMode == NT_MEMTAG_LEVEL_ASYNC);
addInt(DT_AARCH64_MEMTAG_HEAP, config->androidMemtagHeap);
addInt(DT_AARCH64_MEMTAG_STACK, config->androidMemtagStack);
- if (mainPart->memtagDescriptors->isNeeded()) {
- addInSec(DT_AARCH64_MEMTAG_GLOBALS, *mainPart->memtagDescriptors);
- addInt(DT_AARCH64_MEMTAG_GLOBALSSZ, mainPart->memtagDescriptors->getSize());
+ if (mainPart->memtagGlobalDescriptors->isNeeded()) {
+ addInSec(DT_AARCH64_MEMTAG_GLOBALS, *mainPart->memtagGlobalDescriptors);
+ addInt(DT_AARCH64_MEMTAG_GLOBALSSZ, mainPart->memtagGlobalDescriptors->getSize());
}
}
}
@@ -3919,7 +3919,7 @@ static size_t computeOrWriteULEB128(uint64_t v, uint8_t *buf, size_t offset) {
// https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst#83encoding-of-sht_aarch64_memtag_globals_dynamic
constexpr uint64_t kMemtagStepSizeBits = 3;
constexpr uint64_t kMemtagGranuleSize = 16;
-static size_t createMemtagDescriptors(const SmallVector<const Symbol *, 0> &symbols,
+static size_t createMemtagGlobalDescriptors(const SmallVector<const Symbol *, 0> &symbols,
uint8_t *buf = nullptr) {
size_t sectionSize = 0;
uint64_t lastGlobalEnd = 0;
@@ -3961,7 +3961,7 @@ static size_t createMemtagDescriptors(const SmallVector<const Symbol *, 0> &symb
return sectionSize;
}
-bool MemtagDescriptors::updateAllocSize() {
+bool MemtagGlobalDescriptors::updateAllocSize() {
size_t oldSize = getSize();
std::stable_sort(symbols.begin(), symbols.end(),
[](const Symbol *s1, const Symbol *s2) {
@@ -3970,12 +3970,12 @@ bool MemtagDescriptors::updateAllocSize() {
return oldSize != getSize();
}
-void MemtagDescriptors::writeTo(uint8_t *buf) {
- createMemtagDescriptors(symbols, buf);
+void MemtagGlobalDescriptors::writeTo(uint8_t *buf) {
+ createMemtagGlobalDescriptors(symbols, buf);
}
-size_t MemtagDescriptors::getSize() const {
- return createMemtagDescriptors(symbols);
+size_t MemtagGlobalDescriptors::getSize() const {
+ return createMemtagGlobalDescriptors(symbols);
}
InStruct elf::in;
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 3a9f4ba886f6bb..7882ad87c241d7 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -1257,9 +1257,9 @@ class PackageMetadataNote final : public SyntheticSection {
size_t getSize() const override;
};
-class MemtagDescriptors final : public SyntheticSection {
+class MemtagGlobalDescriptors final : public SyntheticSection {
public:
- MemtagDescriptors()
+ MemtagGlobalDescriptors()
: SyntheticSection(llvm::ELF::SHF_ALLOC,
llvm::ELF::SHT_AARCH64_MEMTAG_GLOBALS_DYNAMIC,
/*alignment=*/4, ".memtag.globals.dynamic") {}
@@ -1315,7 +1315,7 @@ struct Partition {
std::unique_ptr<GnuHashTableSection> gnuHashTab;
std::unique_ptr<HashTableSection> hashTab;
std::unique_ptr<MemtagAndroidNote> memtagAndroidNote;
- std::unique_ptr<MemtagDescriptors> memtagDescriptors;
+ std::unique_ptr<MemtagGlobalDescriptors> memtagGlobalDescriptors;
std::unique_ptr<PackageMetadataNote> packageMetadataNote;
std::unique_ptr<RelocationBaseSection> relaDyn;
std::unique_ptr<RelrBaseSection> relrDyn;
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 7b9880a034bc51..9cb98d5b517056 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -405,8 +405,8 @@ template <class ELFT> void elf::createSyntheticSections() {
part.memtagAndroidNote = std::make_unique<MemtagAndroidNote>();
add(*part.memtagAndroidNote);
if (canHaveMemtagGlobals()) {
- part.memtagDescriptors = std::make_unique<MemtagDescriptors>();
- add(*part.memtagDescriptors);
+ part.memtagGlobalDescriptors = std::make_unique<MemtagGlobalDescriptors>();
+ add(*part.memtagGlobalDescriptors);
}
}
@@ -1731,8 +1731,8 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
changed |= part.relaDyn->updateAllocSize();
if (part.relrDyn)
changed |= part.relrDyn->updateAllocSize();
- if (part.memtagDescriptors)
- changed |= part.memtagDescriptors->updateAllocSize();
+ if (part.memtagGlobalDescriptors)
+ changed |= part.memtagGlobalDescriptors->updateAllocSize();
}
const Defined *changedSym = script->assignAddresses();
>From b6229f4ec6c919dbd57098158eb77392bd5b1613 Mon Sep 17 00:00:00 2001
From: Mitch Phillips <mitchp at google.com>
Date: Mon, 8 Jan 2024 13:57:52 +0100
Subject: [PATCH 2/2] clang-format
---
lld/ELF/SyntheticSections.cpp | 8 +++++---
lld/ELF/Writer.cpp | 3 ++-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index b0bcb6178f2ba0..1c1b0ee2f9c8cd 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1456,7 +1456,8 @@ DynamicSection<ELFT>::computeContents() {
addInt(DT_AARCH64_MEMTAG_STACK, config->androidMemtagStack);
if (mainPart->memtagGlobalDescriptors->isNeeded()) {
addInSec(DT_AARCH64_MEMTAG_GLOBALS, *mainPart->memtagGlobalDescriptors);
- addInt(DT_AARCH64_MEMTAG_GLOBALSSZ, mainPart->memtagGlobalDescriptors->getSize());
+ addInt(DT_AARCH64_MEMTAG_GLOBALSSZ,
+ mainPart->memtagGlobalDescriptors->getSize());
}
}
}
@@ -3919,8 +3920,9 @@ static size_t computeOrWriteULEB128(uint64_t v, uint8_t *buf, size_t offset) {
// https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst#83encoding-of-sht_aarch64_memtag_globals_dynamic
constexpr uint64_t kMemtagStepSizeBits = 3;
constexpr uint64_t kMemtagGranuleSize = 16;
-static size_t createMemtagGlobalDescriptors(const SmallVector<const Symbol *, 0> &symbols,
- uint8_t *buf = nullptr) {
+static size_t
+createMemtagGlobalDescriptors(const SmallVector<const Symbol *, 0> &symbols,
+ uint8_t *buf = nullptr) {
size_t sectionSize = 0;
uint64_t lastGlobalEnd = 0;
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 9cb98d5b517056..dfec5e07301a74 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -405,7 +405,8 @@ template <class ELFT> void elf::createSyntheticSections() {
part.memtagAndroidNote = std::make_unique<MemtagAndroidNote>();
add(*part.memtagAndroidNote);
if (canHaveMemtagGlobals()) {
- part.memtagGlobalDescriptors = std::make_unique<MemtagGlobalDescriptors>();
+ part.memtagGlobalDescriptors =
+ std::make_unique<MemtagGlobalDescriptors>();
add(*part.memtagGlobalDescriptors);
}
}
More information about the llvm-commits
mailing list