From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id AEEFA385783F for ; Wed, 26 Aug 2020 13:48:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AEEFA385783F Received: by mail-pl1-x62e.google.com with SMTP id a8so702223plm.2 for ; Wed, 26 Aug 2020 06:48:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=z/JmbiGd8unk/VyyXRdzVhAueQ7jadYFPhuzU2Ot7Zw=; b=nUbtKaUf8pp+hoA0Qo9kFvEywYHBBYdiFqO/E87/A6t/vJ4hPsIcLdO1VnP26JmKNU mpbfOST/nMdPrCSjxj0zNsVkElPOGhiU5R0CElwepcjqYxiWlnUy7AIwBBZdMZHNe2S8 apd81uFSlWdx3oqpxDRuSiYd2b4DimoLJE2mHrvEEE/QgpDRhjRnn8zXXEIdzb9jTDNf SzaX/dMJIdaxdvJnmoJX/TKAgvlfdYyMVFvXrSKA8dsgVVDDdMepitn5QzZse4AUvfSn RrbRr2OYkVQZf0rRQ05QK+jshGM1eaLCf65MmaBfEwwuO3iyy+LgxNZet5rbtkt8LBMZ 2TzQ== X-Gm-Message-State: AOAM530bWevyetkSclrbLlc+YHP4GRYwoGqsh3TbXXYEEWvVTJ8wjuI3 UOQMmTdeieAhyTRy/ley9b/BLjHlD/aOVg== X-Google-Smtp-Source: ABdhPJz4/coHV0e9Lien0MZYOLo+cGGXSUXoEhqARVK8faunlCp5e6ouxyFKaSJttIee5F4JqbURPA== X-Received: by 2002:a17:902:c395:: with SMTP id g21mr11885002plg.264.1598449694603; Wed, 26 Aug 2020 06:48:14 -0700 (PDT) Received: from bubble.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id j13sm3092579pfn.166.2020.08.26.06.48.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 06:48:14 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 477F681300; Wed, 26 Aug 2020 23:18:10 +0930 (ACST) Date: Wed, 26 Aug 2020 23:18:10 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PR26453 UBSAN: som.c:2885 null pointer memcpy Message-ID: <20200826134810.GL15695@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-12.4 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2020 13:48:16 -0000 PR 26453 * som.c (som_prep_for_fixups): Return early when no symbols. diff --git a/bfd/som.c b/bfd/som.c index 4f0a606c18..93a0ad89d5 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -2804,6 +2804,9 @@ som_prep_for_fixups (bfd *abfd, asymbol **syms, unsigned long num_syms) asymbol **sorted_syms; size_t amt; + if (num_syms == 0) + return TRUE; + /* Most SOM relocations involving a symbol have a length which is dependent on the index of the symbol. So symbols which are used often in relocations should have a small index. */ -- Alan Modra Australia Development Lab, IBM