diff --git a/llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test b/llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test --- a/llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test +++ b/llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test @@ -306,6 +306,19 @@ # SIZE-MISMATCH: warning: {{.*}} mismatch between DT_AARCH64_MEMTAG_GLOBALSSZ (0x1337) and # SIZE-MISMATCH-SAME: SHT_AARCH64_MEMTAG_GLOBALS_DYNAMIC section size (0xa) +######################################### +## Ensure that GLOBALSSZ tag is stored in a 64-bit integer even on 32-bit machines. +######################################### + +# RUN: yaml2obj --docnum=3 %s -o %t \ +# RUN: -D DT_AARCH64_MEMTAG_GLOBALSSZ=0x100000001 \ +# RUN: -D GLOBALS_SECTION_CONTENTS=11 +# RUN: llvm-readelf --memtag %t 2>&1 | FileCheck %s --check-prefixes=SIZE-MISMATCH2 +# RUN: llvm-readobj --memtag %t 2>&1 | FileCheck %s --check-prefixes=SIZE-MISMATCH2 + +# SIZE-MISMATCH2: warning: {{.*}} mismatch between DT_AARCH64_MEMTAG_GLOBALSSZ (0x100000001) and +# SIZE-MISMATCH2-SAME: SHT_AARCH64_MEMTAG_GLOBALS_DYNAMIC section size (0x1) + ######################################### ## Ensure that we fail if DT_AARCH64_MEMTAG_GLOBALS doesn't agree with the address of the section. ######################################### diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -221,7 +221,7 @@ void printArchSpecificInfo() override; void printStackMap() const override; void printMemtag() override; - ArrayRef getMemtagGlobalsSectionContents(uintptr_t ExpectedAddr); + ArrayRef getMemtagGlobalsSectionContents(uint64_t ExpectedAddr); // Hash histogram shows statistics of how efficient the hash was for the // dynamic symbol table. The table shows the number of hash buckets for @@ -5977,7 +5977,7 @@ template ArrayRef -ELFDumper::getMemtagGlobalsSectionContents(uintptr_t ExpectedAddr) { +ELFDumper::getMemtagGlobalsSectionContents(uint64_t ExpectedAddr) { for (const typename ELFT::Shdr &Sec : cantFail(Obj.sections())) { if (Sec.sh_type != SHT_AARCH64_MEMTAG_GLOBALS_DYNAMIC) continue; @@ -6010,8 +6010,8 @@ template void ELFDumper::printMemtag() { if (Obj.getHeader().e_machine != EM_AARCH64) return; std::vector> DynamicEntries; - size_t MemtagGlobalsSz = 0; - uintptr_t MemtagGlobals = 0; + uint64_t MemtagGlobalsSz = 0; + uint64_t MemtagGlobals = 0; for (const typename ELFT::Dyn &Entry : dynamic_table()) { uintX_t Tag = Entry.getTag(); switch (Tag) {