From patchwork Wed Jan 15 11:03:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 104823 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 31D04385DDEE for ; Wed, 15 Jan 2025 11:06:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31D04385DDEE Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=O4PmFKBu X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 3A8F9385DDCD for ; Wed, 15 Jan 2025 11:03:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A8F9385DDCD 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 3A8F9385DDCD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736939037; cv=none; b=WJ/zFrwKWmfnPqWr+Rn1f1gRZGn4IjD9RhdQSWQQRwaPsiIkeWLA3w+fr4ztXgFbIzRwBKEwPkBBDMa1oUCBGRTF4ip6Cu7rle5tU2l/e5N1PqqRJvq/GsJYsInIHr8qLELr4U0z8KR4ZKV8A1kA64il85Sal5nWmS4/MU1POzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736939037; c=relaxed/simple; bh=DbuspnL4Z9f+u+emPJivx2bLfiJwvR0VF7Rtpbi6xgE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ad2Q76kPfriXcv9DNtqKIDgKNwtREt6PwFEHh0u7ryQUe+mF79PoGziPComOpSJdRNya5j+2lgo3q8lPN8omgTcsRx8483azVEvJtUM348Lr61AWqnGShxoijQJX16Csh+x0nYC+0/xNfanmr2+TqAyHo7RN2tvNWDY5CcQJdUw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A8F9385DDCD Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-216401de828so108710475ad.3 for ; Wed, 15 Jan 2025 03:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736939036; x=1737543836; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DcZrg7W/KFA0hTTGsd0JQOx5jjlKWGOSsWu50sJUbQw=; b=O4PmFKBucONcgcMFdcIhDxrWmVrsxGycuEYYQY1JP9+GpgVZ62nJJpbH4LD684Vghc RS8Zs18myi3boCR388cmjj45HgsOjwYytRejopJEgc8SzGRuV+pqwcxejmYvf4RfAvut Gs9grmUWUJkKuAwaNfg0qHTKO9k3+K7PEf2igteSN/KKVqiN0BLsvdUuZZki66PHDQAL vLzersGIZql8mIu7bJ8vm6pOTXOocHd9C6XlZORJvTyyyam0v4eEuSB1rRQiqGzYeL38 6zJAq2DEzh5GKzbk12hHCx0tpbC1B8vU6UoPlJKZ5u8XUwmltukyg6dqS1bu2dfZ5tfL tAdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736939036; x=1737543836; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DcZrg7W/KFA0hTTGsd0JQOx5jjlKWGOSsWu50sJUbQw=; b=m+sOQglT6/TTdVSrukwTxn6jlHN9HplsHwIBp+MrarX5087G2/AVyxsO6zzBdRfaZU nwXdf98wGclR/PVzzZjQr8K7wHq+s+nun7QT/ZVzpMuQzhkdvAYLHQdiSCNCsDxAQYYn Kd8VUiebP6fUTxKavTT9OmajiLGWSOScrB5RTucTaPWbuSE23j5zT1iy8smq7d7SWPeT eIvo6AnOLPHWYb0EoNGrS6T7LqrEHnbTlaw0J0QqgNwnnLuM4VYfvFurSKJC3PNIzcHC uzu4aGZAC/ubNOXfGnHUC6rZoQZTYh9CY3LeRcfcNcUh7El3KU3a/vIgpqAxSs8GGxV1 aSyg== X-Gm-Message-State: AOJu0YxY7QZeEl65lIwV42rON00rp7izKp4V+otA+QvRtq4N2gzqdMVW e1D2nxfI/3ni71FazDH+w+fs3UmjW2ePBO0lTfKurNnkFzgX7wCm X-Gm-Gg: ASbGncvfkR9cAbKFkYtZ22RJKLEAey7qBYcAKL8ZI+7/SbLEmRG87U6gzikRTIqK2Kn IDcZP3kf8Ge7nFMzwAXzY5wTcbJI2GctommIB6bS/sDf2G/gHbLmyjybAKPCXOLW8rYbDxJkcFx FqMtsP3/rNcMG2XQN5ncjJg2/oeZ0g740xEFoj2J/GMsbRNwfOMoyBSWYwY+m6rVPQ80/fRipCf wOwFa9qvUD6I8U6cB+Tbrq4F9CCqhhdRxggOorTFFlcYJoLi/Ctq3QO5z9zpkE/rPHyEQ== X-Google-Smtp-Source: AGHT+IEoVcmLGZAZpEUp7b3UMGwweDXEIkZC8PxIPr0EN1WkiAH2Y1GiQgsfwi728U7oRVG4KunCmA== X-Received: by 2002:a17:902:e545:b0:215:4a31:47d8 with SMTP id d9443c01a7336-21a83f36d79mr419991035ad.9.1736939036092; Wed, 15 Jan 2025 03:03:56 -0800 (PST) Received: from gnu-tgl-3.localdomain ([220.196.194.88]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21a9f21c49fsm79399245ad.118.2025.01.15.03.03.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2025 03:03:55 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id D592DC0242; Wed, 15 Jan 2025 19:03:47 +0800 (CST) From: "H.J. Lu" To: binutils@sourceware.org Cc: amodra@gmail.com, nickc@redhat.com Subject: [PATCH v2 1/2] ld: Correct ldelf_place_orphan Date: Wed, 15 Jan 2025 19:03:46 +0800 Message-ID: <20250115110347.1718501-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250115110347.1718501-1-hjl.tools@gmail.com> References: <20250115110347.1718501-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3018.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.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 Remove the extra for loop and if statement in ldelf_place_orphan. * ldelf.c (ldelf_place_orphan): Remove the extra for loop and if statement. Signed-off-by: H.J. Lu --- ld/ldelf.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ld/ldelf.c b/ld/ldelf.c index a66d1d21394..dfe8032f255 100644 --- a/ld/ldelf.c +++ b/ld/ldelf.c @@ -2275,19 +2275,17 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint) { struct orphan_save *ho, *horig; - for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho) for (ho = hold, horig = orig_hold; ho < hold + ARRAY_SIZE (hold); ++ho, ++horig) { *ho = *horig; if (ho->name != NULL) - if (ho->name != NULL) - { - ho->os = lang_output_section_find (ho->name); - if (ho->os != NULL && ho->os->flags == 0) - ho->os->flags = ho->flags; - } + { + ho->os = lang_output_section_find (ho->name); + if (ho->os != NULL && ho->os->flags == 0) + ho->os->flags = ho->flags; + } } orphan_init_done = true; } From patchwork Wed Jan 15 11:03:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 104822 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 DC243385DDDA for ; Wed, 15 Jan 2025 11:06:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC243385DDDA Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Jtihiuvk X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id C78B1385DDCC for ; Wed, 15 Jan 2025 11:03:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C78B1385DDCC 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 C78B1385DDCC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736939035; cv=none; b=nyAOVIgZMBvWVTMSbAjIWC7HjxjVBPr8hKYKk169MCZbATHJJtZeVgaViRza6nf9mSsh3rBwovMabbIARNnvH5Zp0t3GyGi1nvxOUR2Wswc9OWXoKV/S9sHEgd8+ftkIaMaQos/2hq5KZT9qpZimURdEakiqZqvKfYmsoLjAj8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736939035; c=relaxed/simple; bh=f8vGmFkzPioFWI2jLhP5ZtesuMVS0uyhujDU83y6+2w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aQdC12OBaefCTM+ZzrSy389bnDB1bwXgZzVdKBM6gy8S7nSm0ZsWuJHNQ3lGRhlzILtcWiWsJPVBaQIdPlGk2XaS0WGRHmIILOpzzW18FqOfSxiOwfQPcgUOq4JpJ10sdR1f2KMWnjQZwA1M+/HxiiceNwdGN5cPOIda79YeoQc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C78B1385DDCC Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2165cb60719so117664355ad.0 for ; Wed, 15 Jan 2025 03:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736939034; x=1737543834; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3hy62t38x9GJrUbTlufpeEJmNa+YGQ2zPBSH/URfrSc=; b=Jtihiuvkpa8IbPqeM/dyiad/aOtJaYHSKr34lQXxnEoQP5qGj5n5wU3Ka6rClccWL6 tdWI8f5EcViaL59aLUDSFDECBtoSwqheTtdaLEwp076ofda8BbHfkDz2XBDjs2Qa0ENO PlJTCMKMD+73WfXVbo3akKQRftfdlQeOL7zaBGUOqKgniE/3XZIhdCOmjlesA3crPKmB 6zUFhEKR9yMewod/rJ4LxKop0LhAOa/eY2Hs5TtVKxoVZNjcofCp+SjaM9vm4TdQGSoZ Ltw23moeSZf3az3f+4uE3GDa20WE5V3mIZYDKQn4b0DRCOKl8PFabFObjSnKhPij/AfV K5IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736939034; x=1737543834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3hy62t38x9GJrUbTlufpeEJmNa+YGQ2zPBSH/URfrSc=; b=Hgn7mnSIqVz/GUBSOjyKw1hc2y+dt26ZgrQsZY+X0v/rzWahYLz98m0x5sKRcLfO1y HoVvfPW1NYgkh+PL2opZd8I0tXe54GVLYqKNmrQaN2nrmIv+t/S/NAS+6EVul2q/VKTV UHqHhi88L7XBjHi2dceghiA2pP/P5J1cVt22n/ltXpBfe/2KsofZSYhQBFvMF4s1UFpD HlLirmhydj2UBnvVT+TgmnAmZIwum8A8247CSGR1YHPj6DtNs/odZxNms1PfggRaz1tx BD0teY2CO+nfwuO9UNUaw+vDwEIUs9iq0k0V9ngcntD/zyO1rrYFgGJAy1ZH26/uYUiu RoMw== X-Gm-Message-State: AOJu0YzMydQEJUIbO1ajt+FhFucCQY9/ARrUSMa3Uu2h9PZwSgbg8DSi pFCHpoMVJIfhttEMaO7JcExS9BnxgNHKkRmGVPEZ+FPt0t1ZOuCjcABKBGzCIC5zxQ== X-Gm-Gg: ASbGncuRwU9rCx8PMxnLrEnbHrY/1M/eT41NmhTtoM+sPiToxIlQREstoUvoeM1f7Fy RMTaCF8XnqizJWAKJQ+eV5i6Poa4b4P56kimSwjzwfmyx2Sn0be/YUYL0RZh80f5yQvcaZeGAz9 /QWfLXHcC4A0LewEEkEWFaeE2Gb3Gnk3u8snyBSDivdUPjqOqZLl0LVN5FXrI5hoeEvfT0LVFii 51IYfrbW08JbniF4I981lGeYpDhIVTvs/tl+pOXSMBNFaKJeyj4E3DO64At/J6lZe3EiA== X-Google-Smtp-Source: AGHT+IGnGbBT5pQ1LCvVk96UB3jRE7m6eM9HAZzuZD6lTMoWo1rxYwWVsg6pLenWqH/WsgfbhIvTFg== X-Received: by 2002:a17:903:41c5:b0:215:19ae:77bf with SMTP id d9443c01a7336-21a83f4ea67mr440232575ad.19.1736939033730; Wed, 15 Jan 2025 03:03:53 -0800 (PST) Received: from gnu-tgl-3.localdomain ([220.196.194.88]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21a9f137eccsm81041135ad.95.2025.01.15.03.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2025 03:03:53 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id E06F9C031A; Wed, 15 Jan 2025 19:03:47 +0800 (CST) From: "H.J. Lu" To: binutils@sourceware.org Cc: amodra@gmail.com, nickc@redhat.com Subject: [PATCH v2 2/2] ld: Update gld${EMULATION_NAME}_place_orphan for PE/PEP Date: Wed, 15 Jan 2025 19:03:47 +0800 Message-ID: <20250115110347.1718501-3-hjl.tools@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250115110347.1718501-1-hjl.tools@gmail.com> References: <20250115110347.1718501-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3018.2 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 Similar to ldelf_place_orphan, initialize hold from orig_hold at run-time in PE and PEP gld${EMULATION_NAME}_place_orphan. * emultempl/pe.em (orphan_init_done): Make it file scope. (gld${EMULATION_NAME}_finish): Set orphan_init_done to false for the object-only output. (gld${EMULATION_NAME}_place_orphan): Rename hold to orig_hold. Initialize hold from orig_hold at run-time. * emultempl/pep.em (orphan_init_done): Make it file scope. (gld${EMULATION_NAME}_finish): Set orphan_init_done to false for the object-only output. (gld${EMULATION_NAME}_place_orphan): Rename hold to orig_hold. Initialize hold from orig_hold at run-time. Signed-off-by: H.J. Lu --- ld/emultempl/pe.em | 32 +++++++++++++++++++++----------- ld/emultempl/pep.em | 32 +++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 1a458aa774d..5fb14c9a4a6 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -160,6 +160,7 @@ static char * thumb_entry_symbol = NULL; static lang_assignment_statement_type *image_base_statement = 0; static unsigned short pe_dll_characteristics = DEFAULT_DLL_CHARACTERISTICS; static bool insert_timestamp = true; +static bool orphan_init_done; static const char *emit_build_id; #ifdef PDB_H static int pdb; @@ -2032,6 +2033,10 @@ gld${EMULATION_NAME}_recognized_file (lang_input_statement_type *entry ATTRIBUTE static void gld${EMULATION_NAME}_finish (void) { + /* Support the object-only output. */ + if (config.emit_gnu_object_only) + orphan_init_done = false; + #if defined(TARGET_IS_armpe) || defined(TARGET_IS_arm_wince_pe) struct bfd_link_hash_entry * h; @@ -2191,7 +2196,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s, if (os == NULL) { - static struct orphan_save hold[] = + static struct orphan_save orig_hold[] = { { ".text", SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE, @@ -2209,6 +2214,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s, SEC_ALLOC, 0, 0, 0, 0 } }; + static struct orphan_save hold[ARRAY_SIZE (orig_hold)]; enum orphan_save_index { orphan_text = 0, @@ -2217,7 +2223,6 @@ gld${EMULATION_NAME}_place_orphan (asection *s, orphan_data, orphan_bss }; - static int orphan_init_done = 0; struct orphan_save *place; lang_output_section_statement_type *after; etree_type *address; @@ -2226,15 +2231,20 @@ gld${EMULATION_NAME}_place_orphan (asection *s, if (!orphan_init_done) { - struct orphan_save *ho; - for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho) - if (ho->name != NULL) - { - ho->os = lang_output_section_find (ho->name); - if (ho->os != NULL && ho->os->flags == 0) - ho->os->flags = ho->flags; - } - orphan_init_done = 1; + struct orphan_save *ho, *horig; + for (ho = hold, horig = orig_hold; + ho < hold + ARRAY_SIZE (hold); + ++ho, ++horig) + { + *ho = *horig; + if (ho->name != NULL) + { + ho->os = lang_output_section_find (ho->name); + if (ho->os != NULL && ho->os->flags == 0) + ho->os->flags = ho->flags; + } + } + orphan_init_done = true; } flags = s->flags; diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index 356b0e9f5da..df74352e4df 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -181,6 +181,7 @@ static int support_old_code = 0; static lang_assignment_statement_type *image_base_statement = 0; static unsigned short pe_dll_characteristics = DEFAULT_DLL_CHARACTERISTICS; static bool insert_timestamp = true; +static bool orphan_init_done; static const char *emit_build_id; #ifdef PDB_H static int pdb; @@ -1915,6 +1916,10 @@ gld${EMULATION_NAME}_recognized_file (lang_input_statement_type *entry ATTRIBUTE static void gld${EMULATION_NAME}_finish (void) { + /* Support the object-only output. */ + if (config.emit_gnu_object_only) + orphan_init_done = false; + is_underscoring (); finish_default (); @@ -2027,7 +2032,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s, if (os == NULL) { - static struct orphan_save hold[] = + static struct orphan_save orig_hold[] = { { ".text", SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE, @@ -2045,6 +2050,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s, SEC_ALLOC, 0, 0, 0, 0 } }; + static struct orphan_save hold[ARRAY_SIZE (orig_hold)]; enum orphan_save_index { orphan_text = 0, @@ -2053,7 +2059,6 @@ gld${EMULATION_NAME}_place_orphan (asection *s, orphan_data, orphan_bss }; - static int orphan_init_done = 0; struct orphan_save *place; lang_output_section_statement_type *after; etree_type *address; @@ -2062,15 +2067,20 @@ gld${EMULATION_NAME}_place_orphan (asection *s, if (!orphan_init_done) { - struct orphan_save *ho; - for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho) - if (ho->name != NULL) - { - ho->os = lang_output_section_find (ho->name); - if (ho->os != NULL && ho->os->flags == 0) - ho->os->flags = ho->flags; - } - orphan_init_done = 1; + struct orphan_save *ho, *horig; + for (ho = hold, horig = orig_hold; + ho < hold + ARRAY_SIZE (hold); + ++ho, ++horig) + { + *ho = *horig; + if (ho->name != NULL) + { + ho->os = lang_output_section_find (ho->name); + if (ho->os != NULL && ho->os->flags == 0) + ho->os->flags = ho->flags; + } + } + orphan_init_done = true; } flags = s->flags;