From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by sourceware.org (Postfix) with ESMTPS id E07DA3858D28 for ; Mon, 19 Dec 2022 18:37:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E07DA3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BJFnjp4005722; Mon, 19 Dec 2022 19:37:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=selector1; bh=LLLFI4Jgpc+pke6VpMHhoGdrf5jDnNpo6bgEKRpGMSo=; b=F7gUK2vuCGrBWRQRxRjzCkVUkUdMTAJ/Lkh2xaiPqcyRHDGQSPg+yAKg4d5/nkecGdxX +tgLdgJGrFMFGtnupyDCAX5Dcn8MDU4e2JzftUctQ3A3FcAXxA4RC8kXCNS6oRYlnr6l 16gA9673fINDU0/Ag8Z0/uO3oXsB1BDOVS51yBdhnuDyS0P18BzvMRKK6Wu/TxL7ghY8 V0paLZ7l3x6NClQ+7SEsLgIBtGo/pUxFdINe0h7AlA/0T+7/qqgAbEWGpvVpkSkL/oMj 5qcARi8iAMHscYov8ZIIu+CweRZxAXlyor/QRL0RUux/qNXXnmXtEloxK41jbaOAlPZr PA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3mh3smwemc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Dec 2022 19:37:46 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CEB0C100038; Mon, 19 Dec 2022 19:37:41 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 5A674233011; Mon, 19 Dec 2022 19:36:20 +0100 (CET) Received: from jkgcxl0004.jkg.st.com (10.210.54.218) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.13; Mon, 19 Dec 2022 19:36:17 +0100 From: =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= To: CC: , =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= , Yvan ROUX Subject: [PATCH v2] bfd: Discard region regardless of warning flag Date: Mon, 19 Dec 2022 19:34:51 +0100 Message-ID: <20221219183450.3754890-1-torbjorn.svensson@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.210.54.218] X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-19_01,2022-12-15_02,2022-06-22_01 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,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: v1 -> v2: Added testcase Ok for trunk? I have commit access for GDB. Do I still need someone to push this for me or do I automatically have write access to the complete binutils repository and just need the approval to push it myself? --- The discard of the region should be performed regardless if the warning for the discard is enabled or not. Without this patch, ld would segfault in bfd_section_removed_from_list, called in the if-statement right after this block, as the argument isec->output_section can be NULL. Signed-off-by: Torbjörn SVENSSON Co-Authored-By: Yvan ROUX --- bfd/elflink.c | 10 +++---- ld/testsuite/ld-arm/arm-elf.exp | 1 + ld/testsuite/ld-arm/non-contiguous-arm7.d | 4 +++ ld/testsuite/ld-arm/non-contiguous-arm7.ld | 32 ++++++++++++++++++++++ ld/testsuite/ld-arm/non-contiguous-arm7.s | 16 +++++++++++ 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 ld/testsuite/ld-arm/non-contiguous-arm7.d create mode 100644 ld/testsuite/ld-arm/non-contiguous-arm7.ld create mode 100644 ld/testsuite/ld-arm/non-contiguous-arm7.s diff --git a/bfd/elflink.c b/bfd/elflink.c index fc3edef9a05..0368256970b 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -11154,12 +11154,12 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd) if (isym->st_shndx != SHN_UNDEF && isym->st_shndx < SHN_LORESERVE && isec->output_section == NULL - && flinfo->info->non_contiguous_regions - && flinfo->info->non_contiguous_regions_warnings) + && flinfo->info->non_contiguous_regions) { - _bfd_error_handler (_("warning: --enable-non-contiguous-regions " - "discards section `%s' from '%s'\n"), - isec->name, bfd_get_filename (isec->owner)); + if (flinfo->info->non_contiguous_regions_warnings) + _bfd_error_handler (_("warning: --enable-non-contiguous-regions " + "discards section `%s' from '%s'\n"), + isec->name, bfd_get_filename (isec->owner)); continue; } diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index e53b9bba723..ce3605d3709 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -1271,6 +1271,7 @@ run_dump_test "non-contiguous-arm3" run_dump_test "non-contiguous-arm4" run_dump_test "non-contiguous-arm5" run_dump_test "non-contiguous-arm6" +run_dump_test "non-contiguous-arm7" if { !$is_nacl && [check_shared_lib_support] } { run_dump_test "thumb-plt" diff --git a/ld/testsuite/ld-arm/non-contiguous-arm7.d b/ld/testsuite/ld-arm/non-contiguous-arm7.d new file mode 100644 index 00000000000..b7621615004 --- /dev/null +++ b/ld/testsuite/ld-arm/non-contiguous-arm7.d @@ -0,0 +1,4 @@ +#name: non-contiguous-arm7 +#source: non-contiguous-arm7.s +#ld: --enable-non-contiguous-regions -T non-contiguous-arm7.ld --gc-sections +#error: \A.*unresolvable R_ARM_ABS32 relocation against symbol .MY_BUF..*\Z diff --git a/ld/testsuite/ld-arm/non-contiguous-arm7.ld b/ld/testsuite/ld-arm/non-contiguous-arm7.ld new file mode 100644 index 00000000000..9934fdfd3a4 --- /dev/null +++ b/ld/testsuite/ld-arm/non-contiguous-arm7.ld @@ -0,0 +1,32 @@ +/* + The section .bss.MY_BUF won't fit in RAM1 or RAM2 +*/ + +MEMORY +{ + ROM (rx) : ORIGIN = 0x8000000, LENGTH = 10K + RAM1 (xrw) : ORIGIN = 0x10000000, LENGTH = 64K + RAM2 (xrw) : ORIGIN = 0x20000000, LENGTH = 96K +} + +SECTIONS +{ + .text : + { + KEEP(*(.text.foo)) ; + } >ROM + + .bss : + { + _sbss = .; + *(.bss) *(.bss*) ; + _ebss = .; + } >RAM1 + + .bss_ram2 : + { + _sbss_ram2 = .; + *(.bss) *(.bss*) ; + _ebss_ram2 = .; + } >RAM2 +} diff --git a/ld/testsuite/ld-arm/non-contiguous-arm7.s b/ld/testsuite/ld-arm/non-contiguous-arm7.s new file mode 100644 index 00000000000..be0a407ddc4 --- /dev/null +++ b/ld/testsuite/ld-arm/non-contiguous-arm7.s @@ -0,0 +1,16 @@ + .global MY_BUF + .section .bss.MY_BUF,"aw",%nobits + .type MY_BUF, %object + .size MY_BUF, 102400 +MY_BUF: + .space 102400 + + .section .text.foo,"ax",%progbits + .global foo + .type foo, %function +foo: + ldr r0, .L3 + bx lr +.L3: + .word MY_BUF + .size foo, .-foo -- 2.25.1