hotislandn commented on a change in pull request #2865:
URL: https://github.com/apache/incubator-nuttx/pull/2865#discussion_r579028861



##########
File path: libs/libc/machine/risc-v/common/arch_elf.c
##########
@@ -224,7 +246,7 @@ bool up_checkarch(FAR const Elf_Ehdr *ehdr)
 
   if ((ehdr->e_entry & 1) != 0)
     {
-      berr("ERROR: Entry point is not properly aligned: %08" PRIx32 "\n",
+      berr("ERROR: Entry point is not properly aligned: %08lx\n",

Review comment:
       PRIx32 works for RV32, but not for RV64:
   
   machine/risc-v/common/arch_elf.c:241:12: warning: format '%x' expects 
argument of type 'unsigned int', but argument 3 has type 'Elf64_Addr' {aka 
'const long unsigned int'} [-Wformat=]
          berr("ERROR: Entry point is not properly aligned: %08" PRIx32 "\n",
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               ehdr->e_entry);
               ~~~~~~~~~~~~~
   
   This parameter, "ehdr->e_entry" is also 'const long unsigned int' for RV32, 
which can be tested via following:
   
   machine/risc-v/common/arch_elf.c:241:12: warning: format '%x' expects 
argument of type 'unsigned int', but argument 3 has type 'Elf32_Addr' {aka 
'const long unsigned int'} [-Wformat=]
          berr("ERROR: Entry point is not properly aligned: %08" PRIxPTR "\n",
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               ehdr->e_entry);
               ~~~~~~~~~~~~~
   
   For "PRIx32", it is expanded to "lx" on RV32, but "x" on RV64; a similar 
issue happens for "PRIxPTR".
   
   The reason for this change is that the input parameter has the same base 
type: 'const long unsigned int', which requires to use "lx" for printf, though 
it presents different data lengths on RV32 and RV64. 
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to