[lld] ee19eb3 - [ELF] Change some upper-case utohexstr to lower-case to improve consistency

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 29 18:37:53 PST 2024


Author: Fangrui Song
Date: 2024-11-29T18:37:47-08:00
New Revision: ee19eb3037c781361e6f82c524b500ed5f55be18

URL: https://github.com/llvm/llvm-project/commit/ee19eb3037c781361e6f82c524b500ed5f55be18
DIFF: https://github.com/llvm/llvm-project/commit/ee19eb3037c781361e6f82c524b500ed5f55be18.diff

LOG: [ELF] Change some upper-case utohexstr to lower-case to improve consistency

The convention is to use lower-case addresses.

Added: 
    

Modified: 
    lld/ELF/Arch/Hexagon.cpp
    lld/ELF/Arch/PPC64.cpp
    lld/ELF/OutputSections.cpp
    lld/ELF/Writer.cpp
    lld/test/ELF/linkerscript/i386-sections-max-va-overflow.s
    lld/test/ELF/linkerscript/locationcountererr-arm-exidx.test
    lld/test/ELF/linkerscript/sections-max-va-overflow.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp
index 3c6fe0daee6bd5..23b60672f6317e 100644
--- a/lld/ELF/Arch/Hexagon.cpp
+++ b/lld/ELF/Arch/Hexagon.cpp
@@ -199,7 +199,7 @@ static uint32_t findMaskR6(Ctx &ctx, uint32_t insn) {
       return i.relocMask;
 
   Err(ctx) << "unrecognized instruction for 6_X relocation: 0x"
-           << utohexstr(insn);
+           << utohexstr(insn, true);
   return 0;
 }
 

diff  --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp
index 8dd1735ee1e886..b55385625a1cf1 100644
--- a/lld/ELF/Arch/PPC64.cpp
+++ b/lld/ELF/Arch/PPC64.cpp
@@ -695,7 +695,7 @@ void PPC64::relaxGot(uint8_t *loc, const Relocation &rel, uint64_t val) const {
     if (pcRelInsn == UINT64_C(-1)) {
       Err(ctx)
           << "unrecognized instruction for R_PPC64_PCREL_OPT relaxation: 0x"
-          << Twine::utohexstr(accessInsn);
+          << utohexstr(accessInsn, true);
       break;
     }
 
@@ -1337,7 +1337,7 @@ void PPC64::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
       if (isInstructionUpdateForm(insn))
         Err(ctx) << getErrorLoc(ctx, loc)
                  << "can't toc-optimize an update instruction: 0x"
-                 << utohexstr(insn);
+                 << utohexstr(insn, true);
       writeFromHalf16(ctx, loc, (insn & 0xffe00000) | 0x00020000 | lo(val));
     } else {
       write16(ctx, loc, lo(val));
@@ -1356,8 +1356,8 @@ void PPC64::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
       // pointer register r2, as the base register.
       if (isInstructionUpdateForm(insn))
         Err(ctx) << getErrorLoc(ctx, loc)
-                 << "Can't toc-optimize an update instruction: 0x"
-                 << Twine::utohexstr(insn);
+                 << "can't toc-optimize an update instruction: 0x"
+                 << utohexstr(insn, true);
       insn &= 0xffe00000 | mask;
       writeFromHalf16(ctx, loc, insn | 0x00020000 | lo(val));
     } else {

diff  --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 31d14df9be71e9..546dc58b4bc843 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -155,9 +155,9 @@ void OutputSection::commitSection(InputSection *isec) {
     // Otherwise, check if new type or flags are compatible with existing ones.
     if ((flags ^ isec->flags) & SHF_TLS)
       ErrAlways(ctx) << "incompatible section flags for " << name << "\n>>> "
-                     << isec << ": 0x" << utohexstr(isec->flags)
+                     << isec << ": 0x" << utohexstr(isec->flags, true)
                      << "\n>>> output section " << name << ": 0x"
-                     << utohexstr(flags);
+                     << utohexstr(flags, true);
   }
 
   isec->parent = this;

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index a7fbdc07907044..f10cc54c05a0ca 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -2672,8 +2672,9 @@ template <class ELFT> void Writer<ELFT>::checkSections() {
   for (OutputSection *os : ctx.outputSections)
     if ((os->addr + os->size < os->addr) ||
         (!ELFT::Is64Bits && os->addr + os->size > uint64_t(UINT32_MAX) + 1))
-      Err(ctx) << "section " << os->name << " at 0x" << utohexstr(os->addr)
-               << " of size 0x" << utohexstr(os->size)
+      Err(ctx) << "section " << os->name << " at 0x"
+               << utohexstr(os->addr, true) << " of size 0x"
+               << utohexstr(os->size, true)
                << " exceeds available address space";
 
   // Check for overlapping file offsets. In this case we need to skip any

diff  --git a/lld/test/ELF/linkerscript/i386-sections-max-va-overflow.s b/lld/test/ELF/linkerscript/i386-sections-max-va-overflow.s
index 25bef1575cce6b..80b02be7dbb80b 100644
--- a/lld/test/ELF/linkerscript/i386-sections-max-va-overflow.s
+++ b/lld/test/ELF/linkerscript/i386-sections-max-va-overflow.s
@@ -7,7 +7,7 @@
 
 ## .bar section has data in [0xfffffff1, 0xfffffff1 + 0x10] == [0xfffffff1, 0x1].
 ## Check we can catch this overflow.
-# ERR: error: section .bar at 0xFFFFFFF1 of size 0x10 exceeds available address space
+# ERR: error: section .bar at 0xfffffff1 of size 0x10 exceeds available address space
 
 ## [0xfffffff1, 0x100000000) is allowed.
 # RUN: echo "SECTIONS { . = 0xfffffff0;" > %t.script

diff  --git a/lld/test/ELF/linkerscript/locationcountererr-arm-exidx.test b/lld/test/ELF/linkerscript/locationcountererr-arm-exidx.test
index 2ce35494ca1485..c82a93efc1aae8 100644
--- a/lld/test/ELF/linkerscript/locationcountererr-arm-exidx.test
+++ b/lld/test/ELF/linkerscript/locationcountererr-arm-exidx.test
@@ -12,9 +12,9 @@
 # ERR-NEXT: error: a.t:10: unable to move location counter (0x2000) backward to 0x1f6c for section 'dummy2'
 # ERR-NEXT: error: a.t:14: unable to move location counter (0x4104) backward to 0x4070 for section 'code.unused_space'
 # ERR-NEXT: error: section '.ARM.exidx' will not fit in region 'CODE': overflowed by 148 bytes
-# ERR-NEXT: error: section dummy1 at 0x1000 of size 0xFFFFFFFFFFFFFF6C exceeds available address space
-# ERR-NEXT: error: section dummy2 at 0x2000 of size 0xFFFFFFFFFFFFFF6C exceeds available address space
-# ERR-NEXT: error: section code.unused_space at 0x4104 of size 0xFFFFFFFFFFFFFF6C exceeds available address space
+# ERR-NEXT: error: section dummy1 at 0x1000 of size 0xffffffffffffff6c exceeds available address space
+# ERR-NEXT: error: section dummy2 at 0x2000 of size 0xffffffffffffff6c exceeds available address space
+# ERR-NEXT: error: section code.unused_space at 0x4104 of size 0xffffffffffffff6c exceeds available address space
 
 ## If we merge adjacent duplicate entries, we will have enough space. Don't report
 ## a spurious error https://github.com/llvm/llvm-project/issues/66836

diff  --git a/lld/test/ELF/linkerscript/sections-max-va-overflow.s b/lld/test/ELF/linkerscript/sections-max-va-overflow.s
index ce771b4784c44b..a60da8dfb88049 100644
--- a/lld/test/ELF/linkerscript/sections-max-va-overflow.s
+++ b/lld/test/ELF/linkerscript/sections-max-va-overflow.s
@@ -7,7 +7,7 @@
 
 ## .bar section has data in [0xfffffffffffffff1, 0xfffffffffffffff1 + 0x10] ==
 ## [0xfffffffffffffff1, 0x1]. Check we can catch this overflow.
-# ERR: error: section .bar at 0xFFFFFFFFFFFFFFF1 of size 0x10 exceeds available address space
+# ERR: error: section .bar at 0xfffffffffffffff1 of size 0x10 exceeds available address space
 
 .section .bar,"ax", at progbits
 .zero 0x10


        


More information about the llvm-commits mailing list