diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 9eb2e82542d3d..20eb02b879844 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 19fced5aff922..1c1b0ee2f9c8c 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1454,9 +1454,10 @@ DynamicSection::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,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 createMemtagDescriptors(const SmallVector &symbols, - uint8_t *buf = nullptr) { +static size_t +createMemtagGlobalDescriptors(const SmallVector &symbols, + uint8_t *buf = nullptr) { size_t sectionSize = 0; uint64_t lastGlobalEnd = 0; @@ -3961,7 +3963,7 @@ static size_t createMemtagDescriptors(const SmallVector &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 +3972,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 3a9f4ba886f6b..7882ad87c241d 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 gnuHashTab; std::unique_ptr hashTab; std::unique_ptr memtagAndroidNote; - std::unique_ptr memtagDescriptors; + std::unique_ptr memtagGlobalDescriptors; std::unique_ptr packageMetadataNote; std::unique_ptr relaDyn; std::unique_ptr relrDyn; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 7b9880a034bc5..dfec5e07301a7 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -405,8 +405,9 @@ template void elf::createSyntheticSections() { part.memtagAndroidNote = std::make_unique(); add(*part.memtagAndroidNote); if (canHaveMemtagGlobals()) { - part.memtagDescriptors = std::make_unique(); - add(*part.memtagDescriptors); + part.memtagGlobalDescriptors = + std::make_unique(); + add(*part.memtagGlobalDescriptors); } } @@ -1731,8 +1732,8 @@ template void Writer::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();