[PATCH] D148208: [llvm-readobj] fix unit test failure on 32bit machines

David Spickett via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 09:28:54 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGbdbe15f72983: [llvm-readobj] fix unit test failure on 32bit machines (authored by antmo, committed by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148208/new/

https://reviews.llvm.org/D148208

Files:
  llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test
  llvm/tools/llvm-readobj/ELFDumper.cpp


Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -221,7 +221,7 @@
   void printArchSpecificInfo() override;
   void printStackMap() const override;
   void printMemtag() override;
-  ArrayRef<uint8_t> getMemtagGlobalsSectionContents(uintptr_t ExpectedAddr);
+  ArrayRef<uint8_t> 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 <class ELFT>
 ArrayRef<uint8_t>
-ELFDumper<ELFT>::getMemtagGlobalsSectionContents(uintptr_t ExpectedAddr) {
+ELFDumper<ELFT>::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 <typename ELFT> void ELFDumper<ELFT>::printMemtag() {
   if (Obj.getHeader().e_machine != EM_AARCH64) return;
   std::vector<std::pair<std::string, std::string>> 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) {
Index: llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test
===================================================================
--- llvm/test/tools/llvm-readobj/ELF/AArch64/memtag.test
+++ 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.
 #########################################


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148208.513281.patch
Type: text/x-patch
Size: 2743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230413/cd75ab58/attachment.bin>


More information about the llvm-commits mailing list