PR29613, use of uninitialized value in objcopy

Alan Modra amodra@gmail.com
Fri Apr 19 00:25:38 GMT 2024


On Thu, Apr 18, 2024 at 02:12:27PM -0700, Andrew Pinski wrote:
> On Mon, Sep 26, 2022 at 2:56 AM Alan Modra via Binutils
> <binutils@sourceware.org> wrote:
> >
> >         PR 29613
> >         * elf.c (_bfd_elf_write_secondary_reloc_section): Trim sh_size
> >         back to relocs written.  Use better types for vars.
> 
> Just FYI. I noticed that this adds the use of `%zu` to
> _bfd_error_handler but _bfd_error_handler uses ATTRIBUTE_PRINTF_1
> which uses just the printf format which on mingw is different from
> other targets (it is an alias to ms_printf rather than an alias to
> gnu_printf). So this and other uses `%zu` will cause a warning to show
> up because of that.
> This was reported to GCC via
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114775 .

>From binutils/README:
To build binutils you will need a C99 compliant compiler and library.

Casting size_t to long in order to print values is just plain wrong,
particularly on LLP64 hosts where sizeof(long)==4 and
sizeof(size_t)==8.  In fact, many places in binutils that use long
variables, struct fields or function return values ought to be using
size_t or ssize_t.

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list