Skip to content

Commit b399c84

Browse files
authored
[NFC] [lld] [MTE] Rename MemtagDescriptors to MemtagGlobalDescriptors (#77300)
Requested in #77078, I agree that we may as well be unambiguous.
1 parent b59b8d4 commit b399c84

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

lld/ELF/Relocations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ void elf::postScanRelocations() {
16691669
return;
16701670

16711671
if (sym.isTagged() && sym.isDefined())
1672-
mainPart->memtagDescriptors->addSymbol(sym);
1672+
mainPart->memtagGlobalDescriptors->addSymbol(sym);
16731673

16741674
if (!sym.needsDynReloc())
16751675
return;

lld/ELF/SyntheticSections.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,9 +1454,10 @@ DynamicSection<ELFT>::computeContents() {
14541454
addInt(DT_AARCH64_MEMTAG_MODE, config->androidMemtagMode == NT_MEMTAG_LEVEL_ASYNC);
14551455
addInt(DT_AARCH64_MEMTAG_HEAP, config->androidMemtagHeap);
14561456
addInt(DT_AARCH64_MEMTAG_STACK, config->androidMemtagStack);
1457-
if (mainPart->memtagDescriptors->isNeeded()) {
1458-
addInSec(DT_AARCH64_MEMTAG_GLOBALS, *mainPart->memtagDescriptors);
1459-
addInt(DT_AARCH64_MEMTAG_GLOBALSSZ, mainPart->memtagDescriptors->getSize());
1457+
if (mainPart->memtagGlobalDescriptors->isNeeded()) {
1458+
addInSec(DT_AARCH64_MEMTAG_GLOBALS, *mainPart->memtagGlobalDescriptors);
1459+
addInt(DT_AARCH64_MEMTAG_GLOBALSSZ,
1460+
mainPart->memtagGlobalDescriptors->getSize());
14601461
}
14611462
}
14621463
}
@@ -3919,8 +3920,9 @@ static size_t computeOrWriteULEB128(uint64_t v, uint8_t *buf, size_t offset) {
39193920
// https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst#83encoding-of-sht_aarch64_memtag_globals_dynamic
39203921
constexpr uint64_t kMemtagStepSizeBits = 3;
39213922
constexpr uint64_t kMemtagGranuleSize = 16;
3922-
static size_t createMemtagDescriptors(const SmallVector<const Symbol *, 0> &symbols,
3923-
uint8_t *buf = nullptr) {
3923+
static size_t
3924+
createMemtagGlobalDescriptors(const SmallVector<const Symbol *, 0> &symbols,
3925+
uint8_t *buf = nullptr) {
39243926
size_t sectionSize = 0;
39253927
uint64_t lastGlobalEnd = 0;
39263928

@@ -3961,7 +3963,7 @@ static size_t createMemtagDescriptors(const SmallVector<const Symbol *, 0> &symb
39613963
return sectionSize;
39623964
}
39633965

3964-
bool MemtagDescriptors::updateAllocSize() {
3966+
bool MemtagGlobalDescriptors::updateAllocSize() {
39653967
size_t oldSize = getSize();
39663968
std::stable_sort(symbols.begin(), symbols.end(),
39673969
[](const Symbol *s1, const Symbol *s2) {
@@ -3970,12 +3972,12 @@ bool MemtagDescriptors::updateAllocSize() {
39703972
return oldSize != getSize();
39713973
}
39723974

3973-
void MemtagDescriptors::writeTo(uint8_t *buf) {
3974-
createMemtagDescriptors(symbols, buf);
3975+
void MemtagGlobalDescriptors::writeTo(uint8_t *buf) {
3976+
createMemtagGlobalDescriptors(symbols, buf);
39753977
}
39763978

3977-
size_t MemtagDescriptors::getSize() const {
3978-
return createMemtagDescriptors(symbols);
3979+
size_t MemtagGlobalDescriptors::getSize() const {
3980+
return createMemtagGlobalDescriptors(symbols);
39793981
}
39803982

39813983
InStruct elf::in;

lld/ELF/SyntheticSections.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,9 +1257,9 @@ class PackageMetadataNote final : public SyntheticSection {
12571257
size_t getSize() const override;
12581258
};
12591259

1260-
class MemtagDescriptors final : public SyntheticSection {
1260+
class MemtagGlobalDescriptors final : public SyntheticSection {
12611261
public:
1262-
MemtagDescriptors()
1262+
MemtagGlobalDescriptors()
12631263
: SyntheticSection(llvm::ELF::SHF_ALLOC,
12641264
llvm::ELF::SHT_AARCH64_MEMTAG_GLOBALS_DYNAMIC,
12651265
/*alignment=*/4, ".memtag.globals.dynamic") {}
@@ -1315,7 +1315,7 @@ struct Partition {
13151315
std::unique_ptr<GnuHashTableSection> gnuHashTab;
13161316
std::unique_ptr<HashTableSection> hashTab;
13171317
std::unique_ptr<MemtagAndroidNote> memtagAndroidNote;
1318-
std::unique_ptr<MemtagDescriptors> memtagDescriptors;
1318+
std::unique_ptr<MemtagGlobalDescriptors> memtagGlobalDescriptors;
13191319
std::unique_ptr<PackageMetadataNote> packageMetadataNote;
13201320
std::unique_ptr<RelocationBaseSection> relaDyn;
13211321
std::unique_ptr<RelrBaseSection> relrDyn;

lld/ELF/Writer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,9 @@ template <class ELFT> void elf::createSyntheticSections() {
405405
part.memtagAndroidNote = std::make_unique<MemtagAndroidNote>();
406406
add(*part.memtagAndroidNote);
407407
if (canHaveMemtagGlobals()) {
408-
part.memtagDescriptors = std::make_unique<MemtagDescriptors>();
409-
add(*part.memtagDescriptors);
408+
part.memtagGlobalDescriptors =
409+
std::make_unique<MemtagGlobalDescriptors>();
410+
add(*part.memtagGlobalDescriptors);
410411
}
411412
}
412413

@@ -1731,8 +1732,8 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
17311732
changed |= part.relaDyn->updateAllocSize();
17321733
if (part.relrDyn)
17331734
changed |= part.relrDyn->updateAllocSize();
1734-
if (part.memtagDescriptors)
1735-
changed |= part.memtagDescriptors->updateAllocSize();
1735+
if (part.memtagGlobalDescriptors)
1736+
changed |= part.memtagGlobalDescriptors->updateAllocSize();
17361737
}
17371738

17381739
const Defined *changedSym = script->assignAddresses();

0 commit comments

Comments
 (0)