From patchwork Sun Oct 20 06:48:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 99240 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F3133858C42 for ; Sun, 20 Oct 2024 06:48:29 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id B25213858D20 for ; Sun, 20 Oct 2024 06:48:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B25213858D20 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 B25213858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729406886; cv=none; b=OsISlFcdvU/NwwxlQdQYTD/6+v2C+qk4ukhQPXWwYGEYKVNRFUb+RxE8M6BAqCXhBAy4z7vf/2mGlpj0LkI9XZWx6764bS9nDr5zuSqAp4KMwCz+WCSuILMLz5HikeDdYiPphPLzeQ4KnH0kZ5sg4L6YAXMbcs7nmRC88DG9StA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729406886; c=relaxed/simple; bh=Ka5MP41VcXrgNznKPTU4wpfn7X86AEL1f8LFk1xvhlI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=BOKxj9adAd7cVZiJ0A1hbCHC/4GTcN8jxfObSP6hSPmdQXCZoXYd7eY7DqAP9MgDj+ouTsNryIMv7jW+Db2kJ4JZkcGWaM4q+G/s4Aoky2MJanoEH56XfDHgymYOhPOWApLI8LmevWXt9z5Atv+USwemL6iXcbilVJf/lbaEgWM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-71e72db7bb1so2562973b3a.0 for ; Sat, 19 Oct 2024 23:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729406883; x=1730011683; darn=sourceware.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=ZC+CmBc4dDCVGk7XBZUKQPO/FMPlZGAqTFhTgiRvieQ=; b=jN6+8/0KEb1V2A4RXFPHdj9GeXVxV0jtE/Tv2buNfCsvGyfdG+tnLshY7WTk14vHdl dIVDRlQB/aNzDffWSz+TYa/+hSqcb3+ErfBV8tJ7jfjcDh5CVrqQNL+QXrhcOc2unwBp Ebi0CCcs+DmghpYX2oQuSoRcg9IMr6IrDAZdCHq0yjfS9DrVqklFJUtDv39zvPO1Og7C V+Ow7wIT67dv+JTYc/ai1H4bw7QF6X9lg4Okj660fV63mwg/VNF0TDwXRs5fka8Q9LRH PA00+ZqFIQnM2JDNCesVIGIC9Pj75QBRAHV3XQHiYIB/XQC3ygivBE3diR4qX0jcm3u3 h8Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729406883; x=1730011683; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZC+CmBc4dDCVGk7XBZUKQPO/FMPlZGAqTFhTgiRvieQ=; b=wWrJOLqKX0PpepGagIN9e1jEFw/5353hn9CyCiJ3H3VZ88i5pJptXRJjJx9TcFtU9r B4Rg+pbjSeexp4qOl6dxhgY7XJap3sRlCUVyUKp8Lxt1ps+N2DaDk+GnxC67JECOeyv4 TFJyD7cDbxDQ6jZI9ID0Y00AL+BzhL8rI2ixNCetlbhMyJ3FvCOZf8WpXNFJYQr1q4GC +gcqRwTWaEc3vq/C6+v/IWRL/zwXuINzDq4aFUsq7cI3YACTCq9IWcDHE8p+VT+owvB5 3T4wLpezjsdAZggZzaxE0I8Ua+//rRzlUb8fu/BvAx3v5+gcEhqfN880NeJtod+3urC4 r2pw== X-Gm-Message-State: AOJu0YxJKUeU2+Z9VPOQ2SnAjZSW5LmrvCHKbiaW85GDdjjKrT4+YN1V p01FOzm2+vdbPnaB3QqMkeg8sg0tSrrsRi25JA2pNwlvT1794Yzqd3SI/Q== X-Google-Smtp-Source: AGHT+IEhSSYzyLui5utCsHVTXPJs4ByQZuMZKsbynJ0PkkmTKzWNUneXTkzMKAJGq7R2tiKeEysUwQ== X-Received: by 2002:a05:6a21:3a94:b0:1d8:a759:525b with SMTP id adf61e73a8af0-1d92c575d5cmr11214226637.34.1729406883285; Sat, 19 Oct 2024 23:48:03 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec13d76besm673421b3a.121.2024.10.19.23.48.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2024 23:48:02 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 48AB71140601; Sun, 20 Oct 2024 17:18:00 +1030 (ACDT) Date: Sun, 20 Oct 2024 17:18:00 +1030 From: Alan Modra To: binutils@sourceware.org Subject: Report bfd_merge_sections error Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3033.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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org PR 32260 bfd/ * elfxx-target.h (bfd_elfNN_bfd_merge_sections): Default to bfd_generic_merge_sections when using the generic linker. * elflink.c (_bfd_elf_merge_sections): Return error from _bfd_merge_sections. Abort on wrong hash table. ld/ * ldlang.c (lang_process): Report bfd_merge_sections error. diff --git a/bfd/elflink.c b/bfd/elflink.c index bcac35a49d7..ef159dafd55 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -8109,8 +8109,8 @@ _bfd_elf_merge_sections (bfd *obfd, struct bfd_link_info *info) bfd *ibfd; asection *sec; - if (!is_elf_hash_table (info->hash)) - return false; + if (ENABLE_CHECKING && !is_elf_hash_table (info->hash)) + abort (); for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next) if ((ibfd->flags & DYNAMIC) == 0 @@ -8133,8 +8133,8 @@ _bfd_elf_merge_sections (bfd *obfd, struct bfd_link_info *info) } if (elf_hash_table (info)->merge_info != NULL) - _bfd_merge_sections (obfd, info, elf_hash_table (info)->merge_info, - merge_sections_remove_hook); + return _bfd_merge_sections (obfd, info, elf_hash_table (info)->merge_info, + merge_sections_remove_hook); return true; } diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 075f1bdd433..d10391dcb43 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -187,11 +187,6 @@ #define bfd_elfNN_bfd_gc_sections bfd_elf_gc_sections #endif -#ifndef bfd_elfNN_bfd_merge_sections -#define bfd_elfNN_bfd_merge_sections \ - _bfd_elf_merge_sections -#endif - #ifndef bfd_elfNN_bfd_is_group_section #define bfd_elfNN_bfd_is_group_section bfd_elf_is_group_section #endif @@ -287,6 +282,9 @@ #ifndef bfd_elfNN_bfd_final_link #define bfd_elfNN_bfd_final_link bfd_elf_final_link #endif +#ifndef bfd_elfNN_bfd_merge_sections +#define bfd_elfNN_bfd_merge_sections _bfd_elf_merge_sections +#endif #else /* ! defined (elf_backend_relocate_section) */ /* If no backend relocate_section routine, use the generic linker. Note - this will prevent the port from being able to use some of @@ -310,6 +308,9 @@ #ifndef bfd_elfNN_bfd_final_link #define bfd_elfNN_bfd_final_link _bfd_generic_final_link #endif +#ifndef bfd_elfNN_bfd_merge_sections +#define bfd_elfNN_bfd_merge_sections bfd_generic_merge_sections +#endif #endif /* ! defined (elf_backend_relocate_section) */ #ifndef bfd_elfNN_bfd_link_just_syms diff --git a/ld/ldlang.c b/ld/ldlang.c index 343c4de53f4..00b214411d6 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -8426,7 +8426,8 @@ lang_process (void) sections, so that GCed sections are not merged, but before assigning dynamic symbols, since removing whole input sections is hard then. */ - bfd_merge_sections (link_info.output_bfd, &link_info); + if (!bfd_merge_sections (link_info.output_bfd, &link_info)) + einfo (_("%F%P: bfd_merge_sections failed: %E\n")); /* Look for a text section and set the readonly attribute in it. */ found = bfd_get_section_by_name (link_info.output_bfd, ".text");