From 7ee314faa48ba637641861e0288736cb4666f940 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 23 Sep 2009 13:54:29 +0000 Subject: bfd/ * bfd-in.h (bfd_elf_size_dynamic_sections): Add audit and depaudit arguments. * elflink.c (bfd_elf_size_dynamic_sections): Generate DT_AUDIT, DT_DEPAUDIT from audit/depaudit arguments. (elf_finalize_dynstr): Finalize DT_AUDIT and DT_DEPAUDIT strtab entries. (elf_link_add_object_symbols): Set dt_audit target data when finding a DT_AUDIT. * bfd-in2.h: Regenerate. * bfd-elf.h: Add dt_audit to elf_obj_tdata, and elf_dt_audit macro. ld/ * emultempl/elf32.em (gld${EMULATION_NAME}_add_options): Add --audit, --depaudit, and -P options. (gld${EULATION_NAME}_handle_options): Ditto. (gld${EULATION_NAME}_list_options): Ditto. (gld${EMULATION_NAME}_append_to_separated_string): New function for handling rpath-like colon separated strings. (gld${EMULATION_NAME}_before_allocation): Pass the audit and depaudit libs to bfd. Propagate DT_AUDIT from needed libs to depaudit. * ld.texinfo: Document new options. ld/testsuite/ * ld-elf/audit.exp: New. * ld-elf/audit.rd: New. * ld-elf/depaudit.rd: New. * ld-elf/depaudit2.rd: New. --- ld/emultempl/elf32.em | 93 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 2 deletions(-) (limited to 'ld/emultempl') diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 9518714..f7b70ac 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -157,6 +157,10 @@ static lang_input_statement_type *global_found; static struct bfd_link_needed_list *global_vercheck_needed; static bfd_boolean global_vercheck_failed; +/* These variables are used to implement target options */ + +static char *audit; /* colon (typically) separated list of libs */ +static char *depaudit; /* colon (typically) separated list of libs */ /* On Linux, it's possible to have different versions of the same shared library linked against different versions of libc. The @@ -1396,6 +1400,46 @@ if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation; fi fragment <type == bfd_link_elf_hash_table) _bfd_elf_tls_setup (link_info.output_bfd, &link_info); @@ -1418,9 +1463,39 @@ gld${EMULATION_NAME}_before_allocation (void) rpath = command_line.rpath; if (rpath == NULL) rpath = (const char *) getenv ("LD_RUN_PATH"); + + for (abfd = link_info.input_bfds; abfd; abfd = abfd->link_next) + { + const char *audit_libs = elf_dt_audit (abfd); + + /* If the input bfd contains an audit entry, we need to add it as + a dep audit entry. */ + if (audit_libs && *audit_libs != '\0') + { + char *cp = xstrdup (audit_libs); + do + { + int more = 0; + char *cp2 = strchr (cp, config.rpath_separator); + + if (cp2) + { + *cp2 = '\0'; + more = 1; + } + + if (cp != NULL && *cp != '\0') + gld${EMULATION_NAME}_append_to_separated_string (&depaudit, cp); + + cp = more ? ++cp2 : NULL; + } + while (cp != NULL); + } + } + if (! (bfd_elf_size_dynamic_sections (link_info.output_bfd, command_line.soname, rpath, - command_line.filter_shlib, + command_line.filter_shlib, audit, depaudit, (const char * const *) command_line.auxiliary_filters, &link_info, &sinterp, lang_elf_version_info))) einfo ("%P%F: failed to set dynamic section sizes: %E\n"); @@ -2007,15 +2082,18 @@ fragment <