[NFC] [lld] [MTE] Rename MemtagDescriptors to MemtagGlobalDescriptors (#77300)
Requested in https://github.com/llvm/llvm-project/pull/77078, I agree
that we may as well be unambiguous.
GitOrigin-RevId: b399c8407351a8fce7313d6ecd6510cb04e94d8f
diff --git a/ELF/Relocations.cpp b/ELF/Relocations.cpp
index 9eb2e82..20eb02b 100644
--- a/ELF/Relocations.cpp
+++ b/ELF/Relocations.cpp
@@ -1669,7 +1669,7 @@
return;
if (sym.isTagged() && sym.isDefined())
- mainPart->memtagDescriptors->addSymbol(sym);
+ mainPart->memtagGlobalDescriptors->addSymbol(sym);
if (!sym.needsDynReloc())
return;
diff --git a/ELF/SyntheticSections.cpp b/ELF/SyntheticSections.cpp
index 19fced5..1c1b0ee 100644
--- a/ELF/SyntheticSections.cpp
+++ b/ELF/SyntheticSections.cpp
@@ -1454,9 +1454,10 @@
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,8 +3920,9 @@
// 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,
- 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;
@@ -3961,7 +3963,7 @@
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 +3972,12 @@
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/ELF/SyntheticSections.h b/ELF/SyntheticSections.h
index 3a9f4ba..7882ad8 100644
--- a/ELF/SyntheticSections.h
+++ b/ELF/SyntheticSections.h
@@ -1257,9 +1257,9 @@
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 @@
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/ELF/Writer.cpp b/ELF/Writer.cpp
index 7b9880a..dfec5e0 100644
--- a/ELF/Writer.cpp
+++ b/ELF/Writer.cpp
@@ -405,8 +405,9 @@
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 +1732,8 @@
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();