/usr/src/binutils/patches/show-as-needed.diff is in binutils-source 2.24-5ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | # DP: Display the reference causing a shared library to be needed.
Adds a section for --as-needed libraries to a linker map file, similar
to what we do for archive libraries.
bfd/
* elflink.c (elf_link_add_object_symbols): Call minfo for --as-needed.
ld/
* ldlang.c (asneeded_list_head, asneeded_list_tail): New vars.
(lang_init): Initialise them.
(lang_print_asneeded): New function.
(lang_process): Call lang_print_asneeded.
* ldlang.h (struct asneeded_minfo): New.
(asneeded_list_tail): Declare.
* ldmain.c (add_archive_element): Improve archive map heading.
* ldmisc.c (minfo): Stash --as-needed info.
Index: b/bfd/elflink.c
===================================================================
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4438,6 +4438,9 @@
int ret;
const char *soname = elf_dt_name (abfd);
+ info->callbacks->minfo ("%!", soname, old_bfd,
+ h->root.root.string);
+
/* A symbol from a library loaded via DT_NEEDED of some
other library is referenced by a regular object.
Add a DT_NEEDED entry for it. Issue an error if
Index: b/ld/ldlang.c
===================================================================
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -67,6 +67,7 @@
static lang_statement_list_type *stat_save[10];
static lang_statement_list_type **stat_save_ptr = &stat_save[0];
static struct unique_sections *unique_section_list;
+static struct asneeded_minfo *asneeded_list_head;
/* Forward declarations. */
static void exp_init_os (etree_type *);
@@ -106,6 +107,7 @@
bfd_boolean delete_output_file_on_failure = FALSE;
struct lang_phdr *lang_phdr_list;
struct lang_nocrossrefs *nocrossref_list;
+struct asneeded_minfo **asneeded_list_tail;
/* Functions that traverse the linker script and might evaluate
DEFINED() need to increment this. */
@@ -1233,6 +1235,9 @@
sizeof (struct lang_definedness_hash_entry),
3))
einfo (_("%P%F: can not create hash table: %E\n"));
+
+ asneeded_list_head = NULL;
+ asneeded_list_tail = &asneeded_list_head;
}
void
@@ -1951,6 +1956,43 @@
}
static void
+lang_print_asneeded (void)
+{
+ struct asneeded_minfo *m;
+ char buf[100];
+
+ if (asneeded_list_head == NULL)
+ return;
+
+ sprintf (buf, _("\nAs-needed library included "
+ "to satisfy reference by file (symbol)\n\n"));
+ minfo ("%s", buf);
+
+ for (m = asneeded_list_head; m != NULL; m = m->next)
+ {
+ size_t len;
+
+ minfo ("%s", m->soname);
+ len = strlen (m->soname);
+
+ if (len >= 29)
+ {
+ print_nl ();
+ len = 0;
+ }
+ while (len < 30)
+ {
+ print_space ();
+ ++len;
+ }
+
+ if (m->ref != NULL)
+ minfo ("%B ", m->ref);
+ minfo ("(%T)\n", m->name);
+ }
+}
+
+static void
lang_map_flags (flagword flag)
{
if (flag & SEC_ALLOC)
@@ -6668,6 +6710,8 @@
link_info.gc_sym_list = ldlang_undef_chain_list_head;
ldemul_after_open ();
+ if (config.map_file != NULL)
+ lang_print_asneeded ();
bfd_section_already_linked_table_free ();
Index: b/ld/ldlang.h
===================================================================
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -468,6 +468,14 @@
lang_output_section_statement_type **os_tail;
};
+struct asneeded_minfo
+{
+ struct asneeded_minfo *next;
+ const char *soname;
+ bfd *ref;
+ const char *name;
+};
+
extern struct lang_phdr *lang_phdr_list;
extern struct lang_nocrossrefs *nocrossref_list;
extern const char *output_target;
@@ -486,6 +494,7 @@
extern lang_statement_list_type input_file_chain;
extern int lang_statement_iteration;
+extern struct asneeded_minfo **asneeded_list_tail;
extern void lang_init
(void);
Index: b/ld/ldmain.c
===================================================================
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -840,7 +840,8 @@
{
char buf[100];
- sprintf (buf, _("Archive member included because of file (symbol)\n\n"));
+ sprintf (buf, _("Archive member included "
+ "to satisfy reference by file (symbol)\n\n"));
minfo ("%s", buf);
header_printed = TRUE;
}
Index: b/ld/ldmisc.c
===================================================================
--- a/ld/ldmisc.c
+++ b/ld/ldmisc.c
@@ -484,7 +484,22 @@
va_list arg;
va_start (arg, fmt);
- vfinfo (config.map_file, fmt, arg, FALSE);
+ if (fmt[0] == '%' && fmt[1] == '!' && fmt[2] == 0)
+ {
+ /* Stash info about --as-needed shared libraries. Print
+ later so they don't appear intermingled with archive
+ library info. */
+ struct asneeded_minfo *m = xmalloc (sizeof *m);
+
+ m->next = NULL;
+ m->soname = va_arg (arg, const char *);
+ m->ref = va_arg (arg, bfd *);
+ m->name = va_arg (arg, const char *);
+ *asneeded_list_tail = m;
+ asneeded_list_tail = &m->next;
+ }
+ else
+ vfinfo (config.map_file, fmt, arg, FALSE);
va_end (arg);
}
}
|