Sourceware Bugzilla – Attachment 12318 Details for
Bug 25593
--as-needed breaks DT_NEEDED order with linker plugin
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Try this
0001-ld-Prepend-DT_NEEDED-after-all-IR-symbols-have-been-.patch (text/plain), 2.88 KB, created by
H.J. Lu
on 2020-02-24 18:09:52 UTC
(
hide
)
Description:
Try this
Filename:
MIME Type:
Creator:
H.J. Lu
Created:
2020-02-24 18:09:52 UTC
Size:
2.88 KB
patch
obsolete
>From c830f607510007c7dbbef67489425d98e90dd104 Mon Sep 17 00:00:00 2001 >From: "H.J. Lu" <hjl.tools@gmail.com> >Date: Mon, 24 Feb 2020 09:55:37 -0800 >Subject: [PATCH] ld: Prepend DT_NEEDED after all IR symbols have been claimed > >bfd/ > > PR ld/25593 > * elflink.c (_bfd_elf_add_dynamic_entry): Prepend DT_NEEDED tag > after all IR symbols have been claimed. > >include/ > > PR ld/25593 > * bfdlink.h (bfd_link_info): Add lto_plugin_all_symbols_read_done. > >ld/ > > PR ld/25593 > * plugin.c (plugin_call_all_symbols_read): Set > link_info.lto_plugin_all_symbols_read_done to TRUE if any IR > symbols have been claimed. >--- > bfd/elflink.c | 14 +++++++++++--- > include/bfdlink.h | 3 +++ > ld/plugin.c | 4 +++- > 3 files changed, 17 insertions(+), 4 deletions(-) > >diff --git a/bfd/elflink.c b/bfd/elflink.c >index 8e7ae2a160..4ed0652083 100644 >--- a/bfd/elflink.c >+++ b/bfd/elflink.c >@@ -3472,7 +3472,7 @@ _bfd_elf_add_dynamic_entry (struct bfd_link_info *info, > const struct elf_backend_data *bed; > asection *s; > bfd_size_type newsize; >- bfd_byte *newcontents; >+ bfd_byte *newcontents, *newlocation, *newdest; > Elf_Internal_Dyn dyn; > > hash_table = elf_hash_table (info); >@@ -3487,13 +3487,21 @@ _bfd_elf_add_dynamic_entry (struct bfd_link_info *info, > BFD_ASSERT (s != NULL); > > newsize = s->size + bed->s->sizeof_dyn; >- newcontents = (bfd_byte *) bfd_realloc (s->contents, newsize); >+ newcontents = (bfd_byte *) bfd_malloc (newsize); > if (newcontents == NULL) > return FALSE; > >+ newlocation = newcontents; >+ newdest = newcontents; >+ if (tag == DT_NEEDED && info->lto_plugin_all_symbols_read_done) >+ newdest += bed->s->sizeof_dyn; >+ else >+ newlocation += s->size; >+ memcpy (newdest, s->contents, s->size); >+ > dyn.d_tag = tag; > dyn.d_un.d_val = val; >- bed->s->swap_dyn_out (hash_table->dynobj, &dyn, newcontents + s->size); >+ bed->s->swap_dyn_out (hash_table->dynobj, &dyn, newlocation); > > s->size = newsize; > s->contents = newcontents; >diff --git a/include/bfdlink.h b/include/bfdlink.h >index 8d85530e39..505338cd63 100644 >--- a/include/bfdlink.h >+++ b/include/bfdlink.h >@@ -350,6 +350,9 @@ struct bfd_link_info > /* TRUE if the LTO plugin is active. */ > unsigned int lto_plugin_active: 1; > >+ /* TRUE if all symbols read hook of LTO plugin has been called. */ >+ unsigned int lto_plugin_all_symbols_read_done: 1; >+ > /* TRUE if global symbols in discarded sections should be stripped. */ > unsigned int strip_discarded: 1; > >diff --git a/ld/plugin.c b/ld/plugin.c >index f8d3ec8e8b..847e8cc844 100644 >--- a/ld/plugin.c >+++ b/ld/plugin.c >@@ -1304,7 +1304,9 @@ plugin_call_all_symbols_read (void) > called_plugin = curplug; > rv = (*curplug->all_symbols_read_handler) (); > called_plugin = NULL; >- if (rv != LDPS_OK) >+ if (rv == LDPS_OK) >+ link_info.lto_plugin_all_symbols_read_done = TRUE; >+ else > set_plugin_error (curplug->name); > } > curplug = curplug->next; >-- >2.24.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 25593
:
12318
|
12319
|
12320
|
12321