[PATCH] microblaze: fix build error on 32-bit hosts

Mark Wielaard mark@klomp.org
Mon Oct 9 12:37:59 GMT 2023


Hi Neal,

On Mon, 2023-10-09 at 11:58 +0000, Frager, Neal wrote:
> The only thing I am unable to verify is using a 32-bit host.  I have only been building with a 64-bit host.
> 
> Does anyone have an idea why this patch would lead to issues with a 32-bit build host and not a 64-bit host?

It is as the error says:

elf32-microblaze.c: In function ‘microblaze_elf_relax_section’:
elf32-microblaze.c:1989:53: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘bfd_vma’ {aka ‘unsigned int’} [-Werror=format=]
 1989 |       fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
      |                                                   ~~^                    ~~~~~~~~~~~~~~
      |                                                     |                        |
      |                                                     long unsigned int        bfd_vma {aka unsigned int}
      |                                                   %x
elf32-microblaze.c:2074:51: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘bfd_vma’ {aka ‘unsigned int’} [-Werror=format=]
 2074 |    fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend);
      |                                                 ~~^                    ~~~~~~~~~~~~~~~~~~
      |                                                   |                            |
      |                                                   long unsigned int            bfd_vma {aka unsigned int}
      |                                                 %x


On a 32bit host bfd_vma is an unsigned int, but you are using a long
printf format.

Casting the r_addend to (long) is one way to resolve this.

Cheers,

Mark

P.S. If you have a commit access to binutils you can use a try branch
to test patches against builder.sourceware.org which contains several
32bit hosts. See https://sourceware.org/binutils/wiki/Buildbot


More information about the Binutils mailing list