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