aboutsummaryrefslogtreecommitdiff
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-01-22 16:05:12 +1030
committerAlan Modra <amodra@gmail.com>2014-01-22 16:21:34 +1030
commit16e4ecc0dbe114cfc97fe2cd32a035ae4c37f22b (patch)
treea48afd646fe4928d6546cc9c25fba25543fbcdb4 /ld/ldlang.c
parentcda796e168a389624b4e06031922bf5eaf0b6f51 (diff)
downloadgdb-16e4ecc0dbe114cfc97fe2cd32a035ae4c37f22b.zip
gdb-16e4ecc0dbe114cfc97fe2cd32a035ae4c37f22b.tar.gz
gdb-16e4ecc0dbe114cfc97fe2cd32a035ae4c37f22b.tar.bz2
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.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 62f85bc..1a0d48f 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -67,6 +67,7 @@ static struct bfd_hash_table lang_definedness_table;
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 *);
@@ -105,6 +106,7 @@ bfd_boolean lang_float_flag = FALSE;
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 at the start of the traversal. */
@@ -1228,6 +1230,9 @@ lang_init (void)
sizeof (struct lang_definedness_hash_entry),
13))
einfo (_("%P%F: can not create hash table: %E\n"));
+
+ asneeded_list_head = NULL;
+ asneeded_list_tail = &asneeded_list_head;
}
void
@@ -1954,6 +1959,43 @@ lang_insert_orphan (asection *s,
}
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)
@@ -6629,6 +6671,8 @@ lang_process (void)
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 ();