From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2124) id E0EEB3858C74; Fri, 27 Jan 2023 12:01:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0EEB3858C74 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nick Clifton To: bfd-cvs@sourceware.org Subject: [binutils-gdb] Another fix for EFI generation with LTO enabled. X-Act-Checkin: binutils-gdb X-Git-Author: Nick Clifton X-Git-Refname: refs/heads/master X-Git-Oldrev: 31b4cda3d55258784dec140d44b0a66f14294ff6 X-Git-Newrev: 1c66b8a03989b963534689ec0a9cce57e419afd5 Message-Id: <20230127120140.E0EEB3858C74@sourceware.org> Date: Fri, 27 Jan 2023 12:01:40 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jan 2023 12:01:41 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D1c66b8a03989= b963534689ec0a9cce57e419afd5 commit 1c66b8a03989b963534689ec0a9cce57e419afd5 Author: Nick Clifton Date: Fri Jan 27 11:59:53 2023 +0000 Another fix for EFI generation with LTO enabled. =20 PR 29998 * pe-dll.c (build_filler_bfd): Initialise the next field of th= e filler input statement, so that it does not break the file chain. Diff: --- ld/ChangeLog | 6 ++++++ ld/pe-dll.c | 38 +++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 502da5e5943..48236585b57 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2023-01-27 Nick Clifton + + PR 29998 + * pe-dll.c (build_filler_bfd): Initialise the next field of the + filler input statement, so that it does not break the file chain. + 2023-01-24 Nick Clifton =20 PR 29998 diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 7b883edc3eb..49544babf11 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -1082,6 +1082,22 @@ build_filler_bfd (bool include_edata) =20 bfd_set_section_size (reloc_s, 0); =20 + /* 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->ne= xt + 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 elem= ent, + effectively deleting it from the input. In order to prevent this, the + assignment below fills in the next field of the statement that is abo= ut + to appended to the file chain. */ + if (file_chain.tail !=3D NULL) + filler_file->next =3D & (* file_chain.tail)->input_statement; + ldlang_add_file (filler_file); } =20 @@ -1542,18 +1558,25 @@ generate_reloc (bfd *abfd, struct bfd_link_info *in= fo) { arelent **relocs; int relsize, nrelocs; + asymbol **symbols; + + if (!bfd_generic_link_read_symbols (b)) + { + einfo (_("%F%P: %pB: could not read symbols: %E\n"), b); + return; + } + + symbols =3D bfd_get_outsymbols (b); =20 for (s =3D b->sections; s; s =3D s->next) { bfd_vma sec_vma; - asymbol **symbols; =20 /* If the section is not going to be output, then ignore it. */ if (s->output_section =3D=3D NULL) { - /* PR 29998: LTO processing can elminate whole code sections, - but it sets the output section to NULL rather than *ABS*. - Fix that here, then ignore the section. */ + /* FIXME: This should not happen. Convert to the correct + form here, but really, this should be investigated. */ s->output_section =3D bfd_abs_section_ptr; continue; } @@ -1574,13 +1597,6 @@ generate_reloc (bfd *abfd, struct bfd_link_info *inf= o) =20 sec_vma =3D s->output_section->vma + s->output_offset; =20 - if (!bfd_generic_link_read_symbols (b)) - { - einfo (_("%F%P: %pB: could not read symbols: %E\n"), b); - return; - } - - symbols =3D bfd_get_outsymbols (b); relsize =3D bfd_get_reloc_upper_bound (b, s); relocs =3D xmalloc (relsize); nrelocs =3D bfd_canonicalize_reloc (b, s, relocs, symbols);