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/ChangeLog | 20 +++++++-- ld/emultempl/elf32.em | 93 +++++++++++++++++++++++++++++++++++++++- ld/ld.texinfo | 22 ++++++++++ ld/testsuite/ChangeLog | 11 ++++- ld/testsuite/ld-elf/audit.exp | 65 ++++++++++++++++++++++++++++ ld/testsuite/ld-elf/audit.rd | 3 ++ ld/testsuite/ld-elf/depaudit.rd | 3 ++ ld/testsuite/ld-elf/depaudit2.rd | 3 ++ 8 files changed, 212 insertions(+), 8 deletions(-) create mode 100644 ld/testsuite/ld-elf/audit.exp create mode 100644 ld/testsuite/ld-elf/audit.rd create mode 100644 ld/testsuite/ld-elf/depaudit.rd create mode 100644 ld/testsuite/ld-elf/depaudit2.rd (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index 0bcb74d..7e8c310 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,15 @@ +2009-09-23 Matt Rice + + * 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. + 2009-09-23 Nick Clifton * po/vi.po: Updated Vietnamese translation. @@ -311,13 +323,13 @@ 2009-08-06 Michael Eager - * Makefile.am: Add eelf32mb_linux.o, eelf32microblaze.o to + * Makefile.am: Add eelf32mb_linux.o, eelf32microblaze.o to ALL_EMULATIONS, targets. * Makefile.in: Regenerate. * configure.tgt: Add microblaze*-linux*, microblaze* targets. * emulparams/elf32mb_linux.sh: New. * emulparams/elf32microblaze.sh. New. - * scripttempl/elfmicroblaze.sc: New. + * scripttempl/elfmicroblaze.sc: New. 2009-08-05 Trevor Smigiel @@ -408,7 +420,7 @@ * scripttempl/pep.sc: Put .eh_frame in its own section. * scripttempl/pe.sc: Ditto. - + 2009-06-26 Kai Tietz * scripttempl/pe.sc (.debug_pubtypes): Added section rule. @@ -941,7 +953,7 @@ 2009-02-24 Sandra Loosemore * ld.texinfo (Options): Correct typos in example. Recommend - using joined forms of syntax for passing options with arguments + using joined forms of syntax for passing options with arguments from a driver. (-a): Use consistent syntax for documenting option arguments. Clean up indexing and markup. 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 < + + * ld-elf/audit.exp: New. + * ld-elf/audit.rd: New. + * ld-elf/depaudit.rd: New. + * ld-elf/depaudit2.rd: New. + 2009-09-23 Jie Zhang * ld-srec/srec.exp: Add xfails for bfin-*-linux-uclibc. @@ -136,7 +143,7 @@ two new link tests. * ld-powerpc/tlsexe.d: Update for new __tls_get_addr stub. * ld-powerpc/tlsexe.g, * ld-powerpc/tlsexe.r, *ld-powerpc/tlsexe32.d, - * ld-powerpc/tlsexe32.g, * ld-powerpc/tlsexe32.r, + * ld-powerpc/tlsexe32.g, * ld-powerpc/tlsexe32.r, * ld-powerpc/tlsexetoc.d, * ld-powerpc/tlsexetoc.g, * ld-powerpc/tlsexetoc.r: Likewise. @@ -792,7 +799,7 @@ * ld-arm/arm-elf.exp (armeabitests): Add thumb2-bl-blx-interwork test. * ld-arm/thumb2-bl-blx-interwork.s: New. - * ld-arm/thumb2-bl-blx-interwork.d: New. + * ld-arm/thumb2-bl-blx-interwork.d: New. 2009-04-30 Nick Clifton diff --git a/ld/testsuite/ld-elf/audit.exp b/ld/testsuite/ld-elf/audit.exp new file mode 100644 index 0000000..407c61a --- /dev/null +++ b/ld/testsuite/ld-elf/audit.exp @@ -0,0 +1,65 @@ +# Expect script for various ELF tests. +# Copyright 2009 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# Exclude non-ELF targets. + +if ![is_elf_format] { + return +} + +# The following tests require running the executable generated by ld. +if ![isnative] { + return +} + +# Check if compiler works +if { [which $CC] == 0 } { + return +} + +set build_tests { + {"Run with -paudit.so" + "-Wl,--audit=tmpdir/audit.so" "" + {main.c} {{"readelf" {-d} "audit.rd"}} "audit.out"} + {"Run with -Paudit.so" + "-Wl,-Ptmpdir/audit.so" "" + {main.c} {{"readelf" {-d} "depaudit.rd"}} "depaudit.out"} + {"Run with --depaudit=audit.so" + "-Wl,--depaudit=tmpdir/audit.so" "" + {main.c} {{"readelf" {-d} "depaudit.rd"}} "depaudit2.out"} + {"Run with shared with --audit" + "-shared -Wl,--audit=tmpdir/audit.so" "-fPIC" + {main.c} {} "libusesaudit.so"} + {"Run with shared with --audit" + "-shared -Wl,--audit=tmpdir/audit.so -Wl,--audit=tmpdir/audit2.so \ + -Wl,--audit=tmpdir/audit3.so" + "-fPIC" + {main.c} {} "libusesaudit2.so"} + {"Run with -lusesaudit" + "-Ltmpdir/ -lusesaudit" "" + {main.c} {{"readelf" {-d} "depaudit.rd"}} "useslibusesaudit.out"} + {"Run with -lusesaudit -lusesaudit2" + "-Ltmpdir/ -lusesaudit -lusesaudit2" "" + {main.c} {{"readelf" {-d} "depaudit2.rd"}} "useslibusesaudit2.out"} +} + +run_cc_link_tests $build_tests + diff --git a/ld/testsuite/ld-elf/audit.rd b/ld/testsuite/ld-elf/audit.rd new file mode 100644 index 0000000..fd3b941 --- /dev/null +++ b/ld/testsuite/ld-elf/audit.rd @@ -0,0 +1,3 @@ +#... +.*Audit library: \[tmpdir/audit.so\].* +#pass diff --git a/ld/testsuite/ld-elf/depaudit.rd b/ld/testsuite/ld-elf/depaudit.rd new file mode 100644 index 0000000..98a2692 --- /dev/null +++ b/ld/testsuite/ld-elf/depaudit.rd @@ -0,0 +1,3 @@ +#... +.*Dependency audit library: \[tmpdir/audit.so\].* +#pass diff --git a/ld/testsuite/ld-elf/depaudit2.rd b/ld/testsuite/ld-elf/depaudit2.rd new file mode 100644 index 0000000..3554416 --- /dev/null +++ b/ld/testsuite/ld-elf/depaudit2.rd @@ -0,0 +1,3 @@ +#... +.*Dependency audit library: \[tmpdir/audit.so:tmpdir/audit2.so:tmpdir/audit3.so\].* +#pass -- cgit v1.1