objtool: Print bfd_vma as unsigned long long on ia32-x86_64 cross build

When objtool is cross-compiled in ia32 container for x86_64 target it
fails with the following errors:

> disas.c: In function 'disas_print_addr_sym':
> disas.c:173:38: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'bfd_vma' {aka 'long long unsigned int'} [-Werror=format=]
> 173 | DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, symstr);
> | ^~~~~~~~~~~~ ~~~~
> | |
> | bfd_vma {aka long long unsigned int}

Provide a correct printf-fmt depending on sizeof(bfd_vma).

Fixes: 5d859dff266f ("objtool: Print symbol during disassembly")
Signed-off-by: Dmitry Safonov <dima@arista.com>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Link: https://patch.msgid.link/20260126-objtool-ia32-v1-1-bb6feaf17566@arista.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

authored by Dmitry Safonov and committed by Josh Poimboeuf fd4eeb30 3f2de814

+8 -6
+8 -6
tools/objtool/disas.c
··· 108 109 #define DINFO_FPRINTF(dinfo, ...) \ 110 ((*(dinfo)->fprintf_func)((dinfo)->stream, __VA_ARGS__)) 111 112 static int disas_result_fprintf(struct disas_context *dctx, 113 const char *fmt, va_list ap) ··· 172 173 if (sym) { 174 sprint_name(symstr, sym->name, addr - sym->offset); 175 - DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, symstr); 176 } else { 177 str = offstr(sec, addr); 178 - DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, str); 179 free(str); 180 } 181 } ··· 254 * example: "lea 0x0(%rip),%rdi". The kernel can reference 255 * the next IP with _THIS_IP_ macro. 256 */ 257 - DINFO_FPRINTF(dinfo, "0x%lx <_THIS_IP_>", addr); 258 return; 259 } 260 ··· 266 */ 267 if (reloc->sym->type == STT_SECTION) { 268 str = offstr(reloc->sym->sec, reloc->sym->offset + offset); 269 - DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, str); 270 free(str); 271 } else { 272 sprint_name(symstr, reloc->sym->name, offset); 273 - DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, symstr); 274 } 275 } 276 ··· 313 */ 314 sym = insn_call_dest(insn); 315 if (sym && (sym->offset == addr || (sym->offset == 0 && is_reloc))) { 316 - DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, sym->name); 317 return; 318 } 319
··· 108 109 #define DINFO_FPRINTF(dinfo, ...) \ 110 ((*(dinfo)->fprintf_func)((dinfo)->stream, __VA_ARGS__)) 111 + #define bfd_vma_fmt \ 112 + __builtin_choose_expr(sizeof(bfd_vma) == sizeof(unsigned long), "%#lx <%s>", "%#llx <%s>") 113 114 static int disas_result_fprintf(struct disas_context *dctx, 115 const char *fmt, va_list ap) ··· 170 171 if (sym) { 172 sprint_name(symstr, sym->name, addr - sym->offset); 173 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, symstr); 174 } else { 175 str = offstr(sec, addr); 176 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, str); 177 free(str); 178 } 179 } ··· 252 * example: "lea 0x0(%rip),%rdi". The kernel can reference 253 * the next IP with _THIS_IP_ macro. 254 */ 255 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, "_THIS_IP_"); 256 return; 257 } 258 ··· 264 */ 265 if (reloc->sym->type == STT_SECTION) { 266 str = offstr(reloc->sym->sec, reloc->sym->offset + offset); 267 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, str); 268 free(str); 269 } else { 270 sprint_name(symstr, reloc->sym->name, offset); 271 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, symstr); 272 } 273 } 274 ··· 311 */ 312 sym = insn_call_dest(insn); 313 if (sym && (sym->offset == addr || (sym->offset == 0 && is_reloc))) { 314 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, sym->name); 315 return; 316 } 317