aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authornobody <>2009-01-03 17:43:47 +0000
committernobody <>2009-01-03 17:43:47 +0000
commit98efba94c8d14ffea399e9a1859a6ced1e4869dc (patch)
tree03a93ec394427860fa23e131b4c834b417c614bf /gold
parente7c73f57df961ee3db9b81f5dec5b3c5d9c3d288 (diff)
downloadgdb-binutils-arc-20081103-branchpoint.zip
gdb-binutils-arc-20081103-branchpoint.tar.gz
gdb-binutils-arc-20081103-branchpoint.tar.bz2
This commit was manufactured by cvs2svn to create branchbinutils-arc-20081103-branchpointarc-20081103-branchpointarc-20081103-branch
'arc-20081103-branch'. Sprout from binutils-2_19-branch 2008-09-08 08:56:58 UTC nobody 'This commit was manufactured by cvs2svn to create branch 'binutils-' Cherrypick from binutils-2_19-branch 2009-01-03 17:43:46 UTC nobody 'This commit was manufactured by cvs2svn to create branch 'binutils-': gas/testsuite/gas/ppc/common.d gas/testsuite/gas/ppc/common.s ld/testsuite/ld-powerpc/attr-gnu-12-1.s ld/testsuite/ld-powerpc/attr-gnu-12-11.d ld/testsuite/ld-powerpc/attr-gnu-12-2.s ld/testsuite/ld-powerpc/attr-gnu-12-21.d Cherrypick from binutils-2_19-branch 2008-09-11 09:06:56 UTC nobody 'This commit was manufactured by cvs2svn to create branch 'binutils-': gprof/po/ro.po Cherrypick from binutils-2_19-branch 2008-09-26 07:02:45 UTC nobody 'This commit was manufactured by cvs2svn to create branch 'binutils-': gas/config/te-solaris.h Cherrypick from master 2008-11-02 23:59:45 UTC Alan Modra <amodra@gmail.com> 'daily update': ChangeLog Makefile.def Makefile.in Makefile.tpl bfd/ChangeLog bfd/Makefile.am bfd/Makefile.in bfd/aclocal.m4 bfd/bfd-in2.h bfd/cache.c bfd/coff64-rs6000.c bfd/coffgen.c bfd/cofflink.c bfd/config.in bfd/configure bfd/configure.in bfd/doc/Makefile.in bfd/dwarf2.c bfd/elf-bfd.h bfd/elf-eh-frame.c bfd/elf.c bfd/elf32-cris.c bfd/elf32-ppc.c bfd/elf32-sh-symbian.c bfd/elf32-spu.c bfd/elf32-xtensa.c bfd/elf64-ppc.c bfd/elflink.c bfd/elfxx-mips.c bfd/libbfd.h bfd/linker.c bfd/po/id.po bfd/po/vi.po bfd/reloc.c bfd/version.h binutils/BRANCHES binutils/ChangeLog binutils/Makefile.in binutils/aclocal.m4 binutils/config.in binutils/configure binutils/configure.in binutils/dlltool.c binutils/doc/Makefile.in binutils/dwarf.c binutils/embedspu.sh binutils/objcopy.c binutils/po/id.po binutils/po/sv.po binutils/readelf.c binutils/stabs.c binutils/testsuite/ChangeLog binutils/testsuite/binutils-all/group-2.s binutils/testsuite/binutils-all/group-3.s binutils/testsuite/binutils-all/group-4.s binutils/testsuite/binutils-all/group.s binutils/testsuite/binutils-all/objcopy.exp binutils/testsuite/binutils-all/objdump.W binutils/testsuite/binutils-all/strip-4.d binutils/testsuite/binutils-all/strip-5.d binutils/testsuite/binutils-all/strip-6.d binutils/testsuite/binutils-all/strip-7.d binutils/testsuite/binutils-all/strip-8.d binutils/testsuite/binutils-all/strip-9.d binutils/windmc.c binutils/windres.c configure configure.ac gas/ChangeLog gas/Makefile.am gas/Makefile.in gas/NEWS gas/aclocal.m4 gas/app.c gas/config.in gas/config/bfin-parse.y gas/config/tc-bfin.c gas/config/tc-cris.c gas/config/tc-frv.c gas/config/tc-frv.h gas/config/tc-hppa.c gas/config/tc-hppa.h gas/config/tc-i386.c gas/config/tc-i386.h gas/config/tc-m68k.c gas/config/tc-mips.c gas/config/tc-mmix.c gas/config/tc-mmix.h gas/config/tc-mn10300.h gas/config/tc-ns32k.c gas/config/tc-ppc.c gas/config/tc-sh.h gas/config/tc-sh64.h gas/config/tc-tic4x.c gas/config/tc-xtensa.c gas/config/tc-xtensa.h gas/config/tc-z80.c gas/configure gas/configure.in gas/configure.tgt gas/doc/Makefile.in gas/doc/as.texinfo gas/doc/internals.texi gas/dw2gencfi.c gas/frags.c gas/hash.c gas/listing.c gas/po/id.po gas/read.c gas/symbols.c gas/testsuite/ChangeLog gas/testsuite/gas/all/gas.exp gas/testsuite/gas/cfi/cfi-alpha-1.d gas/testsuite/gas/cfi/cfi-alpha-3.d gas/testsuite/gas/cfi/cfi-arm-1.d gas/testsuite/gas/cfi/cfi-common-1.d gas/testsuite/gas/cfi/cfi-common-2.d gas/testsuite/gas/cfi/cfi-common-3.d gas/testsuite/gas/cfi/cfi-common-4.d gas/testsuite/gas/cfi/cfi-common-5.d gas/testsuite/gas/cfi/cfi-common-6.d gas/testsuite/gas/cfi/cfi-hppa-1.d gas/testsuite/gas/cfi/cfi-i386-2.d gas/testsuite/gas/cfi/cfi-i386.d gas/testsuite/gas/cfi/cfi-m68k.d gas/testsuite/gas/cfi/cfi-mips-1.d gas/testsuite/gas/cfi/cfi-ppc-1.d gas/testsuite/gas/cfi/cfi-s390-1.d gas/testsuite/gas/cfi/cfi-s390x-1.d gas/testsuite/gas/cfi/cfi-sh-1.d gas/testsuite/gas/cfi/cfi-sparc-1.d gas/testsuite/gas/cfi/cfi-sparc64-1.d gas/testsuite/gas/cfi/cfi-x86_64.d gas/testsuite/gas/cris/rd-tls-1.d gas/testsuite/gas/cris/rd-tls-1.s gas/testsuite/gas/cris/rd-tls-2.d gas/testsuite/gas/cris/rd-tls-2.s gas/testsuite/gas/cris/tls-err-1.s gas/testsuite/gas/cris/tls-err-2.s gas/testsuite/gas/cris/tls-err-3.s gas/testsuite/gas/elf/elf.exp gas/testsuite/gas/i386/i386.exp gas/testsuite/gas/i386/nops-5-i686.d gas/testsuite/gas/i386/nops-5.d gas/testsuite/gas/i386/nops-5.s gas/testsuite/gas/i386/sse2avx.d gas/testsuite/gas/i386/sse2avx.s gas/testsuite/gas/i386/x86-64-nops-5-k8.d gas/testsuite/gas/i386/x86-64-nops-5.d gas/testsuite/gas/i386/x86-64-sse2avx.d gas/testsuite/gas/i386/x86-64-sse2avx.s gas/testsuite/gas/ppc/power4_32.d gas/testsuite/gas/ppc/power4_32.s gas/testsuite/gas/ppc/power6.d gas/testsuite/gas/ppc/power6.s gas/testsuite/gas/ppc/ppc.exp gas/testsuite/gas/s390/esa-g5.d gas/testsuite/gas/s390/esa-g5.s gas/testsuite/gas/s390/esa-z990.d gas/testsuite/gas/s390/esa-z990.s gas/testsuite/gas/s390/zarch-z900.d gas/testsuite/gas/s390/zarch-z900.s gas/testsuite/gas/s390/zarch-z990.d gas/testsuite/gas/s390/zarch-z990.s gas/testsuite/gas/z80/arith.d gas/testsuite/gas/z80/arith.s gas/testsuite/gas/z80/bit.d gas/testsuite/gas/z80/bit.s gas/testsuite/gas/z80/block.d gas/testsuite/gas/z80/block.s gas/testsuite/gas/z80/branch.d gas/testsuite/gas/z80/branch.s gas/testsuite/gas/z80/inout.d gas/testsuite/gas/z80/inout.s gas/testsuite/gas/z80/ld-group.d gas/testsuite/gas/z80/ld-group.s gas/testsuite/gas/z80/misc.d gas/testsuite/gas/z80/misc.s gas/testsuite/gas/z80/rotate.d gas/testsuite/gas/z80/rotate.s gas/testsuite/gas/z80/z80.exp gas/write.c gold/ChangeLog gold/Makefile.am gold/Makefile.in gold/archive.cc gold/archive.h gold/config.in gold/configure gold/configure.ac gold/descriptors.cc gold/descriptors.h gold/fileread.cc gold/fileread.h gold/gold.cc gold/i386.cc gold/layout.cc gold/main.cc gold/mapfile.cc gold/object.cc gold/object.h gold/options.cc gold/options.h gold/output.cc gold/output.h gold/plugin.cc gold/plugin.h gold/powerpc.cc gold/readsyms.cc gold/reloc.cc gold/resolve.cc gold/sparc.cc gold/symtab.cc gold/symtab.h gold/target-reloc.h gold/target.h gold/testsuite/Makefile.am gold/testsuite/Makefile.in gold/testsuite/plugin_test.c gold/testsuite/plugin_test_1.sh gold/testsuite/plugin_test_2.sh gold/testsuite/thin_archive_main.cc gold/testsuite/thin_archive_test_1.cc gold/testsuite/thin_archive_test_2.cc gold/testsuite/thin_archive_test_3.cc gold/testsuite/thin_archive_test_4.cc gold/x86_64.cc gprof/ChangeLog gprof/Makefile.in gprof/aclocal.m4 gprof/configure gprof/configure.in gprof/gconfig.in gprof/po/vi.po include/ChangeLog include/demangle.h include/elf/ChangeLog include/elf/cris.h include/elf/dwarf2.h include/elf/ppc.h include/obstack.h include/plugin-api.h ld/ChangeLog ld/Makefile.am ld/Makefile.in ld/aclocal.m4 ld/config.in ld/configure ld/configure.in ld/emulparams/arcelf.sh ld/emulparams/criself.sh ld/emulparams/crislinux.sh ld/emulparams/elf32_i860.sh ld/emulparams/elf32_i960.sh ld/emulparams/elf32_sparc.sh ld/emulparams/elf32_spu.sh ld/emulparams/elf32am33lin.sh ld/emulparams/elf32fr30.sh ld/emulparams/elf32ip2k.sh ld/emulparams/elf32mcore.sh ld/emulparams/elf32openrisc.sh ld/emulparams/elf32ppccommon.sh ld/emulparams/elf32ppcwindiss.sh ld/emulparams/elf32vax.sh ld/emulparams/elf64_s390.sh ld/emulparams/elf64_sparc.sh ld/emulparams/elf64alpha.sh ld/emulparams/elf64mmix.sh ld/emulparams/elf64ppc.sh ld/emulparams/elf_i386.sh ld/emulparams/elf_i386_be.sh ld/emulparams/elf_i386_ldso.sh ld/emulparams/elf_i386_vxworks.sh ld/emulparams/elf_s390.sh ld/emulparams/elf_x86_64.sh ld/emulparams/h8300elf.sh ld/emulparams/hppa64linux.sh ld/emulparams/hppalinux.sh ld/emulparams/i386lynx.sh ld/emulparams/i386moss.sh ld/emulparams/i386nto.sh ld/emulparams/m68kelf.sh ld/emulparams/mn10200.sh ld/emulparams/or32elf.sh ld/emulparams/pjelf.sh ld/emulparams/ppclynx.sh ld/emulparams/scoreelf.sh ld/emulparams/shelf.sh ld/emulparams/shelf32.sh ld/emulparams/shelf_nto.sh ld/emulparams/shelf_vxworks.sh ld/emulparams/shlelf32_linux.sh ld/emulparams/shlelf_linux.sh ld/emulparams/shlelf_nto.sh ld/emultempl/armelf.em ld/emultempl/beos.em ld/emultempl/elf32.em ld/emultempl/genelf.em ld/emultempl/mmo.em ld/emultempl/pe.em ld/emultempl/pep.em ld/emultempl/spuelf.em ld/emultempl/sunos.em ld/ldemul.c ld/ldemul.h ld/ldexp.c ld/ldlang.c ld/ldlang.h ld/pe-dll.c ld/po/id.po ld/po/vi.po ld/scripttempl/avr.sc ld/scripttempl/elf.sc ld/testsuite/ChangeLog ld/testsuite/ld-elf/comm1.c ld/testsuite/ld-elf/eh-frame-hdr.d ld/testsuite/ld-elf/eh-group.exp ld/testsuite/ld-elf/eh-group1.s ld/testsuite/ld-elf/eh-group2.s ld/testsuite/ld-elf/eh1.d ld/testsuite/ld-elf/eh2.d ld/testsuite/ld-elf/eh3.d ld/testsuite/ld-elf/eh4.d ld/testsuite/ld-elf/eh5.d ld/testsuite/ld-elf/eh5b.s ld/testsuite/ld-elf/eh6.d ld/testsuite/ld-elf/extract-symbol-1sec.d ld/testsuite/ld-elf/func1.c ld/testsuite/ld-elf/group4.d ld/testsuite/ld-elf/group5.d ld/testsuite/ld-elf/group6.d ld/testsuite/ld-elf/group7.d ld/testsuite/ld-elf/shared.exp ld/testsuite/ld-elf/stab.d ld/testsuite/ld-elfcomm/common1b.c ld/testsuite/ld-gc/gc.c ld/testsuite/ld-ia64/tlsbin.rd ld/testsuite/ld-ia64/tlspic.rd ld/testsuite/ld-mips-elf/eh-frame1-n32.d ld/testsuite/ld-mips-elf/eh-frame1-n64.d ld/testsuite/ld-mips-elf/eh-frame2-n32.d ld/testsuite/ld-mips-elf/eh-frame2-n64.d ld/testsuite/ld-mips-elf/eh-frame3.d ld/testsuite/ld-mips-elf/eh-frame4.d ld/testsuite/ld-mips-elf/reloc-estimate-1.d ld/testsuite/ld-powerpc/powerpc.exp ld/testsuite/ld-powerpc/vxworks1-lib.rd ld/testsuite/ld-shared/main.c ld/testsuite/lib/ld-lib.exp libiberty/ChangeLog libiberty/Makefile.in libiberty/config.in libiberty/configure libiberty/configure.ac libiberty/cp-demangle.c libiberty/cp-demangle.h libiberty/testsuite/demangle-expected libiberty/xstrdup.c libtool.m4 ltgcc.m4 ltmain.sh ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4 opcodes/ChangeLog opcodes/Makefile.am opcodes/Makefile.in opcodes/aclocal.m4 opcodes/configure opcodes/configure.in opcodes/i386-gen.c opcodes/i386-opc.tbl opcodes/i386-tbl.h opcodes/po/fr.po opcodes/po/vi.po opcodes/s390-opc.c opcodes/s390-opc.txt opcodes/z80-dis.c
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog176
-rw-r--r--gold/Makefile.am9
-rw-r--r--gold/Makefile.in14
-rw-r--r--gold/archive.cc46
-rw-r--r--gold/archive.h2
-rw-r--r--gold/config.in3
-rwxr-xr-xgold/configure41
-rw-r--r--gold/configure.ac14
-rw-r--r--gold/descriptors.cc22
-rw-r--r--gold/descriptors.h12
-rw-r--r--gold/fileread.cc23
-rw-r--r--gold/fileread.h13
-rw-r--r--gold/gold.cc12
-rw-r--r--gold/i386.cc12
-rw-r--r--gold/layout.cc4
-rw-r--r--gold/main.cc5
-rw-r--r--gold/mapfile.cc2
-rw-r--r--gold/object.cc14
-rw-r--r--gold/object.h29
-rw-r--r--gold/options.cc25
-rw-r--r--gold/options.h40
-rw-r--r--gold/output.cc10
-rw-r--r--gold/output.h4
-rw-r--r--gold/plugin.cc984
-rw-r--r--gold/plugin.h457
-rw-r--r--gold/powerpc.cc2
-rw-r--r--gold/readsyms.cc76
-rw-r--r--gold/reloc.cc20
-rw-r--r--gold/resolve.cc19
-rw-r--r--gold/sparc.cc2
-rw-r--r--gold/symtab.cc136
-rw-r--r--gold/symtab.h26
-rw-r--r--gold/target-reloc.h6
-rw-r--r--gold/target.h4
-rw-r--r--gold/testsuite/Makefile.am80
-rw-r--r--gold/testsuite/Makefile.in231
-rw-r--r--gold/testsuite/plugin_test.c427
-rwxr-xr-xgold/testsuite/plugin_test_1.sh56
-rwxr-xr-xgold/testsuite/plugin_test_2.sh54
-rw-r--r--gold/testsuite/thin_archive_main.cc39
-rw-r--r--gold/testsuite/thin_archive_test_1.cc37
-rw-r--r--gold/testsuite/thin_archive_test_2.cc37
-rw-r--r--gold/testsuite/thin_archive_test_3.cc37
-rw-r--r--gold/testsuite/thin_archive_test_4.cc35
-rw-r--r--gold/x86_64.cc12
45 files changed, 3177 insertions, 132 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index cac87e6..e13fa98 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,179 @@
+2008-10-07 Cary Coutant <ccoutant@google.com>
+
+ * options.c (General_options::finalize): Add check for -static and
+ -shared.
+ * gold.cc (queue_middle_tasks): Assert that list of dynamic objects
+ is not empty.
+
+2008-10-02 Cary Coutant <ccoutant@google.com>
+
+ * plugin.cc (make_sized_plugin_object): Fix conditional
+ compilation to work when not all targets are enabled.
+
+2008-09-29 Cary Coutant <ccoutant@google.com>
+
+ * archive.cc (Archive::get_file_and_offset): Use filename instead
+ of name to get library path.
+ (Archive::include_member): Unlock external member of a thin archive.
+
+ * testsuite/Makefile.am (TEST_AR): New variable.
+ (thin_archive_test_1): New test.
+ (thin_archive_test_2): New test.
+ * testsuite/Makefile.in: Regenerate.
+ * testsuite/thin_archive_main.cc: New file.
+ * testsuite/thin_archive_test_1.cc: New file.
+ * testsuite/thin_archive_test_2.cc: New file.
+ * testsuite/thin_archive_test_3.cc: New file.
+ * testsuite/thin_archive_test_4.cc: New file.
+
+2008-09-29 Cary Coutant <ccoutant@google.com>
+
+ * mapfile.cc (Mapfile::print_input_section): Change -1U to -1ULL.
+ * object.cc (Sized_relobj::do_layout): Use constant invalid_address
+ instead of -1U.
+ (Sized_relobj::do_finalize_local_symbols): Likewise.
+ (Sized_relobj::map_to_kept_section): Likewise.
+ * object.h (Sized_relobj::invalid_address): New constant.
+ (Sized_relobj::do_output_section_offset): Check for invalid_address
+ and return -1ULL.
+ * output.cc (Output_reloc::local_section_offset): Use constant
+ invalid_address instead of -1U.
+ (Output_reloc::get_address): Likewise.
+ (Output_section::output_address): Change -1U to -1ULL.
+ * output.h (Output_reloc::invalid_address): New constant.
+ * reloc.cc (Sized_relobj::write_sections): Use constant
+ invalid_address instead of -1U.
+ (Sized_relobj::relocate_sections): Likewise.
+ * symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol
+ values for merge sections.
+ * target-reloc.h (relocate_for_relocatable): Use constant
+ invalid_address instead of -1U.
+
+2008-09-19 Cary Coutant <ccoutant@google.com>
+
+ Add plugin functionality for link-time optimization (LTO).
+ * configure.ac (plugins): Add --enable-plugins option.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+ * Makefile.am (LIBDL): New variable.
+ (CCFILES): Add plugin.cc.
+ (HFILES): Add plugin.h.
+ (ldadd_var): Add LIBDL.
+ * Makefile.in: Regenerate.
+
+ * archive.cc: Include "plugin.h".
+ (Archive::setup): Don't preread archive symbols when using a plugin.
+ (Archive::get_file_and_offset): Add memsize parameter. Change callers.
+ (Archive::get_elf_object_for_member): Call plugin hooks for claiming
+ files.
+ (Archive::include_member): Add symbols from plugin objects.
+ * archive.h (Archive::get_file_and_offset): Add memsize parameter.
+ * descriptors.cc (Descriptors::open): Check for file descriptors
+ abandoned by plugins.
+ (Descriptors::claim_for_plugin): New function.
+ * descriptors.h (Descriptors::claim_for_plugin): New function.
+ (Open_descriptor::is_claimed): New field.
+ (claim_descriptor_for_plugin): New function.
+ * fileread.cc (File_read::claim_for_plugin): New function.
+ * fileread.h (File_read::claim_for_plugin): New function.
+ (File_read::descriptor): New function.
+ * gold.cc: Include "plugin.h".
+ (queue_initial_tasks): Add task to call plugin hooks for generating
+ new object files.
+ * main.cc: Include "plugin.h".
+ (main): Load plugin libraries.
+ * object.h (Pluginobj): Declare.
+ (Object::pluginobj): New function.
+ (Object::do_pluginobj): New function.
+ (Object::set_target): New function.
+ * options.cc: Include "plugin.h".
+ (General_options::parse_plugin): New function.
+ (General_options::General_options): Initialize plugins_ field.
+ (General_options::add_plugin): New function.
+ * options.h (Plugin_manager): Declare.
+ (General_options): Add --plugin option.
+ (General_options::has_plugins): New function.
+ (General_options::plugins): New function.
+ (General_options::add_plugin): New function.
+ (General_options::plugins_): New field.
+ * plugin.cc: New file.
+ * plugin.h: New file.
+ * readsyms.cc: Include "plugin.h".
+ (Read_symbols::do_read_symbols): Check for archive before checking
+ for ELF file. Call plugin hooks to claim files.
+ * resolve.cc (Symbol_table::resolve): Record when symbol is referenced
+ from a real object file; force override when processing replacement
+ files.
+ * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field.
+ (Symbol::init_base_object): Likewise.
+ (Symbol::init_base_output_data): Likewise.
+ (Symbol::init_base_output_segment): Likewise.
+ (Symbol::init_base_constant): Likewise.
+ (Symbol::init_base_undefined): Likewise.
+ (Symbol::output_section): Assert that object is not a plugin.
+ (Symbol_table::add_from_pluginobj): New function.
+ (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as
+ undefined.
+ (Symbol_table::sized_write_globals): Likewise.
+ (Symbol_table::add_from_pluginobj): Instantiate template.
+ * symtab.h (Sized_pluginobj): Declare.
+ (Symbol::in_real_elf): New function.
+ (Symbol::set_in_real_elf): New function.
+ (Symbol::in_real_elf_): New field.
+ (Symbol_table::add_from_pluginobj): New function.
+
+ * testsuite/Makefile.am (AM_CFLAGS): New variable.
+ (LIBDL): New variable.
+ (LDADD): Add LIBDL.
+ (check_PROGRAMS): Add plugin_test_1 and plugin_test_2.
+ (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh.
+ (check_DATA): Add plugin_test_1.err and plugin_test_2.err.
+ (MOSTLYCLEANFILES): Likewise.
+ * testsuite/Makefile.in: Regenerate.
+ * testsuite/plugin_test.c: New file.
+ * testsuite/plugin_test_1.sh: New file.
+ * testsuite/plugin_test_2.sh: New file.
+
+2008-09-16 Ian Lance Taylor <iant@google.com>
+
+ * target-reloc.h (relocate_section): Check whether a symbol is
+ defined by the ABI before reporting an undefined symbol error.
+ * target.h (Target::is_defined_by_abi): Make parameter const.
+ (Target::do_is_defined_by_abi): Likewise.
+ * i386.cc (Target_i386::do_is_defined_by_abi): Likewise.
+ * powerpc.cc (Target_powerpc::do_is_defined_by_abi): Likewise.
+ * sparc.cc (Target_sparc::do_is_defined_by_abi): Likewise.
+ * x86_64.cc (Target_x86_64::do_is_defined_by_abi): Likewise.
+ * testsuite/Makefile.am (tls_test_shared.so): Add -Wl,-z,defs.
+ * testsuite/Makefile.in: Rebuild.
+
+ * fileread.cc (make_view): Add casts to avoid warning.
+
+2008-09-16 Alexandre Oliva <aoliva@redhat.com>
+
+ * i386.cc (Target_i386::define_tls_base_symbol): Update comments.
+ * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
+
+2008-09-16 Alexandre Oliva <aoliva@redhat.com>
+
+ * options.h (General_options::output_is_executable): New.
+ (General_options::output_is_pie): New.
+ * i386.cc (Target_i386::define_tls_base_symbol): Use SEGMENT_START
+ for shared libraries.
+ * x86_64.cc (Target_x86_64::define_tls_base_symbol): Likewise.
+
+2008-09-11 Chris Demetriou <cgd@google.com>
+
+ * options.h (origin): New -z option.
+ * layout.cc (Layout:finish_dynamic_section): If "-z origin"
+ is specified, set DF_ORIGIN in DT_FLAGS and set DF_1_ORIGIN
+ in DT_FLAGS_1.
+
+2008-09-05 Cary Coutant <ccoutant@google.com>
+
+ * fileread.cc (File_read::make_view): Add check for attempt to map
+ beyond end of file.
+
2008-09-05 Cary Coutant <ccoutant@google.com>
* symtab.cc (Symbol_table::add_from_dynobj): Fix typos in
diff --git a/gold/Makefile.am b/gold/Makefile.am
index e706703..74db37a 100644
--- a/gold/Makefile.am
+++ b/gold/Makefile.am
@@ -19,6 +19,10 @@ INCLUDES = \
LIBIBERTY = ../libiberty/libiberty.a
+if PLUGINS
+LIBDL = -ldl
+endif
+
if THREADS
THREADSLIB = -lpthread
endif
@@ -53,6 +57,7 @@ CCFILES = \
options.cc \
output.cc \
parameters.cc \
+ plugin.cc \
readsyms.cc \
reduced_debug_output.cc \
reloc.cc \
@@ -90,6 +95,7 @@ HFILES = \
options.h \
output.h \
parameters.h \
+ plugin.h \
readsyms.h \
reduced_debug_output.h \
reloc.h \
@@ -122,7 +128,8 @@ libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES)
sources_var = main.cc
deps_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
-ldadd_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) $(THREADSLIB)
+ldadd_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \
+ $(THREADSLIB) $(LIBDL)
ld_new_SOURCES = $(sources_var)
ld_new_DEPENDENCIES = $(deps_var) $(LIBOBJS)
diff --git a/gold/Makefile.in b/gold/Makefile.in
index bbc5417..f6a80d0 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -82,7 +82,7 @@ am__objects_1 = archive.$(OBJEXT) binary.$(OBJEXT) common.$(OBJEXT) \
fileread.$(OBJEXT) gold.$(OBJEXT) gold-threads.$(OBJEXT) \
layout.$(OBJEXT) mapfile.$(OBJEXT) merge.$(OBJEXT) \
object.$(OBJEXT) options.$(OBJEXT) output.$(OBJEXT) \
- parameters.$(OBJEXT) readsyms.$(OBJEXT) \
+ parameters.$(OBJEXT) plugin.$(OBJEXT) readsyms.$(OBJEXT) \
reduced_debug_output.$(OBJEXT) reloc.$(OBJEXT) \
resolve.$(OBJEXT) script-sections.$(OBJEXT) script.$(OBJEXT) \
stringpool.$(OBJEXT) symtab.$(OBJEXT) target-select.$(OBJEXT) \
@@ -101,7 +101,7 @@ am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = ../libiberty/libiberty.a
am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) libgold.a \
$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__DEPENDENCIES_4 = @LIBOBJS@
am__ld1_SOURCES_DIST = main.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_ld1_OBJECTS = $(am__objects_4)
@@ -227,6 +227,8 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PLUGINS_FALSE = @PLUGINS_FALSE@
+PLUGINS_TRUE = @PLUGINS_TRUE@
POSUB = @POSUB@
RANDOM_SEED_CFLAGS = @RANDOM_SEED_CFLAGS@
RANLIB = @RANLIB@
@@ -308,6 +310,7 @@ INCLUDES = \
@INCINTL@
LIBIBERTY = ../libiberty/libiberty.a
+@PLUGINS_TRUE@LIBDL = -ldl
@THREADS_TRUE@THREADSLIB = -lpthread
AM_YFLAGS = -d
noinst_LIBRARIES = libgold.a
@@ -336,6 +339,7 @@ CCFILES = \
options.cc \
output.cc \
parameters.cc \
+ plugin.cc \
readsyms.cc \
reduced_debug_output.cc \
reloc.cc \
@@ -373,6 +377,7 @@ HFILES = \
options.h \
output.h \
parameters.h \
+ plugin.h \
readsyms.h \
reduced_debug_output.h \
reloc.h \
@@ -403,7 +408,9 @@ ALL_TARGETOBJS = \
libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES)
sources_var = main.cc
deps_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
-ldadd_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) $(THREADSLIB)
+ldadd_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \
+ $(THREADSLIB) $(LIBDL)
+
ld_new_SOURCES = $(sources_var)
ld_new_DEPENDENCIES = $(deps_var) $(LIBOBJS)
ld_new_LDADD = $(ldadd_var) $(LIBOBJS)
@@ -550,6 +557,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parameters.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/powerpc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readsyms.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reduced_debug_output.Po@am__quote@
diff --git a/gold/archive.cc b/gold/archive.cc
index f5ad574..7e2d143 100644
--- a/gold/archive.cc
+++ b/gold/archive.cc
@@ -37,6 +37,7 @@
#include "symtab.h"
#include "object.h"
#include "archive.h"
+#include "plugin.h"
namespace gold
{
@@ -126,6 +127,9 @@ Archive::setup(Input_objects* input_objects)
&& parameters->options().preread_archive_symbols());
#ifndef ENABLE_THREADS
preread_syms = false;
+#else
+ if (parameters->options().has_plugins())
+ preread_syms = false;
#endif
if (preread_syms)
this->read_all_symbols(input_objects);
@@ -439,11 +443,11 @@ Archive::end()
bool
Archive::get_file_and_offset(off_t off, Input_objects* input_objects,
Input_file** input_file, off_t* memoff,
- std::string* member_name)
+ off_t* memsize, std::string* member_name)
{
off_t nested_off;
- this->read_header(off, false, member_name, &nested_off);
+ *memsize = this->read_header(off, false, member_name, &nested_off);
*input_file = this->input_file_;
*memoff = off + static_cast<off_t>(sizeof(Archive_header));
@@ -455,11 +459,11 @@ Archive::get_file_and_offset(off_t off, Input_objects* input_objects,
// to the directory containing the archive.
if (!IS_ABSOLUTE_PATH(member_name->c_str()))
{
- const char* arch_path = this->name().c_str();
+ const char* arch_path = this->filename().c_str();
const char* basename = lbasename(arch_path);
if (basename > arch_path)
member_name->replace(0, 0,
- this->name().substr(0, basename - arch_path));
+ this->filename().substr(0, basename - arch_path));
}
if (nested_off > 0)
@@ -488,8 +492,8 @@ Archive::get_file_and_offset(off_t off, Input_objects* input_objects,
this->nested_archives_.insert(std::make_pair(*member_name, arch));
gold_assert(ins.second);
}
- return arch->get_file_and_offset(nested_off, input_objects,
- input_file, memoff, member_name);
+ return arch->get_file_and_offset(nested_off, input_objects, input_file,
+ memoff, memsize, member_name);
}
// This is an external member of a thin archive. Open the
@@ -503,6 +507,7 @@ Archive::get_file_and_offset(off_t off, Input_objects* input_objects,
return false;
*memoff = 0;
+ *memsize = (*input_file)->file().filesize();
return true;
}
@@ -515,11 +520,26 @@ Archive::get_elf_object_for_member(off_t off, Input_objects* input_objects)
std::string member_name;
Input_file* input_file;
off_t memoff;
+ off_t memsize;
if (!this->get_file_and_offset(off, input_objects, &input_file, &memoff,
- &member_name))
+ &memsize, &member_name))
return NULL;
+ if (parameters->options().has_plugins())
+ {
+ Object* obj = parameters->options().plugins()->claim_file(input_file,
+ memoff,
+ memsize);
+ if (obj != NULL)
+ {
+ // The input file was claimed by a plugin, and its symbols
+ // have been provided by the plugin.
+ input_file->file().claim_for_plugin();
+ return obj;
+ }
+ }
+
off_t filesize = input_file->file().filesize();
int read_size = elfcpp::Elf_sizes<64>::ehdr_size;
if (filesize - memoff < read_size)
@@ -753,12 +773,24 @@ Archive::include_member(Symbol_table* symtab, Layout* layout,
if (mapfile != NULL)
mapfile->report_include_archive_member(obj->name(), sym, why);
+ Pluginobj* pluginobj = obj->pluginobj();
+ if (pluginobj != NULL)
+ {
+ pluginobj->add_symbols(symtab, layout);
+ return;
+ }
+
if (input_objects->add_object(obj))
{
Read_symbols_data sd;
obj->read_symbols(&sd);
obj->layout(symtab, layout, &sd);
obj->add_symbols(symtab, &sd);
+
+ // If this is an external member of a thin archive, unlock the file
+ // for the next task.
+ if (obj->offset() == 0)
+ obj->unlock(this->task_);
}
else
{
diff --git a/gold/archive.h b/gold/archive.h
index 24fdb2b..6b99aed 100644
--- a/gold/archive.h
+++ b/gold/archive.h
@@ -184,7 +184,7 @@ class Archive
bool
get_file_and_offset(off_t off, Input_objects* input_objects,
Input_file** input_file, off_t* memoff,
- std::string* member_name);
+ off_t* memsize, std::string* member_name);
// Return an ELF object for the member at offset OFF. Set *MEMBER_NAME to
// the name of the member.
diff --git a/gold/config.in b/gold/config.in
index 73cc6e9..309f84b6 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -4,6 +4,9 @@
language is requested. */
#undef ENABLE_NLS
+/* Define to enable linker plugins */
+#undef ENABLE_PLUGINS
+
/* Define to do multi-threaded linking */
#undef ENABLE_THREADS
diff --git a/gold/configure b/gold/configure
index f2ec1ef..d898870 100755
--- a/gold/configure
+++ b/gold/configure
@@ -309,7 +309,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar THREADS_TRUE THREADS_FALSE TARGETOBJS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE YACC RANLIB ac_ct_RANLIB LN_S USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE NATIVE_LINKER_TRUE NATIVE_LINKER_FALSE GCC_TRUE GCC_FALSE FN_PTRS_IN_SO_WITHOUT_PIC_TRUE FN_PTRS_IN_SO_WITHOUT_PIC_FALSE TLS_TRUE TLS_FALSE STATIC_TLS_TRUE STATIC_TLS_FALSE OMP_SUPPORT_TRUE OMP_SUPPORT_FALSE TLS_GNU2_DIALECT_TRUE TLS_GNU2_DIALECT_FALSE TLS_DESCRIPTORS_TRUE TLS_DESCRIPTORS_FALSE CONSTRUCTOR_PRIORITY_TRUE CONSTRUCTOR_PRIORITY_FALSE RANDOM_SEED_CFLAGS WARN_CFLAGS NO_WERROR WARN_CXXFLAGS LFS_CFLAGS LIBOBJS CPP EGREP HAVE_ZLIB_TRUE HAVE_ZLIB_FALSE CXXCPP MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar THREADS_TRUE THREADS_FALSE PLUGINS_TRUE PLUGINS_FALSE TARGETOBJS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE YACC RANLIB ac_ct_RANLIB LN_S USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE NATIVE_LINKER_TRUE NATIVE_LINKER_FALSE GCC_TRUE GCC_FALSE FN_PTRS_IN_SO_WITHOUT_PIC_TRUE FN_PTRS_IN_SO_WITHOUT_PIC_FALSE TLS_TRUE TLS_FALSE STATIC_TLS_TRUE STATIC_TLS_FALSE OMP_SUPPORT_TRUE OMP_SUPPORT_FALSE TLS_GNU2_DIALECT_TRUE TLS_GNU2_DIALECT_FALSE TLS_DESCRIPTORS_TRUE TLS_DESCRIPTORS_FALSE CONSTRUCTOR_PRIORITY_TRUE CONSTRUCTOR_PRIORITY_FALSE RANDOM_SEED_CFLAGS WARN_CFLAGS NO_WERROR WARN_CXXFLAGS LFS_CFLAGS LIBOBJS CPP EGREP HAVE_ZLIB_TRUE HAVE_ZLIB_FALSE CXXCPP MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LTLIBOBJS'
ac_subst_files=''
ac_pwd=`pwd`
@@ -866,6 +866,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-threads multi-threaded linking
+ --enable-plugins linker plugins
--enable-targets alternative target configurations
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
@@ -1959,6 +1960,35 @@ else
fi
+# Check whether --enable-plugins or --disable-plugins was given.
+if test "${enable_plugins+set}" = set; then
+ enableval="$enable_plugins"
+ case "${enableval}" in
+ yes | "") plugins=yes ;;
+ no) plugins=no ;;
+ *) plugins=yes ;;
+ esac
+else
+ plugins=no
+fi;
+if test "$plugins" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define ENABLE_PLUGINS 1
+_ACEOF
+
+fi
+
+
+if test "$plugins" = "yes"; then
+ PLUGINS_TRUE=
+ PLUGINS_FALSE='#'
+else
+ PLUGINS_TRUE='#'
+ PLUGINS_FALSE=
+fi
+
+
# Check whether --enable-targets or --disable-targets was given.
if test "${enable_targets+set}" = set; then
enableval="$enable_targets"
@@ -6720,6 +6750,13 @@ echo "$as_me: error: conditional \"THREADS\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
+if test -z "${PLUGINS_TRUE}" && test -z "${PLUGINS_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"PLUGINS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"PLUGINS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
@@ -7396,6 +7433,8 @@ s,@am__tar@,$am__tar,;t t
s,@am__untar@,$am__untar,;t t
s,@THREADS_TRUE@,$THREADS_TRUE,;t t
s,@THREADS_FALSE@,$THREADS_FALSE,;t t
+s,@PLUGINS_TRUE@,$PLUGINS_TRUE,;t t
+s,@PLUGINS_FALSE@,$PLUGINS_FALSE,;t t
s,@TARGETOBJS@,$TARGETOBJS,;t t
s,@CC@,$CC,;t t
s,@CFLAGS@,$CFLAGS,;t t
diff --git a/gold/configure.ac b/gold/configure.ac
index 3fbcd0e..b0efef1 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -53,6 +53,20 @@ if test "$threads" = "yes"; then
fi
AM_CONDITIONAL(THREADS, test "$threads" = "yes")
+AC_ARG_ENABLE([plugins],
+[ --enable-plugins linker plugins],
+[case "${enableval}" in
+ yes | "") plugins=yes ;;
+ no) plugins=no ;;
+ *) plugins=yes ;;
+ esac],
+[plugins=no])
+if test "$plugins" = "yes"; then
+ AC_DEFINE(ENABLE_PLUGINS, 1,
+ [Define to enable linker plugins])
+fi
+AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
+
AC_ARG_ENABLE([targets],
[ --enable-targets alternative target configurations],
[case "${enableval}" in
diff --git a/gold/descriptors.cc b/gold/descriptors.cc
index 75a7a86..73c03bf 100644
--- a/gold/descriptors.cc
+++ b/gold/descriptors.cc
@@ -115,7 +115,9 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
pod->inuse = true;
pod->is_write = (flags & O_ACCMODE) != O_RDONLY;
- ++this->current_;
+ if (!pod->is_claimed)
+ ++this->current_;
+ pod->is_claimed = false;
if (this->current_ >= this->limit_)
this->close_some_descriptor();
@@ -166,6 +168,24 @@ Descriptors::release(int descriptor, bool permanent)
}
}
+// Claim the file descriptor DESCRIPTOR for a plugin. This effectively
+// removes the descriptor from the pool of linker-managed descriptors,
+// as the plugin will assume responsibility for closing it.
+// The IS_CLAIMED flag allows us to recognize when a file descriptor
+// has been reused after being closed by the plugin.
+
+void
+Descriptors::claim_for_plugin(int descriptor)
+{
+ Hold_lock hl(*this->lock_);
+
+ gold_assert(descriptor >= 0
+ && (static_cast<size_t>(descriptor)
+ < this->open_descriptors_.size()));
+ Open_descriptor* pod = &this->open_descriptors_[descriptor];
+ pod->is_claimed = true;
+}
+
// Close some descriptor. The lock is held when this is called. We
// close the descriptor on the top of the free stack. Note that this
// is the opposite of an LRU algorithm--we close the most recently
diff --git a/gold/descriptors.h b/gold/descriptors.h
index 6a6ab61..359008c 100644
--- a/gold/descriptors.h
+++ b/gold/descriptors.h
@@ -56,6 +56,12 @@ class Descriptors
void
release(int descriptor, bool permanent);
+ // Claim the file descriptor DESCRIPTOR for a plugin. This effectively
+ // removes the descriptor from the pool of linker-managed descriptors,
+ // as the plugin will assume responsibility for closing it.
+ void
+ claim_for_plugin(int descriptor);
+
private:
// Information kept for a descriptor.
struct Open_descriptor
@@ -69,6 +75,8 @@ class Descriptors
bool inuse;
// Whether this is a write descriptor.
bool is_write;
+ // Whether the descriptor has been claimed for a plugin.
+ bool is_claimed;
};
bool
@@ -100,6 +108,10 @@ inline void
release_descriptor(int descriptor, bool permanent)
{ descriptors.release(descriptor, permanent); }
+inline void
+claim_descriptor_for_plugin(int descriptor)
+{ descriptors.claim_for_plugin(descriptor); }
+
} // End namespace gold.
#endif // !defined(GOLD_DESCRIPTORS_H)
diff --git a/gold/fileread.cc b/gold/fileread.cc
index 8c2f8f3..72abd6b 100644
--- a/gold/fileread.cc
+++ b/gold/fileread.cc
@@ -191,6 +191,19 @@ File_read::release()
this->released_ = true;
}
+// Claim the file for a plugin. This effectively releases the file without
+// closing it; the plugin will assume responsibility for closing it.
+
+void
+File_read::claim_for_plugin()
+{
+ gold_assert(this->is_locked());
+ claim_descriptor_for_plugin(this->descriptor_);
+ this->descriptor_ = -1;
+ this->is_descriptor_opened_ = false;
+ this->released_ = true;
+}
+
// Lock the file.
void
@@ -355,6 +368,16 @@ File_read::make_view(off_t start, section_size_type size,
{
gold_assert(size > 0);
+ // Check that start and end of the view are within the file.
+ if (start > this->size_
+ || (static_cast<unsigned long long>(size)
+ > static_cast<unsigned long long>(this->size_ - start)))
+ gold_fatal(_("%s: attempt to map %lld bytes at offset %lld exceeds "
+ "size of file; the file may be corrupt"),
+ this->filename().c_str(),
+ static_cast<long long>(size),
+ static_cast<long long>(start));
+
off_t poff = File_read::page_offset(start);
section_size_type psize = File_read::pages(size + (start - poff));
diff --git a/gold/fileread.h b/gold/fileread.h
index 4236ce0..1b776f1 100644
--- a/gold/fileread.h
+++ b/gold/fileread.h
@@ -109,6 +109,11 @@ class File_read
void
release();
+ // Claim the file for a plugin. This effectively releases the file without
+ // closing it; the plugin will assume responsibility for closing it.
+ void
+ claim_for_plugin();
+
// Return the size of the file.
off_t
filesize() const
@@ -183,6 +188,14 @@ class File_read
static void
print_stats();
+ // Return the open file descriptor (for plugins).
+ int
+ descriptor() const
+ {
+ gold_assert(this->descriptor_ >= 0);
+ return this->descriptor_;
+ }
+
private:
// This class may not be copied.
File_read(const File_read&);
diff --git a/gold/gold.cc b/gold/gold.cc
index 42c6248..ac321be 100644
--- a/gold/gold.cc
+++ b/gold/gold.cc
@@ -40,6 +40,7 @@
#include "layout.h"
#include "reloc.h"
#include "defstd.h"
+#include "plugin.h"
namespace gold
{
@@ -151,6 +152,16 @@ queue_initial_tasks(const General_options& options,
this_blocker = next_blocker;
}
+ if (options.has_plugins())
+ {
+ Task_token* next_blocker = new Task_token(true);
+ next_blocker->add_blocker();
+ workqueue->queue(new Plugin_hook(options, input_objects, symtab, layout,
+ &search_path, mapfile, this_blocker,
+ next_blocker));
+ this_blocker = next_blocker;
+ }
+
workqueue->queue(new Task_function(new Middle_runner(options,
input_objects,
symtab,
@@ -192,6 +203,7 @@ queue_middle_tasks(const General_options& options,
if (!doing_static_link && options.is_static())
{
// We print out just the first .so we see; there may be others.
+ gold_assert(input_objects->dynobj_begin() != input_objects->dynobj_end());
gold_error(_("cannot mix -static with dynamic object %s"),
(*input_objects->dynobj_begin())->name().c_str());
}
diff --git a/gold/i386.cc b/gold/i386.cc
index 54f1233..8a5558e 100644
--- a/gold/i386.cc
+++ b/gold/i386.cc
@@ -135,7 +135,7 @@ class Target_i386 : public Sized_target<32, false>
// Return whether SYM is defined by the ABI.
bool
- do_is_defined_by_abi(Symbol* sym) const
+ do_is_defined_by_abi(const Symbol* sym) const
{ return strcmp(sym->name(), "___tls_get_addr") == 0; }
// Return the size of the GOT section.
@@ -323,7 +323,7 @@ class Target_i386 : public Sized_target<32, false>
void
make_plt_entry(Symbol_table*, Layout*, Symbol*);
- // Define the _TLS_MODULE_BASE_ symbol at the end of the TLS segment.
+ // Define the _TLS_MODULE_BASE_ symbol in the TLS segment.
void
define_tls_base_symbol(Symbol_table*, Layout*);
@@ -736,7 +736,7 @@ Target_i386::make_plt_entry(Symbol_table* symtab, Layout* layout, Symbol* gsym)
this->plt_->add_entry(gsym);
}
-// Define the _TLS_MODULE_BASE_ symbol at the end of the TLS segment.
+// Define the _TLS_MODULE_BASE_ symbol in the TLS segment.
void
Target_i386::define_tls_base_symbol(Symbol_table* symtab, Layout* layout)
@@ -747,12 +747,16 @@ Target_i386::define_tls_base_symbol(Symbol_table* symtab, Layout* layout)
Output_segment* tls_segment = layout->tls_segment();
if (tls_segment != NULL)
{
+ bool is_exec = parameters->options().output_is_executable();
symtab->define_in_output_segment("_TLS_MODULE_BASE_", NULL,
tls_segment, 0, 0,
elfcpp::STT_TLS,
elfcpp::STB_LOCAL,
elfcpp::STV_HIDDEN, 0,
- Symbol::SEGMENT_END, true);
+ (is_exec
+ ? Symbol::SEGMENT_END
+ : Symbol::SEGMENT_START),
+ true);
}
this->tls_base_symbol_defined_ = true;
}
diff --git a/gold/layout.cc b/gold/layout.cc
index 99819d6..ec9654e 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -2753,6 +2753,8 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
}
if (parameters->options().shared() && this->has_static_tls())
flags |= elfcpp::DF_STATIC_TLS;
+ if (parameters->options().origin())
+ flags |= elfcpp::DF_ORIGIN;
odyn->add_constant(elfcpp::DT_FLAGS, flags);
flags = 0;
@@ -2774,6 +2776,8 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
flags &= ~(elfcpp::DF_1_INITFIRST
| elfcpp::DF_1_NODELETE
| elfcpp::DF_1_NOOPEN);
+ if (parameters->options().origin())
+ flags |= elfcpp::DF_1_ORIGIN;
if (flags)
odyn->add_constant(elfcpp::DT_FLAGS_1, flags);
}
diff --git a/gold/main.cc b/gold/main.cc
index b842159..8e8e8f9 100644
--- a/gold/main.cc
+++ b/gold/main.cc
@@ -42,6 +42,7 @@
#include "archive.h"
#include "symtab.h"
#include "layout.h"
+#include "plugin.h"
using namespace gold;
@@ -190,6 +191,10 @@ main(int argc, char** argv)
if (parameters->options().relocatable())
command_line.script_options().version_script_info()->clear();
+ // Load plugin libraries.
+ if (command_line.options().has_plugins())
+ command_line.options().plugins()->load_plugins();
+
// The work queue.
Workqueue workqueue(command_line.options());
diff --git a/gold/mapfile.cc b/gold/mapfile.cc
index 9cec366..a3ba52b 100644
--- a/gold/mapfile.cc
+++ b/gold/mapfile.cc
@@ -253,7 +253,7 @@ Mapfile::print_input_section(Relobj* relobj, unsigned int shndx)
{
os = relobj->output_section(shndx);
addr = relobj->output_section_offset(shndx);
- if (addr != -1U)
+ if (addr != -1ULL)
addr += os->address();
}
diff --git a/gold/object.cc b/gold/object.cc
index d8f5ec8..f7dcda8 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -926,7 +926,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
{
// Do not include this section in the link.
out_sections[i] = NULL;
- out_section_offsets[i] = -1U;
+ out_section_offsets[i] = invalid_address;
continue;
}
@@ -967,7 +967,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
out_sections[i] = os;
if (offset == -1)
- out_section_offsets[i] = -1U;
+ out_section_offsets[i] = invalid_address;
else
out_section_offsets[i] = convert_types<Address, off_t>(offset);
@@ -1004,7 +1004,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
if (data_section == NULL)
{
out_sections[i] = NULL;
- out_section_offsets[i] = -1U;
+ out_section_offsets[i] = invalid_address;
continue;
}
@@ -1014,7 +1014,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
Output_section* os = layout->layout_reloc(this, i, shdr, data_section,
rr);
out_sections[i] = os;
- out_section_offsets[i] = -1U;
+ out_section_offsets[i] = invalid_address;
}
// Handle the .eh_frame sections at the end.
@@ -1042,7 +1042,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
&offset);
out_sections[i] = os;
if (offset == -1)
- out_section_offsets[i] = -1U;
+ out_section_offsets[i] = invalid_address;
else
out_section_offsets[i] = convert_types<Address, off_t>(offset);
@@ -1266,7 +1266,7 @@ Sized_relobj<size, big_endian>::do_finalize_local_symbols(unsigned int index,
// so we leave the input value unchanged here.
continue;
}
- else if (out_offsets[shndx] == -1U)
+ else if (out_offsets[shndx] == invalid_address)
{
// This is a SHF_MERGE section or one which otherwise
// requires special handling. We get the output address
@@ -1573,7 +1573,7 @@ Sized_relobj<size, big_endian>::map_to_kept_section(
*found = true;
Output_section* os = kept->object_->output_section(kept->shndx_);
Address offset = kept->object_->get_output_section_offset(kept->shndx_);
- gold_assert(os != NULL && offset != -1U);
+ gold_assert(os != NULL && offset != invalid_address);
return os->address() + offset;
}
*found = false;
diff --git a/gold/object.h b/gold/object.h
index 188f1f2..fcb5d31 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -42,6 +42,7 @@ class Layout;
class Output_section;
class Output_file;
class Output_symtab_xindex;
+class Pluginobj;
class Dynobj;
class Object_merge_map;
class Relocatable_relocs;
@@ -214,6 +215,12 @@ class Object
is_dynamic() const
{ return this->is_dynamic_; }
+ // Returns NULL for Objects that are not plugin objects. This method
+ // is overridden in the Pluginobj class.
+ Pluginobj*
+ pluginobj()
+ { return this->do_pluginobj(); }
+
// Return the target structure associated with this object.
Target*
target() const
@@ -431,7 +438,18 @@ class Object
size_t* used) const
{ this->do_get_global_symbol_counts(symtab, defined, used); }
+ // Set the target.
+ void
+ set_target(Target* target)
+ { this->target_ = target; }
+
protected:
+ // Returns NULL for Objects that are not plugin objects. This method
+ // is overridden in the Pluginobj class.
+ virtual Pluginobj*
+ do_pluginobj()
+ { return NULL; }
+
// Read the symbols--implemented by child class.
virtual void
do_read_symbols(Read_symbols_data*) = 0;
@@ -1184,6 +1202,8 @@ class Sized_relobj : public Relobj
typedef std::vector<Symbol*> Symbols;
typedef std::vector<Symbol_value<size> > Local_values;
+ static const Address invalid_address = static_cast<Address>(0) - 1;
+
Sized_relobj(const std::string& name, Input_file* input_file, off_t offset,
const typename elfcpp::Ehdr<size, big_endian>&);
@@ -1439,7 +1459,12 @@ class Sized_relobj : public Relobj
// Get the offset of a section.
uint64_t
do_output_section_offset(unsigned int shndx) const
- { return this->get_output_section_offset(shndx); }
+ {
+ Address off = this->get_output_section_offset(shndx);
+ if (off == invalid_address)
+ return -1ULL;
+ return off;
+ }
// Set the offset of a section.
void
@@ -1681,7 +1706,7 @@ class Sized_relobj : public Relobj
// for TLS symbols, indexed by symbol number.
Local_got_offsets local_got_offsets_;
// For each input section, the offset of the input section in its
- // output section. This is -1U if the input section requires a
+ // output section. This is INVALID_ADDRESS if the input section requires a
// special mapping.
std::vector<Address> section_offsets_;
// Table mapping discarded comdat sections to corresponding kept sections.
diff --git a/gold/options.cc b/gold/options.cc
index 78f0b1a..069c138 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -36,6 +36,7 @@
#include "script.h"
#include "target-select.h"
#include "options.h"
+#include "plugin.h"
namespace gold
{
@@ -296,6 +297,15 @@ General_options::parse_library(const char*, const char* arg,
cmdline->inputs().add_file(file);
}
+#ifdef ENABLE_PLUGINS
+void
+General_options::parse_plugin(const char*, const char* arg,
+ Command_line*)
+{
+ this->add_plugin(arg);
+}
+#endif // ENABLE_PLUGINS
+
void
General_options::parse_R(const char* option, const char* arg,
Command_line* cmdline)
@@ -594,7 +604,7 @@ namespace gold
General_options::General_options()
: execstack_status_(General_options::EXECSTACK_FROM_INPUT), static_(false),
- do_demangle_(false)
+ do_demangle_(false), plugins_()
{
}
@@ -632,6 +642,16 @@ General_options::add_sysroot()
free(canonical_sysroot);
}
+// Add a plugin and its arguments to the list of plugins.
+
+void
+General_options::add_plugin(const char* arg)
+{
+ if (this->plugins_ == NULL)
+ this->plugins_ = new Plugin_manager(*this);
+ this->plugins_->add_plugin(arg);
+}
+
// Set up variables and other state that isn't set up automatically by
// the parse routine, and ensure options don't contradict each other
// and are otherwise kosher.
@@ -772,6 +792,9 @@ General_options::finalize()
this->add_sysroot();
// Now that we've normalized the options, check for contradictory ones.
+ if (this->shared() && this->is_static())
+ gold_fatal(_("-shared and -static are incompatible"));
+
if (this->shared() && this->relocatable())
gold_fatal(_("-shared and -r are incompatible"));
diff --git a/gold/options.h b/gold/options.h
index 46ad761..167e58a 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -54,6 +54,7 @@ class Search_directory;
class Input_file_group;
class Position_dependent_options;
class Target;
+class Plugin_manager;
// The nested namespace is to contain all the global variables and
// structs that need to be defined in the .h file, but do not need to
@@ -689,8 +690,14 @@ class General_options
DEFINE_string(oformat, options::EXACTLY_TWO_DASHES, '\0', "elf",
N_("Set output format"), N_("[binary]"));
+#ifdef ENABLE_PLUGINS
+ DEFINE_special(plugin, options::TWO_DASHES, '\0',
+ N_("Load a plugin library"), N_("PLUGIN[,ARG,...]"));
+#endif
+
DEFINE_bool(preread_archive_symbols, options::TWO_DASHES, '\0', false,
N_("Preread archive symbols when multi-threaded"), NULL);
+
DEFINE_string(print_symbol_counts, options::TWO_DASHES, '\0', NULL,
N_("Print symbols defined and used for each input"),
N_("FILENAME"));
@@ -837,6 +844,9 @@ class General_options
DEFINE_bool(relro, options::DASH_Z, '\0', false,
N_("Where possible mark variables read-only after relocation"),
N_("Don't mark variables read-only after relocation"));
+ DEFINE_bool(origin, options::DASH_Z, '\0', false,
+ N_("Mark DSO to indicate that needs immediate $ORIGIN "
+ "processing at runtime"), NULL);
public:
typedef options::Dir_list Dir_list;
@@ -862,6 +872,20 @@ class General_options
output_is_position_independent() const
{ return this->shared(); }
+ // Return true if the output is something that can be exec()ed, such
+ // as a static executable, or a position-dependent or
+ // position-independent executable, but not a dynamic library or an
+ // object file.
+ bool
+ output_is_executable() const
+ { return !this->shared() || this->output_is_pie(); }
+
+ // Return true if the output is a position-independent executable.
+ // This is currently not supported.
+ bool
+ output_is_pie() const
+ { return false; }
+
// This would normally be static(), and defined automatically, but
// since static is a keyword, we need to come up with our own name.
bool
@@ -899,6 +923,16 @@ class General_options
do_demangle() const
{ return this->do_demangle_; }
+ // Returns TRUE if any plugin libraries have been loaded.
+ bool
+ has_plugins() const
+ { return this->plugins_ != NULL; }
+
+ // Return a pointer to the plugin manager.
+ Plugin_manager*
+ plugins() const
+ { return this->plugins_; }
+
private:
// Don't copy this structure.
General_options(const General_options&);
@@ -936,12 +970,18 @@ class General_options
void
add_sysroot();
+ // Add a plugin and its arguments to the list of plugins.
+ void
+ add_plugin(const char* arg);
+
// Whether to mark the stack as executable.
Execstack execstack_status_;
// Whether to do a static link.
bool static_;
// Whether to do demangling.
bool do_demangle_;
+ // List of plugin libraries.
+ Plugin_manager* plugins_;
};
// The position-dependent options. We use this to store the state of
diff --git a/gold/output.cc b/gold/output.cc
index 2a46195..f6a6f1d 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -838,11 +838,11 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::
Output_section* os = this->u1_.relobj->output_section(lsi);
gold_assert(os != NULL);
Address offset = this->u1_.relobj->get_output_section_offset(lsi);
- if (offset != -1U)
+ if (offset != invalid_address)
return offset + addend;
// This is a merge section.
offset = os->output_address(this->u1_.relobj, lsi, addend);
- gold_assert(offset != -1U);
+ gold_assert(offset != invalid_address);
return offset;
}
@@ -858,13 +858,13 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::get_address() const
Output_section* os = this->u2_.relobj->output_section(this->shndx_);
gold_assert(os != NULL);
Address off = this->u2_.relobj->get_output_section_offset(this->shndx_);
- if (off != -1U)
+ if (off != invalid_address)
address += os->address() + off;
else
{
address = os->output_address(this->u2_.relobj, this->shndx_,
address);
- gold_assert(address != -1U);
+ gold_assert(address != invalid_address);
}
}
else if (this->u2_.od != NULL)
@@ -2043,7 +2043,7 @@ Output_section::output_address(const Relobj* object, unsigned int shndx,
if (p->output_offset(object, shndx, offset, &output_offset))
{
if (output_offset == -1)
- return -1U;
+ return -1ULL;
return addr + output_offset;
}
addr += p->data_size();
diff --git a/gold/output.h b/gold/output.h
index 1c95881..9f075be 100644
--- a/gold/output.h
+++ b/gold/output.h
@@ -874,6 +874,8 @@ class Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>
typedef typename elfcpp::Elf_types<size>::Elf_Addr Address;
typedef typename elfcpp::Elf_types<size>::Elf_Addr Addend;
+ static const Address invalid_address = static_cast<Address>(0) - 1;
+
// An uninitialized entry. We need this because we want to put
// instances of this class into an STL container.
Output_reloc()
@@ -1915,7 +1917,7 @@ class Output_section : public Output_data
// Add a new input section SHNDX, named NAME, with header SHDR, from
// object OBJECT. RELOC_SHNDX is the index of a relocation section
- // which applies to this section, or 0 if none, or -1U if more than
+ // which applies to this section, or 0 if none, or -1 if more than
// one. HAVE_SECTIONS_SCRIPT is true if we have a SECTIONS clause
// in a linker script; in that case we need to keep track of input
// sections associated with an output section. Return the offset
diff --git a/gold/plugin.cc b/gold/plugin.cc
new file mode 100644
index 0000000..a5f7a06
--- /dev/null
+++ b/gold/plugin.cc
@@ -0,0 +1,984 @@
+// plugin.c -- plugin manager for gold -*- C++ -*-
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// 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.
+
+#include <cstdio>
+#include <cstdarg>
+#include <cstring>
+#include <string>
+#include <vector>
+#include <dlfcn.h>
+
+#include "gold.h"
+#include "parameters.h"
+#include "errors.h"
+#include "fileread.h"
+#include "layout.h"
+#include "options.h"
+#include "plugin.h"
+#include "target.h"
+#include "readsyms.h"
+#include "symtab.h"
+#include "elfcpp.h"
+
+namespace gold
+{
+
+#ifdef ENABLE_PLUGINS
+
+// The linker's exported interfaces.
+
+extern "C"
+{
+
+static enum ld_plugin_status
+register_claim_file(ld_plugin_claim_file_handler handler);
+
+static enum ld_plugin_status
+register_all_symbols_read(ld_plugin_all_symbols_read_handler handler);
+
+static enum ld_plugin_status
+register_cleanup(ld_plugin_cleanup_handler handler);
+
+static enum ld_plugin_status
+add_symbols(void *handle, int nsyms, const struct ld_plugin_symbol *syms);
+
+static enum ld_plugin_status
+get_symbols(const void *handle, int nsyms, struct ld_plugin_symbol *syms);
+
+static enum ld_plugin_status
+add_input_file(char *pathname);
+
+static enum ld_plugin_status
+message(int level, char *format, ...);
+
+};
+
+#endif // ENABLE_PLUGINS
+
+static Pluginobj* make_sized_plugin_object(Input_file* input_file,
+ off_t offset);
+
+// Plugin methods.
+
+// Load one plugin library.
+
+void
+Plugin::load()
+{
+#ifdef ENABLE_PLUGINS
+ std::string filename;
+ std::vector<std::string> args;
+
+ // Parse the filename and arguments, each separated by commas.
+ // FIXME: Temporarily allowing semicolon as an argument separator
+ // so args can be passed through gcc's -Wl,... option, which
+ // breaks arguments at the commas.
+ const char* p = this->args_;
+ int n = strcspn(p, ",;");
+ filename.assign(p, n);
+ p += n;
+ while (*p == ',' || *p == ';')
+ {
+ ++p;
+ n = strcspn(p, ",;");
+ args.push_back(std::string(p, n));
+ p += n;
+ }
+
+ // Load the plugin library.
+ // FIXME: Look for the library in standard locations.
+ this->handle_ = dlopen(filename.c_str(), RTLD_NOW);
+ if (this->handle_ == NULL)
+ {
+ gold_error(_("%s: could not load plugin library"), filename.c_str());
+ return;
+ }
+
+ // Find the plugin's onload entry point.
+ ld_plugin_onload onload = reinterpret_cast<ld_plugin_onload>
+ (dlsym(this->handle_, "onload"));
+ if (onload == NULL)
+ {
+ gold_error(_("%s: could not find onload entry point"), filename.c_str());
+ return;
+ }
+
+ // Get the linker's version number.
+ const char* ver = get_version_string();
+ int major = 0;
+ int minor = 0;
+ sscanf(ver, "%d.%d", &major, &minor);
+
+ // Allocate and populate a transfer vector.
+ const int tv_fixed_size = 11;
+ int tv_size = args.size() + tv_fixed_size;
+ ld_plugin_tv *tv = new ld_plugin_tv[tv_size];
+
+ int i = 0;
+ tv[i].tv_tag = LDPT_API_VERSION;
+ tv[i].tv_u.tv_val = LD_PLUGIN_API_VERSION;
+
+ ++i;
+ tv[i].tv_tag = LDPT_GOLD_VERSION;
+ tv[i].tv_u.tv_val = major * 100 + minor;
+
+ ++i;
+ tv[i].tv_tag = LDPT_LINKER_OUTPUT;
+ if (parameters->options().relocatable())
+ tv[i].tv_u.tv_val = LDPO_REL;
+ else if (parameters->options().shared())
+ tv[i].tv_u.tv_val = LDPO_DYN;
+ else
+ tv[i].tv_u.tv_val = LDPO_EXEC;
+
+ for (unsigned int j = 0; j < args.size(); ++j)
+ {
+ ++i;
+ tv[i].tv_tag = LDPT_OPTION;
+ tv[i].tv_u.tv_string = args[j].c_str();
+ }
+
+ ++i;
+ tv[i].tv_tag = LDPT_REGISTER_CLAIM_FILE_HOOK;
+ tv[i].tv_u.tv_register_claim_file = register_claim_file;
+
+ ++i;
+ tv[i].tv_tag = LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK;
+ tv[i].tv_u.tv_register_all_symbols_read = register_all_symbols_read;
+
+ ++i;
+ tv[i].tv_tag = LDPT_REGISTER_CLEANUP_HOOK;
+ tv[i].tv_u.tv_register_cleanup = register_cleanup;
+
+ ++i;
+ tv[i].tv_tag = LDPT_ADD_SYMBOLS;
+ tv[i].tv_u.tv_add_symbols = add_symbols;
+
+ ++i;
+ tv[i].tv_tag = LDPT_GET_SYMBOLS;
+ tv[i].tv_u.tv_get_symbols = get_symbols;
+
+ ++i;
+ tv[i].tv_tag = LDPT_ADD_INPUT_FILE;
+ tv[i].tv_u.tv_add_input_file = add_input_file;
+
+ ++i;
+ tv[i].tv_tag = LDPT_MESSAGE;
+ tv[i].tv_u.tv_message = message;
+
+ ++i;
+ tv[i].tv_tag = LDPT_NULL;
+ tv[i].tv_u.tv_val = 0;
+
+ gold_assert(i == tv_size - 1);
+
+ // Call the onload entry point.
+ (*onload)(tv);
+
+ delete tv;
+#endif // ENABLE_PLUGINS
+}
+
+// Call the plugin claim-file handler.
+
+inline bool
+Plugin::claim_file(struct ld_plugin_input_file *plugin_input_file)
+{
+ int claimed = 0;
+
+ if (this->claim_file_handler_ != NULL)
+ {
+ (*this->claim_file_handler_)(plugin_input_file, &claimed);
+ if (claimed)
+ return true;
+ }
+ return false;
+}
+
+// Call the all-symbols-read handler.
+
+inline void
+Plugin::all_symbols_read()
+{
+ if (this->all_symbols_read_handler_ != NULL)
+ (*this->all_symbols_read_handler_)();
+}
+
+// Call the cleanup handler.
+
+inline void
+Plugin::cleanup()
+{
+ if (this->cleanup_handler_ != NULL)
+ (*this->cleanup_handler_)();
+}
+
+// Plugin_manager methods.
+
+Plugin_manager::~Plugin_manager()
+{
+ for (Plugin_list::iterator p = this->plugins_.begin();
+ p != this->plugins_.end();
+ ++p)
+ delete *p;
+ this->plugins_.clear();
+ for (Object_list::iterator obj = this->objects_.begin();
+ obj != this->objects_.end();
+ ++obj)
+ delete *obj;
+ this->objects_.clear();
+}
+
+// Load all plugin libraries.
+
+void
+Plugin_manager::load_plugins()
+{
+ for (this->current_ = this->plugins_.begin();
+ this->current_ != this->plugins_.end();
+ ++this->current_)
+ (*this->current_)->load();
+}
+
+// Call the plugin claim-file handlers in turn to see if any claim the file.
+
+Pluginobj*
+Plugin_manager::claim_file(Input_file* input_file, off_t offset,
+ off_t filesize)
+{
+ if (this->in_replacement_phase_)
+ return NULL;
+
+ unsigned int handle = this->objects_.size();
+ this->input_file_ = input_file;
+ this->plugin_input_file_.name = input_file->filename().c_str();
+ this->plugin_input_file_.fd = input_file->file().descriptor();
+ this->plugin_input_file_.offset = offset;
+ this->plugin_input_file_.filesize = filesize;
+ this->plugin_input_file_.handle = reinterpret_cast<void*>(handle);
+
+ for (this->current_ = this->plugins_.begin();
+ this->current_ != this->plugins_.end();
+ ++this->current_)
+ {
+ if ((*this->current_)->claim_file(&this->plugin_input_file_))
+ {
+ if (this->objects_.size() <= handle)
+ {
+ gold_error(_("%s: plugin claimed the file "
+ "but did not provide any symbols"),
+ this->plugin_input_file_.name);
+ return NULL;
+ }
+ return this->objects_[handle];
+ }
+ }
+
+ return NULL;
+}
+
+// Call the all-symbols-read handlers.
+
+void
+Plugin_manager::all_symbols_read(Workqueue* workqueue,
+ Input_objects* input_objects,
+ Symbol_table* symtab, Layout* layout,
+ Dirsearch* dirpath, Mapfile* mapfile,
+ Task_token** last_blocker)
+{
+ this->in_replacement_phase_ = true;
+ this->workqueue_ = workqueue;
+ this->input_objects_ = input_objects;
+ this->symtab_ = symtab;
+ this->layout_ = layout;
+ this->dirpath_ = dirpath;
+ this->mapfile_ = mapfile;
+ this->this_blocker_ = NULL;
+
+ for (this->current_ = this->plugins_.begin();
+ this->current_ != this->plugins_.end();
+ ++this->current_)
+ (*this->current_)->all_symbols_read();
+
+ *last_blocker = this->this_blocker_;
+}
+
+// Call the cleanup handlers.
+
+void
+Plugin_manager::cleanup()
+{
+ for (this->current_ = this->plugins_.begin();
+ this->current_ != this->plugins_.end();
+ ++this->current_)
+ (*this->current_)->cleanup();
+}
+
+// Make a new Pluginobj object. This is called when the plugin calls
+// the add_symbols API.
+
+Pluginobj*
+Plugin_manager::make_plugin_object(unsigned int handle)
+{
+ // Make sure we aren't asked to make an object for the same handle twice.
+ if (this->objects_.size() != handle)
+ return NULL;
+
+ Pluginobj* obj = make_sized_plugin_object(this->input_file_,
+ this->plugin_input_file_.offset);
+ this->objects_.push_back(obj);
+ return obj;
+}
+
+// Add a new input file.
+
+ld_plugin_status
+Plugin_manager::add_input_file(char *pathname)
+{
+ Input_file_argument file(pathname, false, "", false, this->options_);
+ Input_argument* input_argument = new Input_argument(file);
+ Task_token* next_blocker = new Task_token(true);
+ next_blocker->add_blocker();
+ this->workqueue_->queue_soon(new Read_symbols(this->options_,
+ this->input_objects_,
+ this->symtab_,
+ this->layout_,
+ this->dirpath_,
+ this->mapfile_,
+ input_argument,
+ NULL,
+ this->this_blocker_,
+ next_blocker));
+ this->this_blocker_ = next_blocker;
+ return LDPS_OK;
+}
+
+// Class Pluginobj.
+
+Pluginobj::Pluginobj(const std::string& name, Input_file* input_file,
+ off_t offset)
+ : Object(name, input_file, false, offset),
+ nsyms_(0), syms_(NULL), symbols_(), comdat_map_()
+{
+}
+
+// Get symbol resolution info.
+
+ld_plugin_status
+Pluginobj::get_symbol_resolution_info(int nsyms, ld_plugin_symbol* syms) const
+{
+ if (this->nsyms_ == 0)
+ return LDPS_NO_SYMS;
+ for (int i = 0; i < nsyms; i++)
+ {
+ ld_plugin_symbol* isym = &syms[i];
+ Symbol* lsym = this->symbols_[i];
+ ld_plugin_symbol_resolution res = LDPR_UNKNOWN;
+
+ if (lsym->is_undefined())
+ // The symbol remains undefined.
+ res = LDPR_UNDEF;
+ else if (isym->def == LDPK_UNDEF
+ || isym->def == LDPK_WEAKUNDEF
+ || isym->def == LDPK_COMMON)
+ {
+ // The original symbol was undefined or common.
+ if (lsym->source() != Symbol::FROM_OBJECT)
+ res = LDPR_RESOLVED_EXEC;
+ else if (lsym->object()->pluginobj() != NULL)
+ res = LDPR_RESOLVED_IR;
+ else if (lsym->object()->is_dynamic())
+ res = LDPR_RESOLVED_DYN;
+ else
+ res = LDPR_RESOLVED_EXEC;
+ }
+ else
+ {
+ // The original symbol was a definition.
+ if (lsym->source() != Symbol::FROM_OBJECT)
+ res = LDPR_PREEMPTED_REG;
+ else if (lsym->object() == static_cast<const Object*>(this))
+ res = (lsym->in_real_elf()
+ ? LDPR_PREVAILING_DEF
+ : LDPR_PREVAILING_DEF_IRONLY);
+ else
+ res = (lsym->object()->pluginobj() != NULL
+ ? LDPR_PREEMPTED_IR
+ : LDPR_PREEMPTED_REG);
+ }
+ isym->resolution = res;
+ }
+ return LDPS_OK;
+}
+
+// Return TRUE if the comdat group with key COMDAT_KEY from this object
+// should be kept.
+
+bool
+Pluginobj::include_comdat_group(std::string comdat_key, Layout* layout)
+{
+ std::pair<Comdat_map::iterator, bool> ins =
+ this->comdat_map_.insert(std::make_pair(comdat_key, false));
+
+ // If this is the first time we've seen this comdat key, ask the
+ // layout object whether it should be included.
+ if (ins.second)
+ ins.first->second = layout->add_comdat(NULL, 1, comdat_key, true);
+
+ return ins.first->second;
+}
+
+// Class Sized_pluginobj.
+
+template<int size, bool big_endian>
+Sized_pluginobj<size, big_endian>::Sized_pluginobj(
+ const std::string& name,
+ Input_file* input_file,
+ off_t offset)
+ : Pluginobj(name, input_file, offset)
+{
+}
+
+// Read the symbols. Not used for plugin objects.
+
+template<int size, bool big_endian>
+void
+Sized_pluginobj<size, big_endian>::do_read_symbols(Read_symbols_data*)
+{
+ gold_unreachable();
+}
+
+// Lay out the input sections. Not used for plugin objects.
+
+template<int size, bool big_endian>
+void
+Sized_pluginobj<size, big_endian>::do_layout(Symbol_table*, Layout*,
+ Read_symbols_data*)
+{
+ gold_unreachable();
+}
+
+// Add the symbols to the symbol table.
+
+template<int size, bool big_endian>
+void
+Sized_pluginobj<size, big_endian>::do_add_symbols(Symbol_table*,
+ Read_symbols_data*)
+{
+ gold_unreachable();
+}
+
+template<int size, bool big_endian>
+void
+Sized_pluginobj<size, big_endian>::do_add_symbols(Symbol_table* symtab,
+ Layout* layout)
+{
+ const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
+ unsigned char symbuf[sym_size];
+ elfcpp::Sym<size, big_endian> sym(symbuf);
+ elfcpp::Sym_write<size, big_endian> osym(symbuf);
+
+ typedef typename elfcpp::Elf_types<size>::Elf_WXword Elf_size_type;
+
+ this->symbols_.resize(this->nsyms_);
+
+ for (int i = 0; i < this->nsyms_; ++i)
+ {
+ const struct ld_plugin_symbol *isym = &this->syms_[i];
+ const char* name = isym->name;
+ const char* ver = isym->version;
+ elfcpp::Elf_Half shndx;
+ elfcpp::STB bind;
+ elfcpp::STV vis;
+
+ if (name != NULL && name[0] == '\0')
+ name = NULL;
+ if (ver != NULL && ver[0] == '\0')
+ ver = NULL;
+
+ switch (isym->def)
+ {
+ case LDPK_WEAKDEF:
+ case LDPK_WEAKUNDEF:
+ bind = elfcpp::STB_WEAK;
+ break;
+ case LDPK_DEF:
+ case LDPK_UNDEF:
+ case LDPK_COMMON:
+ default:
+ bind = elfcpp::STB_GLOBAL;
+ break;
+ }
+
+ switch (isym->def)
+ {
+ case LDPK_DEF:
+ case LDPK_WEAKDEF:
+ shndx = elfcpp::SHN_ABS;
+ break;
+ case LDPK_COMMON:
+ shndx = elfcpp::SHN_COMMON;
+ break;
+ case LDPK_UNDEF:
+ case LDPK_WEAKUNDEF:
+ default:
+ shndx = elfcpp::SHN_UNDEF;
+ break;
+ }
+
+ switch (isym->visibility)
+ {
+ case LDPV_PROTECTED:
+ vis = elfcpp::STV_DEFAULT;
+ break;
+ case LDPV_INTERNAL:
+ vis = elfcpp::STV_DEFAULT;
+ break;
+ case LDPV_HIDDEN:
+ vis = elfcpp::STV_DEFAULT;
+ break;
+ case LDPV_DEFAULT:
+ default:
+ vis = elfcpp::STV_DEFAULT;
+ break;
+ }
+
+ if (isym->comdat_key != NULL
+ && isym->comdat_key[0] != '\0'
+ && !this->include_comdat_group(isym->comdat_key, layout))
+ shndx = elfcpp::SHN_UNDEF;
+
+ osym.put_st_name(0);
+ osym.put_st_value(0);
+ osym.put_st_size(static_cast<Elf_size_type>(isym->size));
+ osym.put_st_info(bind, elfcpp::STT_NOTYPE);
+ osym.put_st_other(vis, 0);
+ osym.put_st_shndx(shndx);
+
+ this->symbols_[i] =
+ symtab->add_from_pluginobj<size, big_endian>(this, name, ver, &sym);
+ }
+}
+
+// Get the size of a section. Not used for plugin objects.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_pluginobj<size, big_endian>::do_section_size(unsigned int)
+{
+ gold_unreachable();
+ return 0;
+}
+
+// Get the name of a section. Not used for plugin objects.
+
+template<int size, bool big_endian>
+std::string
+Sized_pluginobj<size, big_endian>::do_section_name(unsigned int)
+{
+ gold_unreachable();
+ return std::string();
+}
+
+// Return a view of the contents of a section. Not used for plugin objects.
+
+template<int size, bool big_endian>
+Object::Location
+Sized_pluginobj<size, big_endian>::do_section_contents(unsigned int)
+{
+ Location loc(0, 0);
+
+ gold_unreachable();
+ return loc;
+}
+
+// Return section flags. Not used for plugin objects.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_pluginobj<size, big_endian>::do_section_flags(unsigned int)
+{
+ gold_unreachable();
+ return 0;
+}
+
+// Return section address. Not used for plugin objects.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_pluginobj<size, big_endian>::do_section_address(unsigned int)
+{
+ gold_unreachable();
+ return 0;
+}
+
+// Return section type. Not used for plugin objects.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_pluginobj<size, big_endian>::do_section_type(unsigned int)
+{
+ gold_unreachable();
+ return 0;
+}
+
+// Return the section link field. Not used for plugin objects.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_pluginobj<size, big_endian>::do_section_link(unsigned int)
+{
+ gold_unreachable();
+ return 0;
+}
+
+// Return the section link field. Not used for plugin objects.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_pluginobj<size, big_endian>::do_section_info(unsigned int)
+{
+ gold_unreachable();
+ return 0;
+}
+
+// Return the section alignment. Not used for plugin objects.
+
+template<int size, bool big_endian>
+uint64_t
+Sized_pluginobj<size, big_endian>::do_section_addralign(unsigned int)
+{
+ gold_unreachable();
+ return 0;
+}
+
+// Return the Xindex structure to use. Not used for plugin objects.
+
+template<int size, bool big_endian>
+Xindex*
+Sized_pluginobj<size, big_endian>::do_initialize_xindex()
+{
+ gold_unreachable();
+ return NULL;
+}
+
+// Get symbol counts. Not used for plugin objects.
+
+template<int size, bool big_endian>
+void
+Sized_pluginobj<size, big_endian>::do_get_global_symbol_counts(const Symbol_table*,
+ size_t*, size_t*) const
+{
+ gold_unreachable();
+}
+
+// Class Add_plugin_symbols.
+
+Add_plugin_symbols::~Add_plugin_symbols()
+{
+ if (this->this_blocker_ != NULL)
+ delete this->this_blocker_;
+ // next_blocker_ is deleted by the task associated with the next
+ // input file.
+}
+
+// We are blocked by this_blocker_. We block next_blocker_. We also
+// lock the file.
+
+Task_token*
+Add_plugin_symbols::is_runnable()
+{
+ if (this->this_blocker_ != NULL && this->this_blocker_->is_blocked())
+ return this->this_blocker_;
+ if (this->obj_->is_locked())
+ return this->obj_->token();
+ return NULL;
+}
+
+void
+Add_plugin_symbols::locks(Task_locker* tl)
+{
+ tl->add(this, this->next_blocker_);
+ tl->add(this, this->obj_->token());
+}
+
+// Add the symbols in the object to the symbol table.
+
+void
+Add_plugin_symbols::run(Workqueue*)
+{
+ this->obj_->add_symbols(this->symtab_, this->layout_);
+}
+
+// Class Plugin_cleanup. This task calls the plugin cleanup hooks once all
+// replacement files have been added.
+
+class Plugin_cleanup : public Task
+{
+ public:
+ Plugin_cleanup(Task_token* this_blocker, Task_token* next_blocker)
+ : this_blocker_(this_blocker), next_blocker_(next_blocker)
+ { }
+
+ ~Plugin_cleanup()
+ {
+ if (this->this_blocker_ != NULL)
+ delete this->this_blocker_;
+ }
+
+ Task_token*
+ is_runnable()
+ {
+ if (this->this_blocker_ != NULL && this->this_blocker_->is_blocked())
+ return this->this_blocker_;
+ return NULL;
+ }
+
+ void
+ locks(Task_locker* tl)
+ { tl->add(this, this->next_blocker_); }
+
+ void
+ run(Workqueue*)
+ { parameters->options().plugins()->cleanup(); }
+
+ std::string
+ get_name() const
+ { return "Plugin_cleanup"; }
+
+ private:
+ Task_token* this_blocker_;
+ Task_token* next_blocker_;
+};
+
+// Class Plugin_hook.
+
+Plugin_hook::~Plugin_hook()
+{
+}
+
+// Return whether a Plugin_hook task is runnable.
+
+Task_token*
+Plugin_hook::is_runnable()
+{
+ if (this->this_blocker_ != NULL && this->this_blocker_->is_blocked())
+ return this->this_blocker_;
+ return NULL;
+}
+
+// Return a Task_locker for a Plugin_hook task. We don't need any
+// locks here.
+
+void
+Plugin_hook::locks(Task_locker*)
+{
+}
+
+// Run a Plugin_hook task.
+
+void
+Plugin_hook::run(Workqueue* workqueue)
+{
+ this->do_plugin_hook(workqueue);
+}
+
+// Run the "all symbols read" plugin hook.
+
+void
+Plugin_hook::do_plugin_hook(Workqueue* workqueue)
+{
+ gold_assert(this->options_.has_plugins());
+ this->options_.plugins()->all_symbols_read(workqueue,
+ this->input_objects_,
+ this->symtab_,
+ this->layout_,
+ this->dirpath_,
+ this->mapfile_,
+ &this->this_blocker_);
+ workqueue->queue_soon(new Plugin_cleanup(this->this_blocker_,
+ this->next_blocker_));
+}
+
+// The C interface routines called by the plugins.
+
+#ifdef ENABLE_PLUGINS
+
+// Register a claim-file handler.
+
+static enum ld_plugin_status
+register_claim_file(ld_plugin_claim_file_handler handler)
+{
+ gold_assert(parameters->options().has_plugins());
+ parameters->options().plugins()->set_claim_file_handler(handler);
+ return LDPS_OK;
+}
+
+// Register an all-symbols-read handler.
+
+static enum ld_plugin_status
+register_all_symbols_read(ld_plugin_all_symbols_read_handler handler)
+{
+ gold_assert(parameters->options().has_plugins());
+ parameters->options().plugins()->set_all_symbols_read_handler(handler);
+ return LDPS_OK;
+}
+
+// Register a cleanup handler.
+
+static enum ld_plugin_status
+register_cleanup(ld_plugin_cleanup_handler handler)
+{
+ gold_assert(parameters->options().has_plugins());
+ parameters->options().plugins()->set_cleanup_handler(handler);
+ return LDPS_OK;
+}
+
+// Add symbols from a plugin-claimed input file.
+
+static enum ld_plugin_status
+add_symbols(void* handle, int nsyms, const ld_plugin_symbol *syms)
+{
+ gold_assert(parameters->options().has_plugins());
+ Pluginobj* obj = parameters->options().plugins()->make_plugin_object(
+ static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle)));
+ if (obj == NULL)
+ return LDPS_ERR;
+ obj->store_incoming_symbols(nsyms, syms);
+ return LDPS_OK;
+}
+
+// Get the symbol resolution info for a plugin-claimed input file.
+
+static enum ld_plugin_status
+get_symbols(const void * handle, int nsyms, ld_plugin_symbol* syms)
+{
+ gold_assert(parameters->options().has_plugins());
+ Pluginobj* obj = parameters->options().plugins()->object(
+ static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle)));
+ if (obj == NULL)
+ return LDPS_ERR;
+ return obj->get_symbol_resolution_info(nsyms, syms);
+}
+
+// Add a new (real) input file generated by a plugin.
+
+static enum ld_plugin_status
+add_input_file(char *pathname)
+{
+ gold_assert(parameters->options().has_plugins());
+ return parameters->options().plugins()->add_input_file(pathname);
+}
+
+// Issue a diagnostic message from a plugin.
+
+static enum ld_plugin_status
+message(int level, char * format, ...)
+{
+ va_list args;
+ va_start(args, format);
+
+ switch (level)
+ {
+ case LDPL_INFO:
+ parameters->errors()->info(format, args);
+ break;
+ case LDPL_WARNING:
+ parameters->errors()->warning(format, args);
+ break;
+ case LDPL_ERROR:
+ default:
+ parameters->errors()->error(format, args);
+ break;
+ case LDPL_FATAL:
+ parameters->errors()->fatal(format, args);
+ break;
+ }
+
+ va_end(args);
+ return LDPS_OK;
+}
+
+#endif // ENABLE_PLUGINS
+
+// Allocate a Pluginobj object of the appropriate size and endianness.
+
+static Pluginobj*
+make_sized_plugin_object(Input_file* input_file, off_t offset)
+{
+ Target* target;
+ Pluginobj* obj = NULL;
+
+ if (parameters->target_valid())
+ target = const_cast<Target*>(&parameters->target());
+ else
+ target = const_cast<Target*>(&parameters->default_target());
+
+ if (target->get_size() == 32)
+ {
+ if (target->is_big_endian())
+#ifdef HAVE_TARGET_32_BIG
+ obj = new Sized_pluginobj<32, true>(input_file->filename(),
+ input_file, offset);
+#else
+ gold_error(_("%s: not configured to support "
+ "32-bit big-endian object"),
+ input_file->filename().c_str());
+#endif
+ else
+#ifdef HAVE_TARGET_32_LITTLE
+ obj = new Sized_pluginobj<32, false>(input_file->filename(),
+ input_file, offset);
+#else
+ gold_error(_("%s: not configured to support "
+ "32-bit little-endian object"),
+ input_file->filename().c_str());
+#endif
+ }
+ else if (target->get_size() == 64)
+ {
+ if (target->is_big_endian())
+#ifdef HAVE_TARGET_64_BIG
+ obj = new Sized_pluginobj<64, true>(input_file->filename(),
+ input_file, offset);
+#else
+ gold_error(_("%s: not configured to support "
+ "64-bit big-endian object"),
+ input_file->filename().c_str());
+#endif
+ else
+#ifdef HAVE_TARGET_64_LITTLE
+ obj = new Sized_pluginobj<64, false>(input_file->filename(),
+ input_file, offset);
+#else
+ gold_error(_("%s: not configured to support "
+ "64-bit little-endian object"),
+ input_file->filename().c_str());
+#endif
+ }
+
+ gold_assert(obj != NULL);
+ obj->set_target(target);
+ return obj;
+}
+
+} // End namespace gold.
diff --git a/gold/plugin.h b/gold/plugin.h
new file mode 100644
index 0000000..3f573ce
--- /dev/null
+++ b/gold/plugin.h
@@ -0,0 +1,457 @@
+// plugin.h -- plugin manager for gold -*- C++ -*-
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// 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.
+
+#ifndef GOLD_PLUGIN_H
+#define GOLD_PLUGIN_H
+
+#include <list>
+#include <string>
+
+#include "object.h"
+#include "plugin-api.h"
+#include "workqueue.h"
+
+namespace gold
+{
+
+class General_options;
+class Input_file;
+class Input_objects;
+class Symbol_table;
+class Layout;
+class Dirsearch;
+class Mapfile;
+class Task_token;
+class Pluginobj;
+
+// This class represents a single plugin library.
+
+class Plugin
+{
+ public:
+ Plugin(const char* args)
+ : handle_(NULL),
+ args_(args),
+ claim_file_handler_(NULL),
+ all_symbols_read_handler_(NULL),
+ cleanup_handler_(NULL)
+ { }
+
+ ~Plugin()
+ { }
+
+ // Load the library and call its entry point.
+ void
+ load();
+
+ // Call the claim-file handler.
+ bool
+ claim_file(struct ld_plugin_input_file *plugin_input_file);
+
+ // Call the all-symbols-read handler.
+ void
+ all_symbols_read();
+
+ // Call the cleanup handler.
+ void
+ cleanup();
+
+ // Register a claim-file handler.
+ void
+ set_claim_file_handler(ld_plugin_claim_file_handler handler)
+ { this->claim_file_handler_ = handler; }
+
+ // Register an all-symbols-read handler.
+ void
+ set_all_symbols_read_handler(ld_plugin_all_symbols_read_handler handler)
+ { this->all_symbols_read_handler_ = handler; }
+
+ // Register a claim-file handler.
+ void
+ set_cleanup_handler(ld_plugin_cleanup_handler handler)
+ { this->cleanup_handler_ = handler; }
+
+ private:
+ Plugin(const Plugin&);
+ Plugin& operator=(const Plugin&);
+
+ // The shared library handle returned by dlopen.
+ void* handle_;
+ // The argument string given to --plugin.
+ const char* args_;
+ // The plugin's event handlers.
+ ld_plugin_claim_file_handler claim_file_handler_;
+ ld_plugin_all_symbols_read_handler all_symbols_read_handler_;
+ ld_plugin_cleanup_handler cleanup_handler_;
+};
+
+// A manager class for plugins.
+
+class Plugin_manager
+{
+ public:
+ Plugin_manager(const General_options& options)
+ : plugins_(), in_replacement_phase_(false), options_(options),
+ workqueue_(NULL), input_objects_(NULL), symtab_(NULL), layout_(NULL),
+ dirpath_(NULL), mapfile_(NULL), this_blocker_(NULL)
+ { this->current_ = plugins_.end(); }
+
+ ~Plugin_manager();
+
+ // Add a plugin library.
+ void
+ add_plugin(const char* args)
+ { this->plugins_.push_back(new Plugin(args)); }
+
+ // Load all plugin libraries.
+ void
+ load_plugins();
+
+ // Call the plugin claim-file handlers in turn to see if any claim the file.
+ Pluginobj*
+ claim_file(Input_file *input_file, off_t offset, off_t filesize);
+
+ // Call the all-symbols-read handlers.
+ void
+ all_symbols_read(Workqueue* workqueue, Input_objects* input_objects,
+ Symbol_table* symtab, Layout* layout, Dirsearch* dirpath,
+ Mapfile* mapfile, Task_token** last_blocker);
+
+ // Call the cleanup handlers.
+ void
+ cleanup();
+
+ // Register a claim-file handler.
+ void
+ set_claim_file_handler(ld_plugin_claim_file_handler handler)
+ {
+ gold_assert(this->current_ != plugins_.end());
+ (*this->current_)->set_claim_file_handler(handler);
+ }
+
+ // Register an all-symbols-read handler.
+ void
+ set_all_symbols_read_handler(ld_plugin_all_symbols_read_handler handler)
+ {
+ gold_assert(this->current_ != plugins_.end());
+ (*this->current_)->set_all_symbols_read_handler(handler);
+ }
+
+ // Register a claim-file handler.
+ void
+ set_cleanup_handler(ld_plugin_cleanup_handler handler)
+ {
+ gold_assert(this->current_ != plugins_.end());
+ (*this->current_)->set_cleanup_handler(handler);
+ }
+
+ // Make a new Pluginobj object. This is called when the plugin calls
+ // the add_symbols API.
+ Pluginobj*
+ make_plugin_object(unsigned int handle);
+
+ // Return the Pluginobj associated with the given HANDLE.
+ Pluginobj*
+ object(unsigned int handle) const
+ {
+ if (handle >= this->objects_.size())
+ return NULL;
+ return this->objects_[handle];
+ }
+
+ // Add a new input file.
+ ld_plugin_status
+ add_input_file(char *pathname);
+
+ // Return TRUE if we are in the replacement phase.
+ bool
+ in_replacement_phase() const
+ { return this->in_replacement_phase_; }
+
+ private:
+ Plugin_manager(const Plugin_manager&);
+ Plugin_manager& operator=(const Plugin_manager&);
+
+ typedef std::list<Plugin*> Plugin_list;
+ typedef std::vector<Pluginobj*> Object_list;
+
+ // The list of plugin libraries.
+ Plugin_list plugins_;
+ // A pointer to the current plugin. Used while loading plugins.
+ Plugin_list::iterator current_;
+
+ // The list of plugin objects. The index of an item in this list
+ // serves as the "handle" that we pass to the plugins.
+ Object_list objects_;
+
+ // The file currently up for claim by the plugins.
+ Input_file* input_file_;
+ struct ld_plugin_input_file plugin_input_file_;
+
+ // TRUE after the all symbols read event; indicates that we are
+ // processing replacement files whose symbols should replace the
+ // placeholder symbols from the Pluginobj objects.
+ bool in_replacement_phase_;
+
+ const General_options& options_;
+ Workqueue* workqueue_;
+ Input_objects* input_objects_;
+ Symbol_table* symtab_;
+ Layout* layout_;
+ Dirsearch* dirpath_;
+ Mapfile* mapfile_;
+ Task_token* this_blocker_;
+};
+
+
+// An object file claimed by a plugin. This is an abstract base class.
+// The implementation is the template class Sized_pluginobj.
+
+class Pluginobj : public Object
+{
+ public:
+
+ typedef std::vector<Symbol*> Symbols;
+
+ Pluginobj(const std::string& name, Input_file* input_file, off_t offset);
+
+ // Fill in the symbol resolution status for the given plugin symbols.
+ ld_plugin_status
+ get_symbol_resolution_info(int nsyms, ld_plugin_symbol* syms) const;
+
+ // Add symbol information to the global symbol table.
+ void
+ add_symbols(Symbol_table* symtab, Layout* layout)
+ { this->do_add_symbols(symtab, layout); }
+
+ // Store the incoming symbols from the plugin for later processing.
+ void
+ store_incoming_symbols(int nsyms, const struct ld_plugin_symbol* syms)
+ {
+ this->nsyms_ = nsyms;
+ this->syms_ = syms;
+ }
+
+ // Return TRUE if the comdat group with key COMDAT_KEY from this object
+ // should be kept.
+ bool
+ include_comdat_group(std::string comdat_key, Layout* layout);
+
+ protected:
+ // Return TRUE if this is an object claimed by a plugin.
+ virtual Pluginobj*
+ do_pluginobj()
+ { return this; }
+
+ // Add symbol information to the global symbol table--implemented by
+ // child class.
+ virtual void
+ do_add_symbols(Symbol_table*, Layout*) = 0;
+
+ // The number of symbols provided by the plugin.
+ int nsyms_;
+
+ // The symbols provided by the plugin.
+ const struct ld_plugin_symbol* syms_;
+
+ // The entries in the symbol table for the external symbols.
+ Symbols symbols_;
+
+ private:
+ // Map a comdat key symbol to a boolean indicating whether the comdat
+ // group in this object with that key should be kept.
+ typedef Unordered_map<std::string, bool> Comdat_map;
+ Comdat_map comdat_map_;
+};
+
+// A plugin object, size-specific version.
+
+template<int size, bool big_endian>
+class Sized_pluginobj : public Pluginobj
+{
+ public:
+ Sized_pluginobj(const std::string& name, Input_file* input_file,
+ off_t offset);
+
+ // Read the symbols.
+ void
+ do_read_symbols(Read_symbols_data*);
+
+ // Lay out the input sections.
+ void
+ do_layout(Symbol_table*, Layout*, Read_symbols_data*);
+
+ // Add the symbols to the symbol table.
+ void
+ do_add_symbols(Symbol_table*, Read_symbols_data*);
+
+ void
+ do_add_symbols(Symbol_table*, Layout*);
+
+ // Get the size of a section.
+ uint64_t
+ do_section_size(unsigned int shndx);
+
+ // Get the name of a section.
+ std::string
+ do_section_name(unsigned int shndx);
+
+ // Return a view of the contents of a section.
+ Object::Location
+ do_section_contents(unsigned int shndx);
+
+ // Return section flags.
+ uint64_t
+ do_section_flags(unsigned int shndx);
+
+ // Return section address.
+ uint64_t
+ do_section_address(unsigned int shndx);
+
+ // Return section type.
+ unsigned int
+ do_section_type(unsigned int shndx);
+
+ // Return the section link field.
+ unsigned int
+ do_section_link(unsigned int shndx);
+
+ // Return the section link field.
+ unsigned int
+ do_section_info(unsigned int shndx);
+
+ // Return the section alignment.
+ uint64_t
+ do_section_addralign(unsigned int shndx);
+
+ // Return the Xindex structure to use.
+ Xindex*
+ do_initialize_xindex();
+
+ // Get symbol counts.
+ void
+ do_get_global_symbol_counts(const Symbol_table*, size_t*, size_t*) const;
+
+ // Add placeholder symbols from a claimed file.
+ ld_plugin_status
+ add_symbols_from_plugin(int nsyms, const ld_plugin_symbol* syms);
+
+ protected:
+
+ private:
+};
+
+// This Task handles adding the symbols to the symbol table. These
+// tasks must be run in the same order as the arguments appear on the
+// command line.
+
+class Add_plugin_symbols : public Task
+{
+ public:
+ // THIS_BLOCKER is used to prevent this task from running before the
+ // one for the previous input file. NEXT_BLOCKER is used to prevent
+ // the next task from running.
+ Add_plugin_symbols(Symbol_table* symtab,
+ Layout* layout,
+ Pluginobj* obj,
+ Task_token* this_blocker,
+ Task_token* next_blocker)
+ : symtab_(symtab), layout_(layout), obj_(obj),
+ this_blocker_(this_blocker), next_blocker_(next_blocker)
+ { }
+
+ ~Add_plugin_symbols();
+
+ // The standard Task methods.
+
+ Task_token*
+ is_runnable();
+
+ void
+ locks(Task_locker*);
+
+ void
+ run(Workqueue*);
+
+ std::string
+ get_name() const
+ { return "Add_plugin_symbols " + this->obj_->name(); }
+
+private:
+ Symbol_table* symtab_;
+ Layout* layout_;
+ Pluginobj* obj_;
+ Task_token* this_blocker_;
+ Task_token* next_blocker_;
+};
+
+// This Task handles handles the "all symbols read" event hook.
+// The plugin may add additional input files at this time, which must
+// be queued for reading.
+
+class Plugin_hook : public Task
+{
+ public:
+ Plugin_hook(const General_options& options, Input_objects* input_objects,
+ Symbol_table* symtab, Layout* layout, Dirsearch* dirpath,
+ Mapfile* mapfile, Task_token* this_blocker,
+ Task_token* next_blocker)
+ : options_(options), input_objects_(input_objects), symtab_(symtab),
+ layout_(layout), dirpath_(dirpath), mapfile_(mapfile),
+ this_blocker_(this_blocker), next_blocker_(next_blocker)
+ { }
+
+ ~Plugin_hook();
+
+ // The standard Task methods.
+
+ Task_token*
+ is_runnable();
+
+ void
+ locks(Task_locker*);
+
+ void
+ run(Workqueue*);
+
+ std::string
+ get_name() const
+ { return "Plugin_hook"; }
+
+ private:
+ // Call the plugin hook.
+ void
+ do_plugin_hook(Workqueue*);
+
+ const General_options& options_;
+ Input_objects* input_objects_;
+ Symbol_table* symtab_;
+ Layout* layout_;
+ Dirsearch* dirpath_;
+ Mapfile* mapfile_;
+ Task_token* this_blocker_;
+ Task_token* next_blocker_;
+};
+
+} // End namespace gold.
+
+#endif // !defined(GOLD_PLUGIN_H)
diff --git a/gold/powerpc.cc b/gold/powerpc.cc
index 421cfdb..05ce4fc 100644
--- a/gold/powerpc.cc
+++ b/gold/powerpc.cc
@@ -129,7 +129,7 @@ class Target_powerpc : public Sized_target<size, big_endian>
// Return whether SYM is defined by the ABI.
bool
- do_is_defined_by_abi(Symbol* sym) const
+ do_is_defined_by_abi(const Symbol* sym) const
{
return strcmp(sym->name(), "___tls_get_addr") == 0;
}
diff --git a/gold/readsyms.cc b/gold/readsyms.cc
index 05c80f8..ac646d9 100644
--- a/gold/readsyms.cc
+++ b/gold/readsyms.cc
@@ -32,6 +32,7 @@
#include "archive.h"
#include "script.h"
#include "readsyms.h"
+#include "plugin.h"
namespace gold
{
@@ -159,6 +160,53 @@ Read_symbols::do_read_symbols(Workqueue* workqueue)
const unsigned char* ehdr = input_file->file().get_view(0, 0, read_size,
true, false);
+ if (read_size >= Archive::sarmag)
+ {
+ bool is_thin_archive
+ = memcmp(ehdr, Archive::armagt, Archive::sarmag) == 0;
+ if (is_thin_archive
+ || memcmp(ehdr, Archive::armag, Archive::sarmag) == 0)
+ {
+ // This is an archive.
+ Archive* arch = new Archive(this->input_argument_->file().name(),
+ input_file, is_thin_archive,
+ this->dirpath_, this);
+ arch->setup(this->input_objects_);
+
+ // Unlock the archive so it can be used in the next task.
+ arch->unlock(this);
+
+ workqueue->queue_next(new Add_archive_symbols(this->symtab_,
+ this->layout_,
+ this->input_objects_,
+ this->mapfile_,
+ arch,
+ this->input_group_,
+ this->this_blocker_,
+ this->next_blocker_));
+ return true;
+ }
+ }
+
+ if (parameters->options().has_plugins())
+ {
+ Pluginobj* obj = parameters->options().plugins()->claim_file(input_file,
+ 0, filesize);
+ if (obj != NULL)
+ {
+ // The input file was claimed by a plugin, and its symbols
+ // have been provided by the plugin.
+ input_file->file().claim_for_plugin();
+ input_file->file().unlock(this);
+ workqueue->queue_next(new Add_plugin_symbols(this->symtab_,
+ this->layout_,
+ obj,
+ this->this_blocker_,
+ this->next_blocker_));
+ return true;
+ }
+ }
+
if (read_size >= 4)
{
static unsigned char elfmagic[4] =
@@ -201,34 +249,6 @@ Read_symbols::do_read_symbols(Workqueue* workqueue)
}
}
- if (read_size >= Archive::sarmag)
- {
- bool is_thin_archive
- = memcmp(ehdr, Archive::armagt, Archive::sarmag) == 0;
- if (is_thin_archive
- || memcmp(ehdr, Archive::armag, Archive::sarmag) == 0)
- {
- // This is an archive.
- Archive* arch = new Archive(this->input_argument_->file().name(),
- input_file, is_thin_archive,
- this->dirpath_, this);
- arch->setup(this->input_objects_);
-
- // Unlock the archive so it can be used in the next task.
- arch->unlock(this);
-
- workqueue->queue_next(new Add_archive_symbols(this->symtab_,
- this->layout_,
- this->input_objects_,
- this->mapfile_,
- arch,
- this->input_group_,
- this->this_blocker_,
- this->next_blocker_));
- return true;
- }
- }
-
// Queue up a task to try to parse this file as a script. We use a
// separate task so that the script will be read in order with other
// objects named on the command line. Also so that we don't try to
diff --git a/gold/reloc.cc b/gold/reloc.cc
index daa0ea8..481617d 100644
--- a/gold/reloc.cc
+++ b/gold/reloc.cc
@@ -586,8 +586,8 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
// In the normal case, this input section is simply mapped to
// the output section at offset OUTPUT_OFFSET.
- // However, if OUTPUT_OFFSET == -1U, then input data is handled
- // specially--e.g., a .eh_frame section. The relocation
+ // However, if OUTPUT_OFFSET == INVALID_ADDRESS, then input data is
+ // handled specially--e.g., a .eh_frame section. The relocation
// routines need to check for each reloc where it should be
// applied. For this case, we need an input/output view for the
// entire contents of the section in the output file. We don't
@@ -619,7 +619,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
off_t view_start;
section_size_type view_size;
- if (output_offset != -1U)
+ if (output_offset != invalid_address)
{
view_start = output_section_offset + output_offset;
view_size = convert_to_section_size_type(shdr.get_sh_size());
@@ -633,7 +633,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
if (view_size == 0)
continue;
- gold_assert(output_offset == -1U
+ gold_assert(output_offset == invalid_address
|| output_offset + view_size <= output_section_size);
unsigned char* view;
@@ -641,7 +641,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
{
unsigned char* buffer = os->postprocessing_buffer();
view = buffer + view_start;
- if (output_offset != -1U)
+ if (output_offset != invalid_address)
{
off_t sh_offset = shdr.get_sh_offset();
if (!rm.empty() && rm.back().file_offset > sh_offset)
@@ -652,7 +652,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
}
else
{
- if (output_offset == -1U)
+ if (output_offset == invalid_address)
view = of->get_input_output_view(view_start, view_size);
else
{
@@ -667,11 +667,11 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
pvs->view = view;
pvs->address = os->address();
- if (output_offset != -1U)
+ if (output_offset != invalid_address)
pvs->address += output_offset;
pvs->offset = view_start;
pvs->view_size = view_size;
- pvs->is_input_output_view = output_offset == -1U;
+ pvs->is_input_output_view = output_offset == invalid_address;
pvs->is_postprocessing_view = os->requires_postprocessing();
}
@@ -772,7 +772,7 @@ Sized_relobj<size, big_endian>::relocate_sections(
continue;
}
- gold_assert(output_offset != -1U
+ gold_assert(output_offset != invalid_address
|| this->relocs_must_follow_section_writes());
relinfo.reloc_shndx = i;
@@ -784,7 +784,7 @@ Sized_relobj<size, big_endian>::relocate_sections(
prelocs,
reloc_count,
os,
- output_offset == -1U,
+ output_offset == invalid_address,
(*pviews)[index].view,
(*pviews)[index].address,
(*pviews)[index].view_size);
diff --git a/gold/resolve.cc b/gold/resolve.cc
index 0ad990c..17544f8 100644
--- a/gold/resolve.cc
+++ b/gold/resolve.cc
@@ -26,6 +26,7 @@
#include "target.h"
#include "object.h"
#include "symtab.h"
+#include "plugin.h"
namespace gold
{
@@ -240,6 +241,24 @@ Symbol_table::resolve(Sized_symbol<size>* to,
to->set_in_dyn();
}
+ // Record if we've seen this symbol in a real ELF object (i.e., the
+ // symbol is referenced from outside the world known to the plugin).
+ if (object->pluginobj() == NULL)
+ to->set_in_real_elf();
+
+ // If we're processing replacement files, allow new symbols to override
+ // the placeholders from the plugin objects.
+ if (to->source() == Symbol::FROM_OBJECT)
+ {
+ Pluginobj* obj = to->object()->pluginobj();
+ if (obj != NULL
+ && parameters->options().plugins()->in_replacement_phase())
+ {
+ this->override(to, sym, st_shndx, is_ordinary, object, version);
+ return;
+ }
+ }
+
unsigned int frombits = symbol_to_bits(sym.get_st_bind(),
object->is_dynamic(),
st_shndx, is_ordinary,
diff --git a/gold/sparc.cc b/gold/sparc.cc
index 7da59dd..cca78b7 100644
--- a/gold/sparc.cc
+++ b/gold/sparc.cc
@@ -130,7 +130,7 @@ class Target_sparc : public Sized_target<size, big_endian>
section_size_type reloc_view_size);
// Return whether SYM is defined by the ABI.
bool
- do_is_defined_by_abi(Symbol* sym) const
+ do_is_defined_by_abi(const Symbol* sym) const
{
// XXX Really need to support this better...
if (sym->type() == elfcpp::STT_SPARC_REGISTER)
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 393d71a..c2de3bc 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -37,6 +37,7 @@
#include "target.h"
#include "workqueue.h"
#include "symtab.h"
+#include "plugin.h"
namespace gold
{
@@ -73,6 +74,7 @@ Symbol::init_fields(const char* name, const char* version,
this->is_copied_from_dynobj_ = false;
this->is_forced_local_ = false;
this->is_ordinary_shndx_ = false;
+ this->in_real_elf_ = false;
}
// Return the demangled version of the symbol's name, but only
@@ -117,6 +119,7 @@ Symbol::init_base_object(const char* name, const char* version, Object* object,
this->source_ = FROM_OBJECT;
this->in_reg_ = !object->is_dynamic();
this->in_dyn_ = object->is_dynamic();
+ this->in_real_elf_ = object->pluginobj() == NULL;
}
// Initialize the fields in the base class Symbol for a symbol defined
@@ -133,6 +136,7 @@ Symbol::init_base_output_data(const char* name, const char* version,
this->u_.in_output_data.offset_is_from_end = offset_is_from_end;
this->source_ = IN_OUTPUT_DATA;
this->in_reg_ = true;
+ this->in_real_elf_ = true;
}
// Initialize the fields in the base class Symbol for a symbol defined
@@ -150,6 +154,7 @@ Symbol::init_base_output_segment(const char* name, const char* version,
this->u_.in_output_segment.offset_base = offset_base;
this->source_ = IN_OUTPUT_SEGMENT;
this->in_reg_ = true;
+ this->in_real_elf_ = true;
}
// Initialize the fields in the base class Symbol for a symbol defined
@@ -163,6 +168,7 @@ Symbol::init_base_constant(const char* name, const char* version,
this->init_fields(name, version, type, binding, visibility, nonvis);
this->source_ = IS_CONSTANT;
this->in_reg_ = true;
+ this->in_real_elf_ = true;
}
// Initialize the fields in the base class Symbol for an undefined
@@ -177,6 +183,7 @@ Symbol::init_base_undefined(const char* name, const char* version,
this->dynsym_index_ = -1U;
this->source_ = IS_UNDEFINED;
this->in_reg_ = true;
+ this->in_real_elf_ = true;
}
// Allocate a common symbol in the base.
@@ -357,6 +364,7 @@ Symbol::output_section() const
if (shndx != elfcpp::SHN_UNDEF && this->is_ordinary_shndx_)
{
gold_assert(!this->u_.from_object.object->is_dynamic());
+ gold_assert(this->u_.from_object.object->pluginobj() == NULL);
Relobj* relobj = static_cast<Relobj*>(this->u_.from_object.object);
return relobj->output_section(shndx);
}
@@ -973,6 +981,68 @@ Symbol_table::add_from_relobj(
}
}
+// Add a symbol from a plugin-claimed file.
+
+template<int size, bool big_endian>
+Symbol*
+Symbol_table::add_from_pluginobj(
+ Sized_pluginobj<size, big_endian>* obj,
+ const char* name,
+ const char* ver,
+ elfcpp::Sym<size, big_endian>* sym)
+{
+ unsigned int st_shndx = sym->get_st_shndx();
+
+ Stringpool::Key ver_key = 0;
+ bool def = false;
+ bool local = false;
+
+ if (ver != NULL)
+ {
+ ver = this->namepool_.add(ver, true, &ver_key);
+ }
+ // We don't want to assign a version to an undefined symbol,
+ // even if it is listed in the version script. FIXME: What
+ // about a common symbol?
+ else
+ {
+ if (!this->version_script_.empty()
+ && st_shndx != elfcpp::SHN_UNDEF)
+ {
+ // The symbol name did not have a version, but the
+ // version script may assign a version anyway.
+ std::string version;
+ if (this->version_script_.get_symbol_version(name, &version))
+ {
+ // The version can be empty if the version script is
+ // only used to force some symbols to be local.
+ if (!version.empty())
+ {
+ ver = this->namepool_.add_with_length(version.c_str(),
+ version.length(),
+ true,
+ &ver_key);
+ def = true;
+ }
+ }
+ else if (this->version_script_.symbol_is_local(name))
+ local = true;
+ }
+ }
+
+ Stringpool::Key name_key;
+ name = this->namepool_.add(name, true, &name_key);
+
+ Sized_symbol<size>* res;
+ res = this->add_from_object(obj, name, name_key, ver, ver_key,
+ def, *sym, st_shndx, true, st_shndx);
+
+ if (local)
+ this->force_local(res);
+
+ return res;
+}
+
// Add all the symbols in a dynamic object to the hash table.
template<int size, bool big_endian>
@@ -2043,6 +2113,11 @@ Symbol_table::sized_finalize_symbol(Symbol* unsized_sym)
value = 0;
shndx = elfcpp::SHN_UNDEF;
}
+ else if (symobj->pluginobj() != NULL)
+ {
+ value = 0;
+ shndx = elfcpp::SHN_UNDEF;
+ }
else if (shndx == elfcpp::SHN_UNDEF)
value = 0;
else if (!is_ordinary
@@ -2061,11 +2136,20 @@ Symbol_table::sized_finalize_symbol(Symbol* unsized_sym)
}
uint64_t secoff64 = relobj->output_section_offset(shndx);
- Value_type secoff = convert_types<Value_type, uint64_t>(secoff64);
- if (sym->type() == elfcpp::STT_TLS)
- value = sym->value() + os->tls_offset() + secoff;
- else
- value = sym->value() + os->address() + secoff;
+ if (secoff64 == -1ULL)
+ {
+ // The section needs special handling (e.g., a merge section).
+ value = os->output_address(relobj, shndx, sym->value());
+ }
+ else
+ {
+ Value_type secoff =
+ convert_types<Value_type, uint64_t>(secoff64);
+ if (sym->type() == elfcpp::STT_TLS)
+ value = sym->value() + os->tls_offset() + secoff;
+ else
+ value = sym->value() + os->address() + secoff;
+ }
}
}
break;
@@ -2261,6 +2345,8 @@ Symbol_table::sized_write_globals(const Input_objects* input_objects,
dynsym_value = target.dynsym_value(sym);
shndx = elfcpp::SHN_UNDEF;
}
+ else if (symobj->pluginobj() != NULL)
+ shndx = elfcpp::SHN_UNDEF;
else if (in_shndx == elfcpp::SHN_UNDEF
|| (!is_ordinary
&& (in_shndx == elfcpp::SHN_ABS
@@ -2703,6 +2789,46 @@ Symbol_table::add_from_relobj<64, true>(
#ifdef HAVE_TARGET_32_LITTLE
template
+Symbol*
+Symbol_table::add_from_pluginobj<32, false>(
+ Sized_pluginobj<32, false>* obj,
+ const char* name,
+ const char* ver,
+ elfcpp::Sym<32, false>* sym);
+#endif
+
+#ifdef HAVE_TARGET_32_BIG
+template
+Symbol*
+Symbol_table::add_from_pluginobj<32, true>(
+ Sized_pluginobj<32, true>* obj,
+ const char* name,
+ const char* ver,
+ elfcpp::Sym<32, true>* sym);
+#endif
+
+#ifdef HAVE_TARGET_64_LITTLE
+template
+Symbol*
+Symbol_table::add_from_pluginobj<64, false>(
+ Sized_pluginobj<64, false>* obj,
+ const char* name,
+ const char* ver,
+ elfcpp::Sym<64, false>* sym);
+#endif
+
+#ifdef HAVE_TARGET_64_BIG
+template
+Symbol*
+Symbol_table::add_from_pluginobj<64, true>(
+ Sized_pluginobj<64, true>* obj,
+ const char* name,
+ const char* ver,
+ elfcpp::Sym<64, true>* sym);
+#endif
+
+#ifdef HAVE_TARGET_32_LITTLE
+template
void
Symbol_table::add_from_dynobj<32, false>(
Sized_dynobj<32, false>* dynobj,
diff --git a/gold/symtab.h b/gold/symtab.h
index 043fb50f..cfd0c73 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -43,6 +43,8 @@ class Object;
class Relobj;
template<int size, bool big_endian>
class Sized_relobj;
+template<int size, bool big_endian>
+class Sized_pluginobj;
class Dynobj;
template<int size, bool big_endian>
class Sized_dynobj;
@@ -273,6 +275,18 @@ class Symbol
set_in_dyn()
{ this->in_dyn_ = true; }
+ // Return whether this symbol has been seen in a real ELF object.
+ // (IN_REG will return TRUE if the symbol has been seen in either
+ // a real ELF object or an object claimed by a plugin.)
+ bool
+ in_real_elf() const
+ { return this->in_real_elf_; }
+
+ // Mark this symbol as having been seen in a real ELF object.
+ void
+ set_in_real_elf()
+ { this->in_real_elf_ = true; }
+
// Return the index of this symbol in the output file symbol table.
// A value of -1U means that this symbol is not going into the
// output file. This starts out as zero, and is set to a non-zero
@@ -871,8 +885,10 @@ class Symbol
bool is_forced_local_ : 1;
// True if the field u_.from_object.shndx is an ordinary section
// index, not one of the special codes from SHN_LORESERVE to
- // SHN_HIRESERVE.
+ // SHN_HIRESERVE (bit 31).
bool is_ordinary_shndx_ : 1;
+ // True if we've seen this symbol in a real ELF object.
+ bool in_real_elf_ : 1;
};
// The parts of a symbol which are size specific. Using a template
@@ -1139,6 +1155,14 @@ class Symbol_table
typename Sized_relobj<size, big_endian>::Symbols*,
size_t* defined);
+ // Add one external symbol from the plugin object OBJ to the symbol table.
+ // Returns a pointer to the resolved symbol in the symbol table.
+ template<int size, bool big_endian>
+ Symbol*
+ add_from_pluginobj(Sized_pluginobj<size, big_endian>* obj,
+ const char* name, const char* ver,
+ elfcpp::Sym<size, big_endian>* sym);
+
// Add COUNT dynamic symbols from the dynamic object DYNOBJ to the
// symbol table. SYMS is the symbols. SYM_NAMES is their names.
// SYM_NAME_SIZE is the size of SYM_NAMES. The other parameters are
diff --git a/gold/target-reloc.h b/gold/target-reloc.h
index 6683ddd..935d76b 100644
--- a/gold/target-reloc.h
+++ b/gold/target-reloc.h
@@ -283,6 +283,7 @@ relocate_section(
if (sym != NULL
&& sym->is_undefined()
&& sym->binding() != elfcpp::STB_WEAK
+ && !target->is_defined_by_abi(sym)
&& (!parameters->options().shared() // -shared
|| parameters->options().defs())) // -z defs
gold_undefined_symbol(sym, relinfo, i, offset);
@@ -449,6 +450,7 @@ relocate_for_relocatable(
typedef typename Reloc_types<sh_type, size, big_endian>::Reloc_write
Reltype_write;
const int reloc_size = Reloc_types<sh_type, size, big_endian>::reloc_size;
+ const Address invalid_address = static_cast<Address>(0) - 1;
Sized_relobj<size, big_endian>* const object = relinfo->object;
const unsigned int local_count = object->local_symbol_count();
@@ -523,7 +525,7 @@ relocate_for_relocatable(
Address offset = reloc.get_r_offset();
Address new_offset;
- if (offset_in_output_section != -1U)
+ if (offset_in_output_section != invalid_address)
new_offset = offset + offset_in_output_section;
else
{
@@ -542,7 +544,7 @@ relocate_for_relocatable(
if (!parameters->options().relocatable())
{
new_offset += view_address;
- if (offset_in_output_section != -1U)
+ if (offset_in_output_section != invalid_address)
new_offset -= offset_in_output_section;
}
diff --git a/gold/target.h b/gold/target.h
index 30fa008..460ac96 100644
--- a/gold/target.h
+++ b/gold/target.h
@@ -164,7 +164,7 @@ class Target
// Return whether SYM is known to be defined by the ABI. This is
// used to avoid inappropriate warnings about undefined symbols.
bool
- is_defined_by_abi(Symbol* sym) const
+ is_defined_by_abi(const Symbol* sym) const
{ return this->do_is_defined_by_abi(sym); }
protected:
@@ -222,7 +222,7 @@ class Target
// Virtual function which may be implemented by the child class.
virtual bool
- do_is_defined_by_abi(Symbol*) const
+ do_is_defined_by_abi(const Symbol*) const
{ return false; }
private:
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index c9dd470..57d96cd 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -9,6 +9,7 @@ AUTOMAKE_OPTIONS =
# The two_file_test tests -fmerge-constants, so we simply always turn
# it on. This may need to be controlled by a configure option
# eventually.
+AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) -fmerge-constants
AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) -fmerge-constants
INCLUDES = \
@@ -21,6 +22,11 @@ TEST_READELF = $(top_builddir)/../binutils/readelf
TEST_OBJDUMP = $(top_builddir)/../binutils/objdump
TEST_CXXFILT = $(top_builddir)/../binutils/cxxfilt
TEST_STRIP = $(top_builddir)/../binutils/strip-new
+TEST_AR = $(top_builddir)/../binutils/ar
+
+if PLUGINS
+LIBDL = -ldl
+endif
if THREADS
THREADSLIB = -lpthread
@@ -57,7 +63,7 @@ libgoldtest_a_SOURCES = test.cc testmain.cc testfile.cc
DEPENDENCIES = \
libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL_DEP)
LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \
- $(THREADSLIB)
+ $(THREADSLIB) $(LIBDL)
# The unittests themselves
@@ -468,7 +474,7 @@ tls_test_file2_pic.o: tls_test_file2.cc
tls_test_c_pic.o: tls_test_c.c
$(COMPILE) -c -fpic $(TLS_TEST_C_CFLAGS) -o $@ $<
tls_test_shared.so: tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o gcctestdir/ld
- $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o
+ $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -Wl,-z,defs
tls_test_shared2.so: tls_test_file2_pic.o gcctestdir/ld
$(CXXLINK) -Bgcctestdir/ -shared tls_test_file2_pic.o
@@ -897,5 +903,75 @@ script_test_4: basic_test.o gcctestdir/ld $(srcdir)/script_test_4.t
script_test_4.stdout: script_test_4
$(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
+check_PROGRAMS += thin_archive_test_1
+thin_archive_test_1_SOURCES = thin_archive_main.cc
+thin_archive_test_1_DEPENDENCIES = gcctestdir/ld libthin1.a alt/libthin2.a
+thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt
+thin_archive_test_1_LDADD = libthin1.a -lthin2
+
+check_PROGRAMS += thin_archive_test_2
+thin_archive_test_2_SOURCES = thin_archive_main.cc
+thin_archive_test_2_DEPENDENCIES = gcctestdir/ld libthinall.a
+thin_archive_test_2_LDFLAGS = -Bgcctestdir/ -L.
+thin_archive_test_2_LDADD = -lthinall
+
+libthin1.a: thin_archive_test_1.o alt/thin_archive_test_2.o
+ rm -f $@
+ $(TEST_AR) crT $@ $^
+alt/libthin2.a: thin_archive_test_3.o alt/thin_archive_test_4.o
+ rm -f $@
+ $(TEST_AR) crT $@ $^
+libthin3.a: thin_archive_test_1.o alt/thin_archive_test_4.o
+ rm -f $@
+ $(TEST_AR) crT $@ $^
+alt/libthin4.a: alt/thin_archive_test_2.o thin_archive_test_3.o
+ rm -f $@
+ $(TEST_AR) crT $@ $^
+libthinall.a: libthin3.a alt/libthin4.a
+ rm -f $@
+ $(TEST_AR) crT $@ $^
+alt/thin_archive_test_2.o: thin_archive_test_2.cc
+ test -d alt || mkdir -p alt
+ $(CXXCOMPILE) -c -o $@ $<
+alt/thin_archive_test_4.o: thin_archive_test_4.cc
+ test -d alt || mkdir -p alt
+ $(CXXCOMPILE) -c -o $@ $<
+
+if PLUGINS
+
+check_PROGRAMS += plugin_test_1
+check_SCRIPTS += plugin_test_1.sh
+check_DATA += plugin_test_1.err
+MOSTLYCLEANFILES += plugin_test_1.err
+plugin_test_1: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms gcctestdir/ld plugin_test.so
+ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so;_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms 2>plugin_test_1.err
+plugin_test_1.err: plugin_test_1
+ @touch plugin_test_1.err
+
+check_PROGRAMS += plugin_test_2
+check_SCRIPTS += plugin_test_2.sh
+check_DATA += plugin_test_2.err
+MOSTLYCLEANFILES += plugin_test_2.err
+plugin_test_2: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_shared_2.so gcctestdir/ld plugin_test.so
+ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,-R,.,--plugin,"./plugin_test.so" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_shared_2.so 2>plugin_test_2.err
+plugin_test_2.err: plugin_test_2
+ @touch plugin_test_2.err
+
+plugin_test.so: plugin_test.o
+ $(LINK) -Bgcctestdir/ -shared plugin_test.o
+plugin_test.o: plugin_test.c
+ $(COMPILE) -O0 -c -fpic -o $@ $<
+
+two_file_test_main.syms: two_file_test_main.o
+ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+two_file_test_1.syms: two_file_test_1.o
+ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+two_file_test_1b.syms: two_file_test_1b.o
+ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+two_file_test_2.syms: two_file_test_2.o
+ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+
+endif PLUGINS
+
endif GCC
endif NATIVE_LINKER
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 9f72b88..54b2364 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -47,7 +47,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
$(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \
$(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \
$(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12) \
- $(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15)
+ $(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15) \
+ $(am__EXEEXT_16)
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_1 = basic_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_static_test basic_pic_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_static_pic_test \
@@ -66,33 +67,39 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_relocatable_test
@GCC_FALSE@constructor_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@constructor_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@constructor_static_test_DEPENDENCIES = libgoldtest.a \
@GCC_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
-@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@GCC_FALSE@ $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@constructor_static_test_DEPENDENCIES = \
@NATIVE_LINKER_FALSE@ libgoldtest.a ../libgold.a \
@NATIVE_LINKER_FALSE@ ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@two_file_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@two_file_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@two_file_static_test_DEPENDENCIES = libgoldtest.a \
@GCC_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
-@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@GCC_FALSE@ $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@two_file_static_test_DEPENDENCIES = \
@NATIVE_LINKER_FALSE@ libgoldtest.a ../libgold.a \
@NATIVE_LINKER_FALSE@ ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
# The nonpic tests will fail on platforms which can not put non-PIC
@@ -116,32 +123,37 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test weak_undef_test
@GCC_FALSE@common_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@common_test_1_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@exception_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@exception_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@exception_static_test_DEPENDENCIES = libgoldtest.a \
@GCC_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
-@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@GCC_FALSE@ $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@exception_static_test_DEPENDENCIES = \
@NATIVE_LINKER_FALSE@ libgoldtest.a ../libgold.a \
@NATIVE_LINKER_FALSE@ ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@weak_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@weak_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_4 = weak_undef_nonpic_test
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_5 = weak_alias_test weak_plt \
@@ -187,10 +199,12 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_r_test
@GCC_FALSE@many_sections_test_DEPENDENCIES = libgoldtest.a \
@GCC_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
-@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@GCC_FALSE@ $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@many_sections_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_14 = many_sections_define.h \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_check.h
@@ -199,13 +213,15 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@CONSTRUCTOR_PRIORITY_FALSE@ ../libgold.a \
@CONSTRUCTOR_PRIORITY_FALSE@ ../../libiberty/libiberty.a \
@CONSTRUCTOR_PRIORITY_FALSE@ $(am__DEPENDENCIES_1) \
+@CONSTRUCTOR_PRIORITY_FALSE@ $(am__DEPENDENCIES_1) \
@CONSTRUCTOR_PRIORITY_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@initpri1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@initpri1_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_16 = debug_msg.err \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_so.err \
@@ -232,35 +248,55 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test relro_script_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1 script_test_2 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms binary_test \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2
@GCC_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@script_test_2_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@script_test_2_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@justsyms_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@justsyms_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@binary_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@binary_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@thin_archive_test_2_DEPENDENCIES =
+@NATIVE_LINKER_FALSE@thin_archive_test_2_DEPENDENCIES =
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_20 = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_21 = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.sh
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_22 = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.err \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_23 = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.err \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.err
subdir = testsuite
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -357,32 +393,36 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ binary_test$(EXEEXT) \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3$(EXEEXT)
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2$(EXEEXT)
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__EXEEXT_16 = plugin_test_1$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2$(EXEEXT)
basic_pic_test_SOURCES = basic_pic_test.c
basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT)
basic_pic_test_LDADD = $(LDADD)
am__DEPENDENCIES_1 =
basic_pic_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
basic_static_pic_test_SOURCES = basic_static_pic_test.c
basic_static_pic_test_OBJECTS = basic_static_pic_test.$(OBJEXT)
basic_static_pic_test_LDADD = $(LDADD)
basic_static_pic_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
basic_static_test_SOURCES = basic_static_test.c
basic_static_test_OBJECTS = basic_static_test.$(OBJEXT)
basic_static_test_LDADD = $(LDADD)
basic_static_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
basic_test_SOURCES = basic_test.c
basic_test_OBJECTS = basic_test.$(OBJEXT)
basic_test_LDADD = $(LDADD)
basic_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__binary_test_SOURCES_DIST = binary_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_binary_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ binary_test.$(OBJEXT)
@@ -393,7 +433,7 @@ binary_unittest_OBJECTS = $(am_binary_unittest_OBJECTS)
binary_unittest_LDADD = $(LDADD)
binary_unittest_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__common_test_1_SOURCES_DIST = common_test_1.c
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_common_test_1_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ common_test_1.$(OBJEXT)
@@ -472,13 +512,13 @@ flagstest_compress_debug_sections_OBJECTS = \
flagstest_compress_debug_sections_LDADD = $(LDADD)
flagstest_compress_debug_sections_DEPENDENCIES = libgoldtest.a \
../libgold.a ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
flagstest_o_specialfile_SOURCES = flagstest_o_specialfile.c
flagstest_o_specialfile_OBJECTS = flagstest_o_specialfile.$(OBJEXT)
flagstest_o_specialfile_LDADD = $(LDADD)
flagstest_o_specialfile_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
flagstest_o_specialfile_and_compress_debug_sections_SOURCES = \
flagstest_o_specialfile_and_compress_debug_sections.c
flagstest_o_specialfile_and_compress_debug_sections_OBJECTS = \
@@ -486,7 +526,8 @@ flagstest_o_specialfile_and_compress_debug_sections_OBJECTS = \
flagstest_o_specialfile_and_compress_debug_sections_LDADD = $(LDADD)
flagstest_o_specialfile_and_compress_debug_sections_DEPENDENCIES = \
libgoldtest.a ../libgold.a ../../libiberty/libiberty.a \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
am__initpri1_SOURCES_DIST = initpri1.c
@CONSTRUCTOR_PRIORITY_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am_initpri1_OBJECTS = initpri1.$(OBJEXT)
initpri1_OBJECTS = $(am_initpri1_OBJECTS)
@@ -501,7 +542,7 @@ many_sections_r_test_OBJECTS = many_sections_r_test.$(OBJEXT)
many_sections_r_test_LDADD = $(LDADD)
many_sections_r_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__many_sections_test_SOURCES_DIST = many_sections_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_many_sections_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_test.$(OBJEXT)
@@ -512,7 +553,19 @@ object_unittest_OBJECTS = $(am_object_unittest_OBJECTS)
object_unittest_LDADD = $(LDADD)
object_unittest_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+plugin_test_1_SOURCES = plugin_test_1.c
+plugin_test_1_OBJECTS = plugin_test_1.$(OBJEXT)
+plugin_test_1_LDADD = $(LDADD)
+plugin_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
+ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+plugin_test_2_SOURCES = plugin_test_2.c
+plugin_test_2_OBJECTS = plugin_test_2.$(OBJEXT)
+plugin_test_2_LDADD = $(LDADD)
+plugin_test_2_DEPENDENCIES = libgoldtest.a ../libgold.a \
+ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__protected_1_SOURCES_DIST = protected_main_1.cc protected_main_2.cc \
protected_main_3.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_protected_1_OBJECTS = \
@@ -551,7 +604,15 @@ script_test_3_OBJECTS = script_test_3.$(OBJEXT)
script_test_3_LDADD = $(LDADD)
script_test_3_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am__thin_archive_test_1_SOURCES_DIST = thin_archive_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am_thin_archive_test_1_OBJECTS = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_main.$(OBJEXT)
+thin_archive_test_1_OBJECTS = $(am_thin_archive_test_1_OBJECTS)
+am__thin_archive_test_2_SOURCES_DIST = thin_archive_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am_thin_archive_test_2_OBJECTS = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_main.$(OBJEXT)
+thin_archive_test_2_OBJECTS = $(am_thin_archive_test_2_OBJECTS)
am__tls_pic_test_SOURCES_DIST = tls_test_main.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am_tls_pic_test_OBJECTS = tls_test_main.$(OBJEXT)
tls_pic_test_OBJECTS = $(am_tls_pic_test_OBJECTS)
@@ -708,7 +769,7 @@ two_file_strip_test_OBJECTS = two_file_strip_test.$(OBJEXT)
two_file_strip_test_LDADD = $(LDADD)
two_file_strip_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__two_file_test_SOURCES_DIST = two_file_test_1.cc \
two_file_test_1b.cc two_file_test_2.cc two_file_test_main.cc \
two_file_test.h
@@ -748,7 +809,7 @@ weak_plt_OBJECTS = weak_plt.$(OBJEXT)
weak_plt_LDADD = $(LDADD)
weak_plt_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__weak_test_SOURCES_DIST = weak_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_weak_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test.$(OBJEXT)
@@ -788,11 +849,12 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
flagstest_o_specialfile_and_compress_debug_sections.c \
$(initpri1_SOURCES) $(justsyms_SOURCES) many_sections_r_test.c \
$(many_sections_test_SOURCES) $(object_unittest_SOURCES) \
- $(protected_1_SOURCES) $(protected_2_SOURCES) \
- $(relro_script_test_SOURCES) $(relro_test_SOURCES) \
- $(script_test_1_SOURCES) $(script_test_2_SOURCES) \
- script_test_3.c $(tls_pic_test_SOURCES) \
- $(tls_shared_gd_to_ie_test_SOURCES) \
+ plugin_test_1.c plugin_test_2.c $(protected_1_SOURCES) \
+ $(protected_2_SOURCES) $(relro_script_test_SOURCES) \
+ $(relro_test_SOURCES) $(script_test_1_SOURCES) \
+ $(script_test_2_SOURCES) script_test_3.c \
+ $(thin_archive_test_1_SOURCES) $(thin_archive_test_2_SOURCES) \
+ $(tls_pic_test_SOURCES) $(tls_shared_gd_to_ie_test_SOURCES) \
$(tls_shared_gnu2_gd_to_ie_test_SOURCES) \
$(tls_shared_gnu2_test_SOURCES) $(tls_shared_ie_test_SOURCES) \
$(tls_shared_nonpic_test_SOURCES) $(tls_shared_test_SOURCES) \
@@ -838,12 +900,15 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
flagstest_o_specialfile_and_compress_debug_sections.c \
$(am__initpri1_SOURCES_DIST) $(am__justsyms_SOURCES_DIST) \
many_sections_r_test.c $(am__many_sections_test_SOURCES_DIST) \
- $(object_unittest_SOURCES) $(am__protected_1_SOURCES_DIST) \
+ $(object_unittest_SOURCES) plugin_test_1.c plugin_test_2.c \
+ $(am__protected_1_SOURCES_DIST) \
$(am__protected_2_SOURCES_DIST) \
$(am__relro_script_test_SOURCES_DIST) \
$(am__relro_test_SOURCES_DIST) \
$(am__script_test_1_SOURCES_DIST) \
$(am__script_test_2_SOURCES_DIST) script_test_3.c \
+ $(am__thin_archive_test_1_SOURCES_DIST) \
+ $(am__thin_archive_test_2_SOURCES_DIST) \
$(am__tls_pic_test_SOURCES_DIST) \
$(am__tls_shared_gd_to_ie_test_SOURCES_DIST) \
$(am__tls_shared_gnu2_gd_to_ie_test_SOURCES_DIST) \
@@ -954,6 +1019,8 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PLUGINS_FALSE = @PLUGINS_FALSE@
+PLUGINS_TRUE = @PLUGINS_TRUE@
POSUB = @POSUB@
RANDOM_SEED_CFLAGS = @RANDOM_SEED_CFLAGS@
RANLIB = @RANLIB@
@@ -1027,6 +1094,7 @@ AUTOMAKE_OPTIONS =
# The two_file_test tests -fmerge-constants, so we simply always turn
# it on. This may need to be controlled by a configure option
# eventually.
+AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) -fmerge-constants
AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) -fmerge-constants
INCLUDES = \
-I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../include \
@@ -1038,6 +1106,8 @@ TEST_READELF = $(top_builddir)/../binutils/readelf
TEST_OBJDUMP = $(top_builddir)/../binutils/objdump
TEST_CXXFILT = $(top_builddir)/../binutils/cxxfilt
TEST_STRIP = $(top_builddir)/../binutils/strip-new
+TEST_AR = $(top_builddir)/../binutils/ar
+@PLUGINS_TRUE@LIBDL = -ldl
@THREADS_TRUE@THREADSLIB = -lpthread
@OMP_SUPPORT_TRUE@TLS_TEST_C_CFLAGS = -fopenmp
@@ -1045,13 +1115,13 @@ TEST_STRIP = $(top_builddir)/../binutils/strip-new
# .o's), but not all of them (such as .so's and .err files). We
# improve on that here. automake-1.9 info docs say "mostlyclean" is
# the right choice for files 'make' builds that people rebuild.
-MOSTLYCLEANFILES = *.so $(am__append_16)
+MOSTLYCLEANFILES = *.so $(am__append_16) $(am__append_23)
# We will add to these later, for each individual test. Note
# that we add each test under check_SCRIPTS or check_PROGRAMS;
# the TESTS variable is automatically populated from these.
-check_SCRIPTS = $(am__append_6)
-check_DATA = $(am__append_7)
+check_SCRIPTS = $(am__append_6) $(am__append_21)
+check_DATA = $(am__append_7) $(am__append_22)
BUILT_SOURCES = $(am__append_14)
TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
@@ -1065,7 +1135,7 @@ DEPENDENCIES = \
libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL_DEP)
LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \
- $(THREADSLIB)
+ $(THREADSLIB) $(LIBDL)
object_unittest_SOURCES = object_unittest.cc
binary_unittest_SOURCES = binary_unittest.cc
@@ -1366,6 +1436,14 @@ binary_unittest_SOURCES = binary_unittest.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@binary_test_SOURCES = binary_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@binary_test_DEPENDENCIES = gcctestdir/ld binary.txt
@GCC_TRUE@@NATIVE_LINKER_TRUE@binary_test_LDFLAGS = -Bgcctestdir/ -Wl,--format,binary,binary.txt,--format,elf
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_SOURCES = thin_archive_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_DEPENDENCIES = gcctestdir/ld libthin1.a alt/libthin2.a
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_LDADD = libthin1.a -lthin2
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_SOURCES = thin_archive_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_DEPENDENCIES = gcctestdir/ld libthinall.a
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_LDFLAGS = -Bgcctestdir/ -L.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_LDADD = -lthinall
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -1515,6 +1593,24 @@ many_sections_test$(EXEEXT): $(many_sections_test_OBJECTS) $(many_sections_test_
object_unittest$(EXEEXT): $(object_unittest_OBJECTS) $(object_unittest_DEPENDENCIES)
@rm -f object_unittest$(EXEEXT)
$(CXXLINK) $(object_unittest_LDFLAGS) $(object_unittest_OBJECTS) $(object_unittest_LDADD) $(LIBS)
+@GCC_FALSE@plugin_test_1$(EXEEXT): $(plugin_test_1_OBJECTS) $(plugin_test_1_DEPENDENCIES)
+@GCC_FALSE@ @rm -f plugin_test_1$(EXEEXT)
+@GCC_FALSE@ $(LINK) $(plugin_test_1_LDFLAGS) $(plugin_test_1_OBJECTS) $(plugin_test_1_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@plugin_test_1$(EXEEXT): $(plugin_test_1_OBJECTS) $(plugin_test_1_DEPENDENCIES)
+@NATIVE_LINKER_FALSE@ @rm -f plugin_test_1$(EXEEXT)
+@NATIVE_LINKER_FALSE@ $(LINK) $(plugin_test_1_LDFLAGS) $(plugin_test_1_OBJECTS) $(plugin_test_1_LDADD) $(LIBS)
+@PLUGINS_FALSE@plugin_test_1$(EXEEXT): $(plugin_test_1_OBJECTS) $(plugin_test_1_DEPENDENCIES)
+@PLUGINS_FALSE@ @rm -f plugin_test_1$(EXEEXT)
+@PLUGINS_FALSE@ $(LINK) $(plugin_test_1_LDFLAGS) $(plugin_test_1_OBJECTS) $(plugin_test_1_LDADD) $(LIBS)
+@GCC_FALSE@plugin_test_2$(EXEEXT): $(plugin_test_2_OBJECTS) $(plugin_test_2_DEPENDENCIES)
+@GCC_FALSE@ @rm -f plugin_test_2$(EXEEXT)
+@GCC_FALSE@ $(LINK) $(plugin_test_2_LDFLAGS) $(plugin_test_2_OBJECTS) $(plugin_test_2_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@plugin_test_2$(EXEEXT): $(plugin_test_2_OBJECTS) $(plugin_test_2_DEPENDENCIES)
+@NATIVE_LINKER_FALSE@ @rm -f plugin_test_2$(EXEEXT)
+@NATIVE_LINKER_FALSE@ $(LINK) $(plugin_test_2_LDFLAGS) $(plugin_test_2_OBJECTS) $(plugin_test_2_LDADD) $(LIBS)
+@PLUGINS_FALSE@plugin_test_2$(EXEEXT): $(plugin_test_2_OBJECTS) $(plugin_test_2_DEPENDENCIES)
+@PLUGINS_FALSE@ @rm -f plugin_test_2$(EXEEXT)
+@PLUGINS_FALSE@ $(LINK) $(plugin_test_2_LDFLAGS) $(plugin_test_2_OBJECTS) $(plugin_test_2_LDADD) $(LIBS)
protected_1$(EXEEXT): $(protected_1_OBJECTS) $(protected_1_DEPENDENCIES)
@rm -f protected_1$(EXEEXT)
$(CXXLINK) $(protected_1_LDFLAGS) $(protected_1_OBJECTS) $(protected_1_LDADD) $(LIBS)
@@ -1539,6 +1635,12 @@ script_test_2$(EXEEXT): $(script_test_2_OBJECTS) $(script_test_2_DEPENDENCIES)
@NATIVE_LINKER_FALSE@script_test_3$(EXEEXT): $(script_test_3_OBJECTS) $(script_test_3_DEPENDENCIES)
@NATIVE_LINKER_FALSE@ @rm -f script_test_3$(EXEEXT)
@NATIVE_LINKER_FALSE@ $(LINK) $(script_test_3_LDFLAGS) $(script_test_3_OBJECTS) $(script_test_3_LDADD) $(LIBS)
+thin_archive_test_1$(EXEEXT): $(thin_archive_test_1_OBJECTS) $(thin_archive_test_1_DEPENDENCIES)
+ @rm -f thin_archive_test_1$(EXEEXT)
+ $(CXXLINK) $(thin_archive_test_1_LDFLAGS) $(thin_archive_test_1_OBJECTS) $(thin_archive_test_1_LDADD) $(LIBS)
+thin_archive_test_2$(EXEEXT): $(thin_archive_test_2_OBJECTS) $(thin_archive_test_2_DEPENDENCIES)
+ @rm -f thin_archive_test_2$(EXEEXT)
+ $(CXXLINK) $(thin_archive_test_2_LDFLAGS) $(thin_archive_test_2_OBJECTS) $(thin_archive_test_2_LDADD) $(LIBS)
tls_pic_test$(EXEEXT): $(tls_pic_test_OBJECTS) $(tls_pic_test_DEPENDENCIES)
@rm -f tls_pic_test$(EXEEXT)
$(CXXLINK) $(tls_pic_test_LDFLAGS) $(tls_pic_test_OBJECTS) $(tls_pic_test_LDADD) $(LIBS)
@@ -1692,6 +1794,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_r_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_3.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_main_1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_main_2.Po@am__quote@
@@ -1705,6 +1809,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testfile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testmain.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thin_archive_main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test_file2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test_main.Po@am__quote@
@@ -2125,7 +2230,7 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_c_pic.o: tls_test_c.c
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(COMPILE) -c -fpic $(TLS_TEST_C_CFLAGS) -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_shared.so: tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o gcctestdir/ld
-@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -Wl,-z,defs
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_shared2.so: tls_test_file2_pic.o gcctestdir/ld
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared tls_test_file2_pic.o
@@ -2313,6 +2418,50 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_4.t
@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_4.stdout: script_test_4
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
+
+@GCC_TRUE@@NATIVE_LINKER_TRUE@libthin1.a: thin_archive_test_1.o alt/thin_archive_test_2.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/libthin2.a: thin_archive_test_3.o alt/thin_archive_test_4.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@libthin3.a: thin_archive_test_1.o alt/thin_archive_test_4.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/libthin4.a: alt/thin_archive_test_2.o thin_archive_test_3.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@libthinall.a: libthin3.a alt/libthin4.a
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/thin_archive_test_2.o: thin_archive_test_2.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/thin_archive_test_4.o: thin_archive_test_4.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_1: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms gcctestdir/ld plugin_test.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so;_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms 2>plugin_test_1.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_1.err: plugin_test_1
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @touch plugin_test_1.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_2: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_shared_2.so gcctestdir/ld plugin_test.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,-R,.,--plugin,"./plugin_test.so" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_shared_2.so 2>plugin_test_2.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_2.err: plugin_test_2
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @touch plugin_test_2.err
+
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test.so: plugin_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(LINK) -Bgcctestdir/ -shared plugin_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test.o: plugin_test.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(COMPILE) -O0 -c -fpic -o $@ $<
+
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_main.syms: two_file_test_main.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_1.syms: two_file_test_1.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_1b.syms: two_file_test_1b.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_2.syms: two_file_test_2.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/gold/testsuite/plugin_test.c b/gold/testsuite/plugin_test.c
new file mode 100644
index 0000000..c60c7a1
--- /dev/null
+++ b/gold/testsuite/plugin_test.c
@@ -0,0 +1,427 @@
+/* test_plugin.c -- simple linker plugin test
+
+ Copyright 2008 Free Software Foundation, Inc.
+ Written by Cary Coutant <ccoutant@google.com>.
+
+ This file is part of gold.
+
+ 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. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "plugin-api.h"
+
+struct claimed_file
+{
+ const char* name;
+ void* handle;
+ int nsyms;
+ struct ld_plugin_symbol* syms;
+ struct claimed_file* next;
+};
+
+static struct claimed_file* first_claimed_file = NULL;
+static struct claimed_file* last_claimed_file = NULL;
+
+static ld_plugin_register_claim_file register_claim_file_hook = NULL;
+static ld_plugin_register_all_symbols_read register_all_symbols_read_hook = NULL;
+static ld_plugin_register_cleanup register_cleanup_hook = NULL;
+static ld_plugin_add_symbols add_symbols = NULL;
+static ld_plugin_get_symbols get_symbols = NULL;
+static ld_plugin_add_input_file add_input_file = NULL;
+static ld_plugin_message message = NULL;
+
+#define MAXOPTS 10
+
+static const char *opts[MAXOPTS];
+static int nopts = 0;
+
+enum ld_plugin_status onload(struct ld_plugin_tv *tv);
+enum ld_plugin_status claim_file_hook(const struct ld_plugin_input_file *file,
+ int *claimed);
+enum ld_plugin_status all_symbols_read_hook(void);
+enum ld_plugin_status cleanup_hook(void);
+
+enum ld_plugin_status
+onload(struct ld_plugin_tv *tv)
+{
+ struct ld_plugin_tv *entry;
+ int api_version = 0;
+ int gold_version = 0;
+ int i;
+
+ for (entry = tv; entry->tv_tag != LDPT_NULL; ++entry)
+ {
+ switch (entry->tv_tag)
+ {
+ case LDPT_API_VERSION:
+ api_version = entry->tv_u.tv_val;
+ break;
+ case LDPT_GOLD_VERSION:
+ gold_version = entry->tv_u.tv_val;
+ break;
+ case LDPT_LINKER_OUTPUT:
+ break;
+ case LDPT_OPTION:
+ if (nopts < MAXOPTS)
+ opts[nopts++] = entry->tv_u.tv_string;
+ break;
+ case LDPT_REGISTER_CLAIM_FILE_HOOK:
+ register_claim_file_hook = entry->tv_u.tv_register_claim_file;
+ break;
+ case LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK:
+ register_all_symbols_read_hook =
+ entry->tv_u.tv_register_all_symbols_read;
+ break;
+ case LDPT_REGISTER_CLEANUP_HOOK:
+ register_cleanup_hook = entry->tv_u.tv_register_cleanup;
+ break;
+ case LDPT_ADD_SYMBOLS:
+ add_symbols = entry->tv_u.tv_add_symbols;
+ break;
+ case LDPT_GET_SYMBOLS:
+ get_symbols = entry->tv_u.tv_get_symbols;
+ break;
+ case LDPT_ADD_INPUT_FILE:
+ add_input_file = entry->tv_u.tv_add_input_file;
+ break;
+ case LDPT_MESSAGE:
+ message = entry->tv_u.tv_message;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (message == NULL)
+ {
+ fprintf(stderr, "tv_message interface missing\n");
+ return LDPS_ERR;
+ }
+
+ if (register_claim_file_hook == NULL)
+ {
+ fprintf(stderr, "tv_register_claim_file_hook interface missing\n");
+ return LDPS_ERR;
+ }
+
+ if (register_all_symbols_read_hook == NULL)
+ {
+ fprintf(stderr, "tv_register_all_symbols_read_hook interface missing\n");
+ return LDPS_ERR;
+ }
+
+ if (register_cleanup_hook == NULL)
+ {
+ fprintf(stderr, "tv_register_cleanup_hook interface missing\n");
+ return LDPS_ERR;
+ }
+
+ (*message)(LDPL_INFO, "API version: %d", api_version);
+ (*message)(LDPL_INFO, "gold version: %d", gold_version);
+
+ for (i = 0; i < nopts; ++i)
+ (*message)(LDPL_INFO, "option: %s", opts[i]);
+
+ if ((*register_claim_file_hook)(claim_file_hook) != LDPS_OK)
+ {
+ (*message)(LDPL_ERROR, "error registering claim file hook");
+ return LDPS_ERR;
+ }
+
+ if ((*register_all_symbols_read_hook)(all_symbols_read_hook) != LDPS_OK)
+ {
+ (*message)(LDPL_ERROR, "error registering all symbols read hook");
+ return LDPS_ERR;
+ }
+
+ if ((*register_cleanup_hook)(cleanup_hook) != LDPS_OK)
+ {
+ (*message)(LDPL_ERROR, "error registering cleanup hook");
+ return LDPS_ERR;
+ }
+
+ return LDPS_OK;
+}
+
+enum ld_plugin_status
+claim_file_hook (const struct ld_plugin_input_file* file, int* claimed)
+{
+ int len;
+ char buf[160];
+ struct claimed_file* claimed_file;
+ struct ld_plugin_symbol* syms;
+ int nsyms = 0;
+ int maxsyms = 0;
+ FILE* irfile;
+ char *p;
+ char *pbind;
+ char *pvis;
+ char *psect;
+ int weak;
+ int def;
+ int vis;
+ int size;
+ char* name;
+ int is_comdat;
+ int i;
+
+ (*message)(LDPL_INFO,
+ "%s: claim file hook called (offset = %ld, size = %ld)",
+ file->name, (long)file->offset, (long)file->filesize);
+
+ /* Look for the beginning of output from readelf -s. */
+ irfile = fdopen(file->fd, "r");
+ (void)fseek(irfile, file->offset, SEEK_SET);
+ len = fread(buf, 1, 13, irfile);
+ if (len < 13 || strncmp(buf, "\nSymbol table", 13) != 0)
+ return LDPS_OK;
+
+ /* Skip the two header lines. */
+ (void) fgets(buf, sizeof(buf), irfile);
+ (void) fgets(buf, sizeof(buf), irfile);
+
+ if (add_symbols == NULL)
+ {
+ fprintf(stderr, "tv_add_symbols interface missing\n");
+ return LDPS_ERR;
+ }
+
+ /* Parse the output from readelf. The columns are:
+ Index Value Size Type Binding Visibility Section Name. */
+ syms = (struct ld_plugin_symbol*)malloc(sizeof(struct ld_plugin_symbol) * 8);
+ if (syms == NULL)
+ return LDPS_ERR;
+ maxsyms = 8;
+ while (fgets(buf, sizeof(buf), irfile) != NULL)
+ {
+ p = buf;
+ p += strspn(p, " ");
+
+ /* Index field. */
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Value field. */
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Size field. */
+ size = atoi(p);
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Type field. */
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Binding field. */
+ pbind = p;
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Visibility field. */
+ pvis = p;
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Section field. */
+ psect = p;
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Name field. */
+ /* FIXME: Look for version. */
+ len = strlen(p);
+ if (p[len-1] == '\n')
+ p[--len] = '\0';
+ name = malloc(len + 1);
+ strncpy(name, p, len + 1);
+
+ /* Ignore local symbols. */
+ if (strncmp(pbind, "LOCAL", 5) == 0)
+ continue;
+
+ weak = strncmp(pbind, "WEAK", 4) == 0;
+ if (strncmp(psect, "UND", 3) == 0)
+ def = weak ? LDPK_WEAKUNDEF : LDPK_UNDEF;
+ else if (strncmp(psect, "COM", 3) == 0)
+ def = LDPK_COMMON;
+ else
+ def = weak ? LDPK_WEAKDEF : LDPK_DEF;
+
+ if (strncmp(pvis, "INTERNAL", 8) == 0)
+ vis = LDPV_INTERNAL;
+ else if (strncmp(pvis, "HIDDEN", 6) == 0)
+ vis = LDPV_HIDDEN;
+ else if (strncmp(pvis, "PROTECTED", 9) == 0)
+ vis = LDPV_PROTECTED;
+ else
+ vis = LDPV_DEFAULT;
+
+ /* If the symbol is listed in the options list, special-case
+ it as a comdat symbol. */
+ is_comdat = 0;
+ for (i = 0; i < nopts; ++i)
+ {
+ if (name != NULL && strcmp(name, opts[i]) == 0)
+ {
+ is_comdat = 1;
+ break;
+ }
+ }
+
+ if (nsyms >= maxsyms)
+ {
+ syms = (struct ld_plugin_symbol*)
+ realloc(syms, sizeof(struct ld_plugin_symbol) * maxsyms * 2);
+ if (syms == NULL)
+ return LDPS_ERR;
+ maxsyms *= 2;
+ }
+
+ syms[nsyms].name = name;
+ syms[nsyms].version = NULL;
+ syms[nsyms].def = def;
+ syms[nsyms].visibility = vis;
+ syms[nsyms].size = size;
+ syms[nsyms].comdat_key = is_comdat ? name : NULL;
+ syms[nsyms].resolution = LDPR_UNKNOWN;
+ ++nsyms;
+ }
+
+ claimed_file = (struct claimed_file*) malloc(sizeof(struct claimed_file));
+ if (claimed_file == NULL)
+ return LDPS_ERR;
+
+ claimed_file->name = file->name;
+ claimed_file->handle = file->handle;
+ claimed_file->nsyms = nsyms;
+ claimed_file->syms = syms;
+ claimed_file->next = NULL;
+ if (last_claimed_file == NULL)
+ first_claimed_file = claimed_file;
+ else
+ last_claimed_file->next = claimed_file;
+ last_claimed_file = claimed_file;
+
+ (*add_symbols)(file->handle, nsyms, syms);
+
+ *claimed = 1;
+ return LDPS_OK;
+}
+
+enum ld_plugin_status
+all_symbols_read_hook(void)
+{
+ int i;
+ const char* res;
+ struct claimed_file* claimed_file;
+ char buf[160];
+ char *p;
+
+ (*message)(LDPL_INFO, "all symbols read hook called");
+
+ if (get_symbols == NULL)
+ {
+ fprintf(stderr, "tv_get_symbols interface missing\n");
+ return LDPS_ERR;
+ }
+
+ for (claimed_file = first_claimed_file;
+ claimed_file != NULL;
+ claimed_file = claimed_file->next)
+ {
+ (*get_symbols)(claimed_file->handle, claimed_file->nsyms,
+ claimed_file->syms);
+ for (i = 0; i < claimed_file->nsyms; ++i)
+ {
+ switch (claimed_file->syms[i].resolution)
+ {
+ case LDPR_UNKNOWN:
+ res = "UNKNOWN";
+ break;
+ case LDPR_UNDEF:
+ res = "UNDEF";
+ break;
+ case LDPR_PREVAILING_DEF:
+ res = "PREVAILING_DEF_REG";
+ break;
+ case LDPR_PREVAILING_DEF_IRONLY:
+ res = "PREVAILING_DEF_IRONLY";
+ break;
+ case LDPR_PREEMPTED_REG:
+ res = "PREEMPTED_REG";
+ break;
+ case LDPR_PREEMPTED_IR:
+ res = "PREEMPTED_IR";
+ break;
+ case LDPR_RESOLVED_IR:
+ res = "RESOLVED_IR";
+ break;
+ case LDPR_RESOLVED_EXEC:
+ res = "RESOLVED_EXEC";
+ break;
+ case LDPR_RESOLVED_DYN:
+ res = "RESOLVED_DYN";
+ break;
+ default:
+ res = "?";
+ break;
+ }
+ (*message)(LDPL_INFO, "%s: %s: %s", claimed_file->name,
+ claimed_file->syms[i].name, res);
+ }
+ }
+
+ if (add_input_file == NULL)
+ {
+ fprintf(stderr, "tv_add_input_file interface missing\n");
+ return LDPS_ERR;
+ }
+
+ for (claimed_file = first_claimed_file;
+ claimed_file != NULL;
+ claimed_file = claimed_file->next)
+ {
+ if (strlen(claimed_file->name) >= sizeof(buf))
+ {
+ (*message)(LDPL_FATAL, "%s: filename too long", claimed_file->name);
+ return LDPS_ERR;
+ }
+ strcpy(buf, claimed_file->name);
+ p = strrchr(buf, '.');
+ if (p == NULL || strcmp(p, ".syms") != 0)
+ {
+ (*message)(LDPL_FATAL, "%s: filename must have '.syms' suffix",
+ claimed_file->name);
+ return LDPS_ERR;
+ }
+ p[1] = 'o';
+ p[2] = '\0';
+ (*add_input_file)(buf);
+ }
+
+ return LDPS_OK;
+}
+
+enum ld_plugin_status
+cleanup_hook(void)
+{
+ (*message)(LDPL_INFO, "cleanup hook called");
+ return LDPS_OK;
+}
diff --git a/gold/testsuite/plugin_test_1.sh b/gold/testsuite/plugin_test_1.sh
new file mode 100755
index 0000000..5e16139
--- /dev/null
+++ b/gold/testsuite/plugin_test_1.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# plugin_test_1.sh -- a test case for the plugin API.
+
+# Copyright 2008 Free Software Foundation, Inc.
+# Written by Cary Coutant <ccoutant@google.com>.
+
+# This file is part of gold.
+
+# 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.
+
+# This file goes with plugin_test_1.c, a simple plug-in library that
+# exercises the basic interfaces and prints out version numbers and
+# options passed to the plugin.
+
+check()
+{
+ if ! grep -q "$2" "$1"
+ then
+ echo "Did not find expected output in $1:"
+ echo " $2"
+ echo ""
+ echo "Actual output below:"
+ cat "$1"
+ exit 1
+ fi
+}
+
+check plugin_test_1.err "API version:"
+check plugin_test_1.err "gold version:"
+check plugin_test_1.err "option: _Z4f13iv"
+check plugin_test_1.err "two_file_test_main.o: claim file hook called"
+check plugin_test_1.err "two_file_test_1.syms: claim file hook called"
+check plugin_test_1.err "two_file_test_1b.syms: claim file hook called"
+check plugin_test_1.err "two_file_test_2.syms: claim file hook called"
+check plugin_test_1.err "two_file_test_1.syms: _Z4f13iv: PREVAILING_DEF_IRONLY"
+check plugin_test_1.err "two_file_test_1.syms: _Z2t2v: PREVAILING_DEF_REG"
+check plugin_test_1.err "two_file_test_1.syms: v2: RESOLVED_IR"
+check plugin_test_1.err "two_file_test_1.syms: t17data: RESOLVED_IR"
+check plugin_test_1.err "two_file_test_2.syms: _Z4f13iv: PREEMPTED_IR"
+check plugin_test_1.err "cleanup hook called"
+
+exit 0
diff --git a/gold/testsuite/plugin_test_2.sh b/gold/testsuite/plugin_test_2.sh
new file mode 100755
index 0000000..41865ac
--- /dev/null
+++ b/gold/testsuite/plugin_test_2.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# plugin_test_2.sh -- a test case for the plugin API.
+
+# Copyright 2008 Free Software Foundation, Inc.
+# Written by Cary Coutant <ccoutant@google.com>.
+
+# This file is part of gold.
+
+# 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.
+
+# This file goes with plugin_test_1.c, a simple plug-in library that
+# exercises the basic interfaces and prints out version numbers and
+# options passed to the plugin.
+
+check()
+{
+ if ! grep -q "$2" "$1"
+ then
+ echo "Did not find expected output in $1:"
+ echo " $2"
+ echo ""
+ echo "Actual output below:"
+ cat "$1"
+ exit 1
+ fi
+}
+
+check plugin_test_2.err "API version:"
+check plugin_test_2.err "gold version:"
+check plugin_test_2.err "two_file_test_main.o: claim file hook called"
+check plugin_test_2.err "two_file_test_1.syms: claim file hook called"
+check plugin_test_2.err "two_file_test_1b.syms: claim file hook called"
+check plugin_test_2.err "two_file_shared_2.so: claim file hook called"
+check plugin_test_2.err "two_file_test_1.syms: _Z4f13iv: PREVAILING_DEF_REG"
+check plugin_test_2.err "two_file_test_1.syms: _Z2t2v: PREVAILING_DEF_REG"
+check plugin_test_2.err "two_file_test_1.syms: v2: RESOLVED_DYN"
+check plugin_test_2.err "two_file_test_1.syms: t17data: RESOLVED_DYN"
+check plugin_test_2.err "cleanup hook called"
+
+exit 0
diff --git a/gold/testsuite/thin_archive_main.cc b/gold/testsuite/thin_archive_main.cc
new file mode 100644
index 0000000..6c38715
--- /dev/null
+++ b/gold/testsuite/thin_archive_main.cc
@@ -0,0 +1,39 @@
+// thin_archive_main.cc -- a test case for gold
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// 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.
+
+// This is the main program for the thin archive tests. It calls a single
+// routine, t1, defined in libthin1.a or libthin3.a, which then references
+// other routines in the same and other libraries, to make sure that all
+// archive members are linked properly.
+
+#include <cassert>
+
+extern int t1();
+
+// Main function. Call the test function.
+
+int
+main()
+{
+ assert(t1() == 0x4321);
+ return 0;
+}
diff --git a/gold/testsuite/thin_archive_test_1.cc b/gold/testsuite/thin_archive_test_1.cc
new file mode 100644
index 0000000..db23937
--- /dev/null
+++ b/gold/testsuite/thin_archive_test_1.cc
@@ -0,0 +1,37 @@
+// thin_archive_test_1.cc -- part of a test case for thin archives
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// 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.
+
+// This tests references between files and archives. This is file 1 of 4.
+// Each of the first three files contains a reference to the next.
+// We test the archives as follows:
+
+// Files 1 and 2 in libthin1.a, files 3 and 4 in libthin2.a.
+// Files 1 and 4 in libthin3.a, files 2 and 3 in libthin4.a, with
+// libthin3.a and libthin4.a nested inside libthinall.a.
+
+extern int t2();
+
+int
+t1()
+{
+ return (t2() << 4) | 1;
+}
diff --git a/gold/testsuite/thin_archive_test_2.cc b/gold/testsuite/thin_archive_test_2.cc
new file mode 100644
index 0000000..2c1ee31
--- /dev/null
+++ b/gold/testsuite/thin_archive_test_2.cc
@@ -0,0 +1,37 @@
+// thin_archive_test_2.cc -- part of a test case for thin archives
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// 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.
+
+// This tests references between files and archives. This is file 2 of 4.
+// Each of the first three files contains a reference to the next.
+// We test the archives as follows:
+
+// Files 1 and 2 in libthin1.a, files 3 and 4 in libthin2.a.
+// Files 1 and 4 in libthin3.a, files 2 and 3 in libthin4.a, with
+// libthin3.a and libthin4.a nested inside libthinall.a.
+
+extern int t3();
+
+int
+t2()
+{
+ return (t3() << 4) | 2;
+}
diff --git a/gold/testsuite/thin_archive_test_3.cc b/gold/testsuite/thin_archive_test_3.cc
new file mode 100644
index 0000000..b58c59f
--- /dev/null
+++ b/gold/testsuite/thin_archive_test_3.cc
@@ -0,0 +1,37 @@
+// thin_archive_test_3.cc -- part of a test case for thin archives
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// 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.
+
+// This tests references between files and archives. This is file 3 of 4.
+// Each of the first three files contains a reference to the next.
+// We test the archives as follows:
+
+// Files 1 and 2 in libthin1.a, files 3 and 4 in libthin2.a.
+// Files 1 and 4 in libthin3.a, files 2 and 3 in libthin4.a, with
+// libthin3.a and libthin4.a nested inside libthinall.a.
+
+extern int t4();
+
+int
+t3()
+{
+ return (t4() << 4) | 3;
+}
diff --git a/gold/testsuite/thin_archive_test_4.cc b/gold/testsuite/thin_archive_test_4.cc
new file mode 100644
index 0000000..1b67c94
--- /dev/null
+++ b/gold/testsuite/thin_archive_test_4.cc
@@ -0,0 +1,35 @@
+// thin_archive_test_4.cc -- part of a test case for thin archives
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@google.com>.
+
+// This file is part of gold.
+
+// 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.
+
+// This tests references between files and archives. This is file 4 of 4.
+// Each of the first three files contains a reference to the next.
+// We test the archives as follows:
+
+// Files 1 and 2 in libthin1.a, files 3 and 4 in libthin2.a.
+// Files 1 and 4 in libthin3.a, files 2 and 3 in libthin4.a, with
+// libthin3.a and libthin4.a nested inside libthinall.a.
+
+int
+t4()
+{
+ return 4;
+}
diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index 2daa9bf..69f76a0 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -139,7 +139,7 @@ class Target_x86_64 : public Sized_target<64, false>
// Return whether SYM is defined by the ABI.
bool
- do_is_defined_by_abi(Symbol* sym) const
+ do_is_defined_by_abi(const Symbol* sym) const
{ return strcmp(sym->name(), "__tls_get_addr") == 0; }
// Return the size of the GOT section.
@@ -330,7 +330,7 @@ class Target_x86_64 : public Sized_target<64, false>
void
make_plt_entry(Symbol_table*, Layout*, Symbol*);
- // Define the _TLS_MODULE_BASE_ symbol at the end of the TLS segment.
+ // Define the _TLS_MODULE_BASE_ symbol in the TLS segment.
void
define_tls_base_symbol(Symbol_table*, Layout*);
@@ -796,7 +796,7 @@ Target_x86_64::make_plt_entry(Symbol_table* symtab, Layout* layout,
this->plt_->add_entry(gsym);
}
-// Define the _TLS_MODULE_BASE_ symbol at the end of the TLS segment.
+// Define the _TLS_MODULE_BASE_ symbol in the TLS segment.
void
Target_x86_64::define_tls_base_symbol(Symbol_table* symtab, Layout* layout)
@@ -807,12 +807,16 @@ Target_x86_64::define_tls_base_symbol(Symbol_table* symtab, Layout* layout)
Output_segment* tls_segment = layout->tls_segment();
if (tls_segment != NULL)
{
+ bool is_exec = parameters->options().output_is_executable();
symtab->define_in_output_segment("_TLS_MODULE_BASE_", NULL,
tls_segment, 0, 0,
elfcpp::STT_TLS,
elfcpp::STB_LOCAL,
elfcpp::STV_HIDDEN, 0,
- Symbol::SEGMENT_END, true);
+ (is_exec
+ ? Symbol::SEGMENT_END
+ : Symbol::SEGMENT_START),
+ true);
}
this->tls_base_symbol_defined_ = true;
}