From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id 4D1E83858D32 for ; Mon, 26 Sep 2022 09:55:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4D1E83858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102b.google.com with SMTP id p1-20020a17090a2d8100b0020040a3f75eso6185267pjd.4 for ; Mon, 26 Sep 2022 02:55:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date; bh=+onkI1wsap0P0aqk//QqqUd0dvXe1WUEDnRHaoAJT0I=; b=jaSB3LUIt1yctotIt4b47W7JDU+3QoeHSs38Nw0OmFsHG0wEUOFbCHCrPBUIjXPdDa wpdJpjS118zZTUDf0VF77uxZyuMgtDa8LDpyjOkfdyLBWjN25lg84L96wXHxJpZRxIEf tWu0KQYj/SgvgiDRz856BhtfprLEMMp2xSP8D/Vp/ObgKyt9K5ZfpVcrsmIFEFLcJAIX uJ88ZuCAWOxLj4hCn7gEbfNxi1cFJpNbfLzDC46HDmeC8ssN4b5hQGiQ5Mt9nKQwVla+ rStKgILQjVbUfkp8uXaq5WVf5QkpFqXgrquZIRsC6gyoTGaOWJWM66+arJS/3owp60UU cNDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=+onkI1wsap0P0aqk//QqqUd0dvXe1WUEDnRHaoAJT0I=; b=jEoG3Chk2gz52hjadVCaz+7BlyqWf5f+mwY5J3A5H6FCuT8WhMUT2q8N4IfGqrqeJX ZlBwOiK2butuZ0OfCE7XWMLotr8zm7bPHJKrePFXvB+YMa3W3pOWq1yajs37FC5O6+Pu daE1w1rlVqD763QK8/3zABkrlsSG5Cb3ur7Q6AF27uEZ5tqNbQ30qknDv+/iMJivxqKK Q2vY5NOspOSvSj8dSYj3MzzcsaoW2iDSyDqMLjIEo+JW66C58unHTAwMO72m/eIMOXOn M09zF4XHI9a0HzjP8VOo6rL/9M2xSNAGDj3QCoq1phnjZfa9Lkr1CbZ3sJNV64DXWAfV A/mw== X-Gm-Message-State: ACrzQf1tXQZLYqepwdHF9qsHS2jU3kiIbGpl9cun625X4KAut85ycq72 98PorMkIKsoOIMkIIuyWwppOeg5OPBA= X-Google-Smtp-Source: AMsMyM7LjWWxcw/wNada4HaHBYQbAgdyRQMqDPO8YrfEva9lV+0SiF0azYZnvORVCxpiy6fjKk50WQ== X-Received: by 2002:a17:902:cecc:b0:177:f3f4:cc90 with SMTP id d12-20020a170902cecc00b00177f3f4cc90mr21319237plg.83.1664186146136; Mon, 26 Sep 2022 02:55:46 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:8141:7672:2122:dcb8]) by smtp.gmail.com with ESMTPSA id x7-20020aa79ac7000000b00540d75197e5sm11483163pfp.47.2022.09.26.02.55.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 02:55:45 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id B51E01142DF9; Mon, 26 Sep 2022 19:25:42 +0930 (ACST) Date: Mon, 26 Sep 2022 19:25:42 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PR29613, use of uninitialized value in objcopy Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3035.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,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: PR 29613 * elf.c (_bfd_elf_write_secondary_reloc_section): Trim sh_size back to relocs written. Use better types for vars. 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 = hdr->sh_size / entsize; - if (reloc_count <= 0) + hdr->sh_size = entsize * reloc_count; + if (reloc_count == 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 = 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