From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id C217F3858C39 for ; Tue, 31 Jan 2023 11:30:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C217F3858C39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102a.google.com with SMTP id c10-20020a17090a1d0a00b0022e63a94799so3770601pjd.2 for ; Tue, 31 Jan 2023 03:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=hEBDr7LnKN9sDgZTwKTq/2GTggHWFR4xnJcmnsNwSEQ=; b=SIZAx7u2R5TJ/cOASkLC/NcNV4QS+Mi0v8BhW6tQVADbZL7MbvjexUaMZ6tDZ4jNyM vTkxErJmwiY1Y05Do9j6ycNZOW0adb7SgOxrzyKpUge8wlBxG9oryqaYhj6UwKs/T5Xt EM46T4IdAeW8r6vTWJhjiEtTXhZAz3pE19JfN/6taLZSSfzf7oZMfUStUFf5TsmR0E3t schcfQQM/R2PenZs+T3HbiZeGbxmnkOu4stoGVSQzYXVptDqjQ3yvoswdgLrXA1ud5oS KqYTLhMBmhBObSwPV8jfCXA1m8/DmVLNkGFPmRHxaLf0oZsA0kN0+j+vew8ngHs93pGk okiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hEBDr7LnKN9sDgZTwKTq/2GTggHWFR4xnJcmnsNwSEQ=; b=ENS4VBTDNszpWzq18cYTsyN+8JaN6MFIa6aapVa18u8pBVRS7X/tJhS9lUax2ZgfSc QPgOGuoTD00HDBrN+uMj9icwTbvmVdKgiFvKjJfKDHfKinj0MdsxbaAEElte2txPRjGU eSGHJpWpg7hoUhp6FpNI25btuz2JT/xqxaxbHBy1knyRkztQMG8qFz4GmpAbwSBnXH32 v6MCJmQbimHxl7WM3Zj6+yLPUFQjCfAxvD34LafgMSbOxwR+mlAIQ43tAhQFziZOoNtC +ZzrmnFD/gzM8TWtewM3RtzxeMx2u+j3sAYupWvnORYYu5/Ymb+QEPGZNR8iJ+MinYUY NvTA== X-Gm-Message-State: AO0yUKX0bHNgojnrda1PFb0PmVRSsVbun+ORLgzrDYS4gIiTx2RKMQ3z Ud8qWTnvd2qAS1x6wcUBWeT9kYZJSH0= X-Google-Smtp-Source: AK7set8S3qFjSEGXZAGxsYQFk+2tZoCaW9/bCKQ0iFPSvttxjxbHgEbxjzFIsDf8PBE/cKJITVKWCA== X-Received: by 2002:a17:903:110e:b0:196:3acd:2829 with SMTP id n14-20020a170903110e00b001963acd2829mr27361942plh.59.1675164632680; Tue, 31 Jan 2023 03:30:32 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:83fe:90aa:98ff:94d7]) by smtp.gmail.com with ESMTPSA id c4-20020a170902b68400b0019644d4242dsm3346469pls.82.2023.01.31.03.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 03:30:32 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 1226111405A3; Tue, 31 Jan 2023 22:00:30 +1030 (ACDT) Date: Tue, 31 Jan 2023 22:00:30 +1030 From: Alan Modra To: binutils@sourceware.org Cc: Nick Clifton Subject: Re: Another fix for EFI generation with LTO enabled Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3035.1 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 List-Id: Revert 1c66b8a03989 and instead fix the broken list pointer. I verified that the PR testcase is fixed. We likely would have run into this bug much sooner except that crtn.o is usually linked last, which always results in an insertion earlier in the list. PR 29998 * pe-dll.c (build_filler_bfd): Revert last change. * ldlang.c (lang_process): When rescanning archives for lto, fix file_chain.tail pointer if the insert point happens to be at the end of the list. diff --git a/ld/ldlang.c b/ld/ldlang.c index b66d8c6bc1d..84a2914fc26 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -8017,6 +8017,8 @@ lang_process (void) *insert = &files.head->input_statement; files.head = (lang_statement_union_type *) *iter; *iter = temp; + if (file_chain.tail == (lang_statement_union_type **) insert) + file_chain.tail = (lang_statement_union_type **) iter; if (my_arch != NULL) { lang_input_statement_type *parent = bfd_usrdata (my_arch); diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 49544babf11..2956eef1ca9 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -1082,22 +1082,6 @@ build_filler_bfd (bool include_edata) bfd_set_section_size (reloc_s, 0); - /* FIXME: I am not sure if this is the right way to solve PR 29998. - It might be better to change ldlang.c:lang_statement_append() so that it - checks to see if *(list->tail) is non-NULL and if so, set element->next - to its contents. - - The issue is that this function is called after lang_process(). - lang_process () will have gone through any input archives, and if the - last input file is an archive then it will have left file_chain.tail - pointing to the last used element of that archive. Calling - ldlang_add_file() here then blows aaway the link to that archive element, - effectively deleting it from the input. In order to prevent this, the - assignment below fills in the next field of the statement that is about - to appended to the file chain. */ - if (file_chain.tail != NULL) - filler_file->next = & (* file_chain.tail)->input_statement; - ldlang_add_file (filler_file); } -- Alan Modra Australia Development Lab, IBM