From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 7F7DA3858D33 for ; Thu, 18 Apr 2024 21:12:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F7DA3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7F7DA3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1031 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713474762; cv=none; b=DGnuKIEc8al8m/JVtUObv9QCKd4H5YgsHBwMuCS5I6G1ff6Q6hvPyAIl/NMqT2HZRZ9DijJyyIrEIBbxmJ6veLEMNad2ZvurzElfDxf4dkEqVxhh/O9EPeICrC5puoKxFTuRiwinsmvzS7kVkZ+ZBH4wS4CAjBt4ofDYTJnrzJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713474762; c=relaxed/simple; bh=er3xr72vt/OyJs9PN1Xc/7nkiEZTcOKv2U4uUTkK7Iw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Iz9qZa2Ze/Z05ajiDoxJAlmsSpm94m6ERZLAs+NtV2sf7F/JTdIDpdOe5B9D0Gb9KCXC+LDIzIzcAlS+5q29YtT2NGohAZhBxVMGu4VXLqNbxLa5PNXHY1qmIYiNqC0jYVADq1SB7vU+m2QjMB2tqMJbu8LnR/2ySflJQMcefjs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2ac1674d890so579084a91.3 for ; Thu, 18 Apr 2024 14:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713474759; x=1714079559; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=U0B/GkQfdTjfsR0F/EnoknRC2uKd2/LnFE8BYAc3jcQ=; b=EUTaLS4fJUsiixkEg+0vb4yYM+zcujOy/jF5jf11NF8zwx8uSKuQreG7CJxLePgfas DSy4rfwSbu8ma0ohBgstu9Phuch1s2rssf+aYHHpePgpq9MjzgbwWY/kBfFcsfDITs+k 1vB85fvKZKOF3fjtAMd0CIUirbu5r2q5v5dzT3lHRhnWJpNjGpwMiD6WMry72Vs9M3Nn xYA5r5eJT00kuJZISydba6uOad2EI6dgtZb5GLXQzIyb8D3WB2rHLmsTtSlu22oMaF/2 FJ7AMfXcB5x7tS4DV9TrTooh/5YecyRkcFvVDNDJpkfHkCu+S3rwN9rVihHqMuW2jfHL skQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713474759; x=1714079559; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U0B/GkQfdTjfsR0F/EnoknRC2uKd2/LnFE8BYAc3jcQ=; b=Toy0d47A09Zm5P6XydRp7MUn4umft28/2gDp9HVPnp1dX7brXmnzTw8uHV/KYS8akB bcnavu72BcZWtCBQ/zFpr5JCwRnsYThQHmwtqXc8Fl5xM2B6VRF+7zYmywQmsvn0swGU g3UhVQ5Y+f3OMeBwh2VryXB2ZMDUjKBeEW8hWAfxJhM4TPVII3V9rY5+1XUUX9eu3tEP VxSe9M2RCNqveByrdfChAk2X+9SFcgziZc3XrkqLfc65DjNV9KErTbQU2Xksp5r0BHsa BHfbolZnWsCX9qT9nsiwi+sgUPRW8Z5dCtQFhmoWGyLfZKMQm9pve8uNyob1odMXtM7x juZw== X-Gm-Message-State: AOJu0YwzZ7po4ua0rMa9sJ3/aAiYhfYhGb83EIgAOtA6ZgD0ln16n800 bu7fwrbBYbEk7ruExGb6fYCN1Yi1xlNuq6cA4fYftnjBD6bUHeI4HIAtxWBp3SFFhxFVX7gTq6E DaTy/94tMp4xhsQSwHtfOkw4hc7cwEQEF X-Google-Smtp-Source: AGHT+IEFQ7Mt5Pu86HB3l89j56+Gi8Y/MOMm4GMg3vhGJ+h12zxvyUCrKGbeIW9GLrKXRik3Vcnz8ZZ5o2/rnWz9CTs= X-Received: by 2002:a17:90b:1d06:b0:2ab:b613:96e1 with SMTP id on6-20020a17090b1d0600b002abb61396e1mr395990pjb.5.1713474759173; Thu, 18 Apr 2024 14:12:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrew Pinski Date: Thu, 18 Apr 2024 14:12:27 -0700 Message-ID: Subject: Re: PR29613, use of uninitialized value in objcopy To: Alan Modra Cc: binutils@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Sep 26, 2022 at 2:56=E2=80=AFAM Alan Modra via Binutils 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=3D114775 . Thanks, Andrew > > diff --git a/bfd/elf.c b/bfd/elf.c > index 9a0bc1d2740..396b56db024 100644 > --- a/bfd/elf.c > +++ b/bfd/elf.c > @@ -13482,9 +13482,9 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd= , asection *sec) > { > asymbol * last_sym; > int last_sym_idx; > - unsigned int reloc_count; > - unsigned int idx; > - unsigned int entsize; > + size_t reloc_count; > + size_t idx; > + bfd_size_type entsize; > arelent * src_irel; > bfd_byte * dst_rela; > > @@ -13525,7 +13525,8 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd= , asection *sec) > } > > reloc_count =3D hdr->sh_size / entsize; > - if (reloc_count <=3D 0) > + hdr->sh_size =3D entsize * reloc_count; > + if (reloc_count =3D=3D 0) > { > _bfd_error_handler > /* xgettext:c-format */ > @@ -13572,7 +13573,7 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd= , asection *sec) > { > _bfd_error_handler > /* xgettext:c-format */ > - (_("%pB(%pA): error: reloc table entry %u is empty"), > + (_("%pB(%pA): error: reloc table entry %zu is empty")= , > abfd, relsec, idx); > bfd_set_error (bfd_error_bad_value); > result =3D false; > @@ -13597,7 +13598,7 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd= , asection *sec) > { > _bfd_error_handler > /* xgettext:c-format */ > - (_("%pB(%pA): error: secondary reloc %u" > + (_("%pB(%pA): error: secondary reloc %zu" > " references a missing symbol"), > abfd, relsec, idx); > bfd_set_error (bfd_error_bad_value); > @@ -13615,7 +13616,7 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd= , asection *sec) > { > _bfd_error_handler > /* xgettext:c-format */ > - (_("%pB(%pA): error: secondary reloc %u" > + (_("%pB(%pA): error: secondary reloc %zu" > " references a deleted symbol"), > abfd, relsec, idx); > bfd_set_error (bfd_error_bad_value); > @@ -13629,7 +13630,7 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd= , asection *sec) > { > _bfd_error_handler > /* xgettext:c-format */ > - (_("%pB(%pA): error: secondary reloc %u" > + (_("%pB(%pA): error: secondary reloc %zu" > " is of an unknown type"), > abfd, relsec, idx); > bfd_set_error (bfd_error_bad_value); > > -- > Alan Modra > Australia Development Lab, IBM