From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 8BE4E3858D39 for ; Fri, 29 Jul 2022 07:56:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8BE4E3858D39 Received: by mail-pl1-x632.google.com with SMTP id b22so3908592plz.9 for ; Fri, 29 Jul 2022 00:56:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=UDiRU0RgkXmBUJ8N7nDSOBw3Y5umoE1GgDI0+KoHzSs=; b=04z33LDh32H8bz8IsTtsYeobV2n82vytSB8iw6iUxlEIRkLudeB6lxqOl/I83PjsWh ZLYkwn68JKJ9j3fNxa431cInrRIY9aGVc9Xq6uf39NqtRBFMuINxVTuxRozPS8BNQxLp 2MSYgsaG/IvTvwC1FjGZnKCWo+Lgd3vwee/C/6g65iHUJI1W+R3OkDfhb7i6HbKZMcod ErCuITxMH8xy4bOoQE/cQpNl8YOtusGouqevXQgradBZAup8chlliZ+rpGVYOsxWWlad RMhYbWFEUq1tEfzxOF9tVfoUKiY7+7FHOD/8dmeodkGbaktnn/RNhYHyn167IanQNTXx g2SQ== X-Gm-Message-State: ACgBeo298m3YvxPj1QAYINdn0V3Go6gjO6DEQVK/v9urov8tJ9A08t8k 1hioFLeR8V+JaczdQ6SauShGJ2fozjY= X-Google-Smtp-Source: AA6agR4C3EMokiRLaWiNqi1qGiG+D9aImk5fxQe1HZfBf04lhDLpUIU/911mUggHdbHPbsMlOCBLbg== X-Received: by 2002:a17:90b:390d:b0:1f2:4dbe:5f44 with SMTP id ob13-20020a17090b390d00b001f24dbe5f44mr2789783pjb.27.1659081403245; Fri, 29 Jul 2022 00:56:43 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:3da4:4759:19d:22ca]) by smtp.gmail.com with ESMTPSA id k12-20020a170902c40c00b0016d6420691asm640892plk.207.2022.07.29.00.56.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jul 2022 00:56:42 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 15A551141C37; Fri, 29 Jul 2022 17:26:40 +0930 (ACST) Date: Fri, 29 Jul 2022 17:26:40 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PR16005, avr linker crash on a particular instruction sequence with --relax Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3036.0 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 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: Fri, 29 Jul 2022 07:56:46 -0000 It's possible for relax_delete_bytes to be called with section contents NULL, as demonstrated by the testcase in this PR. PR 16005 * elf32-avr.c (elf32_avr_relax_delete_bytes): Get section contents if not already available. diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c index 48591b8c904..3a1d238e707 100644 --- a/bfd/elf32-avr.c +++ b/bfd/elf32-avr.c @@ -1927,6 +1927,9 @@ elf32_avr_relax_delete_bytes (bfd *abfd, symtab_hdr = &elf_tdata (abfd)->symtab_hdr; sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec); contents = elf_section_data (sec)->this_hdr.contents; + if (contents == NULL + && !bfd_malloc_and_get_section (abfd, sec, &contents)) + return false; relax_info = get_avr_relax_info (sec); toaddr = sec->size; -- Alan Modra Australia Development Lab, IBM