diff options
author | Thomas Preud'homme <thomas.preudhomme@arm.com> | 2016-07-15 17:49:08 +0100 |
---|---|---|
committer | Thomas Preud'homme <thomas.preudhomme@arm.com> | 2016-07-15 17:50:48 +0100 |
commit | 76359541825cf36ecd14ab6b5974ee56e1c59eff (patch) | |
tree | 2043ac1a958572f267df5fabf168bca70300900b /ld/testsuite | |
parent | bc7b765ab71f967eb2a9c3da111d7529eec46fbe (diff) | |
download | gdb-76359541825cf36ecd14ab6b5974ee56e1c59eff.zip gdb-76359541825cf36ecd14ab6b5974ee56e1c59eff.tar.gz gdb-76359541825cf36ecd14ab6b5974ee56e1c59eff.tar.bz2 |
Add support for creating ELF import libraries
2016-07-15 Thomas Preud'homme <thomas.preudhomme@arm.com>
bfd/
* elf-bfd.h (elf_backend_filter_implib_symbols): Declare backend hook.
(_bfd_elf_filter_global_symbols): Declare.
* elf.c (_bfd_elf_filter_global_symbols): New function.
* elflink.c (elf_filter_global_symbols): Likewise.
(elf_output_implib): Likewise.
(bfd_elf_final_link): Call above function, failing if it does.
* elfxx-target.h (elf_backend_filter_implib_symbols): Define macro and
default it to NULL.
(elf_backend_copy_indirect_symbol): Fix spacing.
(elf_backend_hide_symbol): Likewise.
(elfNN_bed): Initialize elf_backend_filter_implib_symbols backend hook.
include/
* bfdlink.h (struct bfd_link_info): Declare new ldscript_def and
out_implib_bfd fields.
2016-07-15 Thomas Preud'homme <thomas.preudhomme@arm.com>
Nick Clifton <nickc@redhat.com>
ld/
* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Open import
library file for writing and initialize implib_bfd field of link_info
structure.
* emultempl/pe.em (pe_implib_filename): Remove variable declaration.
(OPTION_IMPLIB_FILENAME): Remove macro definition.
(gld${EMULATION_NAME}_add_options): Remove --out-implib option.
(gld_${EMULATION_NAME}_list_options): Likewise.
(gld${EMULATION_NAME}_handle_option): Likewise.
(gld_${EMULATION_NAME}_finish): Use command_line.out_implib_filename
instead of pe_implib_filename.
* emultempl/pep.em (pep_implib_filename): Remove variable declaration.
(OPTION_IMPLIB_FILENAME): Remove enumerator.
(gld${EMULATION_NAME}_add_options): Remove --out-implib option.
(gld_${EMULATION_NAME}_list_options): Likewise.
(gld${EMULATION_NAME}_handle_option): Likewise.
(gld_${EMULATION_NAME}_finish): Use command_line.out_implib_filename
instead of pep_implib_filename.
* ld.h (args_type): Declare new out_implib_filename field.
* ld.texinfo (--out-implib): Move documentation to arch-independent
part and rephrase to apply to ELF targets.
* ldexp.c (exp_fold_tree_1): Set ldscript_def field to 1 for symbols
defined in linker scripts.
* ldlex.h (enum option_values): Declare new OPTION_OUT_IMPLIB
enumerator.
* lexsup.c (ld_options): Add entry for new --out-implib switch.
(parse_args): Handle OPTION_OUT_IMPLIB case.
* testsuite/ld-elf/elf.exp (Generate empty import library): New test.
(Generate import library): Likewise.
* testsuite/ld-elf/implib.s: Likewise.
* testsuite/ld-elf/implib.rd: New file.
* testsuite/ld-elf/empty-implib.out: Likewise
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-elf/elf.exp | 16 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/empty-implib.out | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/implib.rd | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/implib.s | 22 |
4 files changed, 51 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index 2dfd0e8..832f313 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -136,6 +136,22 @@ foreach t $test_list { run_dump_test [file rootname $t] } +# Check that the --out-implib option work correctly. +run_ld_link_tests { + {"Generate empty import library" + "--out-implib=tmpdir/implib.lib" "" + "--defsym NO_GLOBAL=1" + {implib.s} + {{ld empty-implib.out}} + "implib"} + {"Generate import library" + "-Tdata=0x1000 --out-implib=tmpdir/implib.lib" "" + "" + {implib.s} + {{readelf {-s tmpdir/implib.lib} implib.rd}} + "implib"} +} + if { [istarget *-*-linux*] || [istarget *-*-nacl*] || [istarget *-*-gnu*] } { diff --git a/ld/testsuite/ld-elf/empty-implib.out b/ld/testsuite/ld-elf/empty-implib.out new file mode 100644 index 0000000..b123064 --- /dev/null +++ b/ld/testsuite/ld-elf/empty-implib.out @@ -0,0 +1,2 @@ +.*: .*: no symbol found for import library +.*: .*: failed to generate import library diff --git a/ld/testsuite/ld-elf/implib.rd b/ld/testsuite/ld-elf/implib.rd new file mode 100644 index 0000000..9f854a5 --- /dev/null +++ b/ld/testsuite/ld-elf/implib.rd @@ -0,0 +1,11 @@ +File: tmpdir/implib.lib + +Symbol table '.symtab' contains 3 entries: + Num: Value +Size Type Bind Vis Ndx Name + 0: [0-9a-f]+ 0 NOTYPE LOCAL DEFAULT UND + 1: 0+100[0-3] 1 OBJECT GLOBAL DEFAULT ABS exported1 + 2: 0+100[0-3] 1 OBJECT GLOBAL DEFAULT ABS exported2 + +File: tmpdir/implib + +#... diff --git a/ld/testsuite/ld-elf/implib.s b/ld/testsuite/ld-elf/implib.s new file mode 100644 index 0000000..a86a940 --- /dev/null +++ b/ld/testsuite/ld-elf/implib.s @@ -0,0 +1,22 @@ +.ifndef NO_GLOBAL + .bss + .comm exported1,1 + + .data + .global exported2 + .type exported2, %object + .size exported2, 1 +exported2: + .byte 21 +.endif + + .bss +not_exported1: + .space 1 + .size not_exported1, 1 + + .data + .type not_exported2, %object + .size not_exported2, 1 +not_exported2: + .byte 42 |