aboutsummaryrefslogtreecommitdiff
path: root/ld/lexsup.c
AgeCommit message (Collapse)AuthorFilesLines
2017-08-11Add -z globalaudit linker command line option to set the DF_GLOBALAUDIT flag ↵Nick Clifton1-0/+2
bit in the dynamic tags. * emultempl/elf32.em (handle_option): Accept the -z globalaudit command line option. * lexsup.c (elf_static_list_options): Add -z globalaudit. * ld.texinfo: Document the support for the new command line option. * NEWS: Mention the new feature. * testsuite/ld-elf/audit.exp: Add a test of the -z globalaudit command line option. * testsuite/ld-elf/globalaudit.rd: New file: Expected output from readelf.
2017-08-06Treat common symbol as undefined for --no-define-commonH.J. Lu1-1/+1
When --no-define-common is used to build shared library, treat common symbol as undefined so that common symbols that are referenced from a shared library to be assigned addresses only in the main program. This eliminates the unused duplicate space in the shared library, and also prevents any possible confusion over resolving to the wrong duplicate when there are many dynamic modules with specialized search paths for runtime symbol resolution. --no-define-common is only allowed when building a shared library. bfd/ PR ld/21903: * elflink.c (elf_link_add_object_symbols): Treat common symbol as undefined for --no-define-common. include/ PR ld/21903: * bfdlink.h (bfd_link_info): Add inhibit_common_definition. ld/ PR ld/21903: * ld.h (command_line): Remove inhibit_common_definition. * ldgram.y: Replace command_line.inhibit_common_definition with link_info.inhibit_common_definition. * ldlang.c (lang_common): Likewise. * lexsup.c (parse_args): Likewise. * ldmain.c (main): Only allow --no-define-common with -shared. * testsuite/ld-elf/pr21903.s: New file. * testsuite/ld-elf/pr21903a.d: Likewise. * testsuite/ld-elf/pr21903b.d: Likewise. * testsuite/ld-elf/pr21903c.d: Likewise. * testsuite/ld-elf/pr21903d.d: Likewise. * testsuite/ld-elf/pr21903e.d: Likewise.
2017-06-15Correct "ld --help" to display "-z stack-size=SIZE"H.J. Lu1-1/+1
ELF Linker command line option to set stack size is "-z stack-size=SIZE", not "-z stacksize=SIZE". * exsup.c (elf_shlib_list_options): Display "-z stack-size=SIZE" instead of "-z stacksize=SIZE".
2017-06-06ld: Allow section groups to be resolved as part of a relocatable linkAndrew Burgess1-0/+6
This commit adds a new linker feature: the ability to resolve section groups as part of a relocatable link. Currently section groups are automatically resolved when performing a final link, and are carried through when performing a relocatable link. By carried through this means that one copy of each section group (from all the copies that might be found in all the input files) is placed into the output file. Sections that are part of a section group will not match input section specifiers within a linker script and are forcibly kept as separate sections. There is a slight resemblance between section groups and common section. Like section groups, common sections are carried through when performing a relocatable link, and resolved (allocated actual space) only at final link time. However, with common sections there is an ability to force the linker to allocate space for the common sections when performing a relocatable link, there's currently no such ability for section groups. This commit adds such a mechanism. This new facility can be accessed in two ways, first there's a command line switch --force-group-allocation, second, there's a new linker script command FORCE_GROUP_ALLOCATION. If one of these is used when performing a relocatable link then the linker will resolve the section groups as though it were performing a final link, the section group will be deleted, and the members of the group will be placed like normal input sections. If there are multiple copies of the group (from multiple input files) then only one copy of the group members will be placed, the duplicate copies will be discarded. Unlike common sections that have the --no-define-common command line flag, and INHIBIT_COMMON_ALLOCATION linker script command there is no way to prevent group resolution during a final link, this is because the ELF gABI specifically prohibits the presence of SHT_GROUP sections in a fully linked executable. However, the code as written should make adding such a feature trivial, setting the new resolve_section_groups flag to false during a final link should work as you'd expect. bfd/ChangeLog: * elf.c (_bfd_elf_make_section_from_shdr): Don't initially mark SEC_GROUP sections as SEC_EXCLUDE. (bfd_elf_set_group_contents): Replace use of abort with an assert. (assign_section_numbers): Use resolve_section_groups flag instead of relocatable link type. (_bfd_elf_init_private_section_data): Use resolve_section_groups flag instead of checking the final_link flag for part of the checks in here. Fix white space as a result. * elflink.c (elf_link_input_bfd): Use resolve_section_groups flag instead of relocatable link type. (bfd_elf_final_link): Likewise. include/ChangeLog: * bfdlink.h (struct bfd_link_info): Add new resolve_section_groups flag. ld/ChangeLog: * ld.h (struct args_type): Add force_group_allocation field. * ldgram.y: Add support for FORCE_GROUP_ALLOCATION. * ldlex.h: Likewise. * ldlex.l: Likewise. * lexsup.c: Likewise. * ldlang.c (unique_section_p): Check resolve_section_groups flag not the relaxable link flag. (lang_add_section): Discard section groups when we're resolving groups. Clear the SEC_LINK_ONCE flag if we're resolving section groups. * ldmain.c (main): Initialise resolve_section_groups flag in link_info based on command line flags. * testsuite/ld-elf/group11.d: New file. * testsuite/ld-elf/group12.d: New file. * testsuite/ld-elf/group12.ld: New file. * NEWS: Mention new features. * ld.texinfo (Options): Document --force-group-allocation. (Miscellaneous Commands): Document FORCE_GROUP_ALLOCATION.
2017-01-02Update year range in copyright notice of all files.Alan Modra1-1/+1
2016-12-16Implement and document --gc-keep-exportedfincs1-0/+6
include/ * bfdlink.h (struct bfd_link_info): Add gc_keep_exported. bfd/ * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Add handling for info->gc_keep_exported. (bfd_elf_gc_sections): Likewise. ld/ * ld.texinfo: Document --gc-keep-exported. * ldlex.h (enum option_values): Add OPTION_GC_KEEP_EXPORTED. * lexsup.c (parse_args): Add handling for --gc-keep-exported.
2016-11-14 lexsup.c (parse_args): Add break at end of default case.Nick Clifton1-0/+1
2016-10-06-Wimplicit-fallthrough warning fixesAlan Modra1-1/+2
Comment changes. bfd/ * coff-h8300.c: Spell fall through comments consistently. * coffgen.c: Likewise. * elf32-hppa.c: Likewise. * elf32-ppc.c: Likewise. * elf32-score.c: Likewise. * elf32-score7.c: Likewise. * elf64-ppc.c: Likewise. * elfxx-aarch64.c: Likewise. * elfxx-mips.c: Likewise. * cpu-ns32k.c: Add missing fall through comments. * elf-m10300.c: Likewise. * elf32-arm.c: Likewise. * elf32-avr.c: Likewise. * elf32-bfin.c: Likewise. * elf32-frv.c: Likewise. * elf32-i386.c: Likewise. * elf32-microblaze.c: Likewise. * elf32-nds32.c: Likewise. * elf32-ppc.c: Likewise. * elf32-rl78.c: Likewise. * elf32-rx.c: Likewise. * elf32-s390.c: Likewise. * elf32-sh.c: Likewise. * elf32-tic6x.c: Likewise. * elf64-ia64-vms.c: Likewise. * elf64-ppc.c: Likewise. * elf64-s390.c: Likewise. * elf64-x86-64.c: Likewise. * elflink.c: Likewise. * elfnn-aarch64.c: Likewise. * elfnn-ia64.c: Likewise. * ieee.c: Likewise. * oasys.c: Likewise. * pdp11.c: Likewise. * srec.c: Likewise. * versados.c: Likewise. opcodes/ * aarch64-opc.c: Spell fall through comments consistently. * i386-dis.c: Likewise. * aarch64-dis.c: Add missing fall through comments. * aarch64-opc.c: Likewise. * arc-dis.c: Likewise. * arm-dis.c: Likewise. * i386-dis.c: Likewise. * m68k-dis.c: Likewise. * mep-asm.c: Likewise. * ns32k-dis.c: Likewise. * sh-dis.c: Likewise. * tic4x-dis.c: Likewise. * tic6x-dis.c: Likewise. * vax-dis.c: Likewise. binutils/ * dlltool.c: Spell fall through comments consistently. * objcopy.c: Likewise. * readelf.c: Likewise. * dwarf.c: Add missing fall through comments. * elfcomm.c: Likewise. * sysinfo.y: Likewise. * readelf.c: Likewise. Also remove extraneous comments. gas/ * app.c: Add missing fall through comments. * dw2gencfi.c: Likewise. * expr.c: Likewise. * config/tc-alpha.c: Likewise. * config/tc-arc.c: Likewise. * config/tc-arm.c: Likewise. * config/tc-cr16.c: Likewise. * config/tc-crx.c: Likewise. * config/tc-dlx.c: Likewise. * config/tc-h8300.c: Likewise. * config/tc-hppa.c: Likewise. * config/tc-i370.c: Likewise. * config/tc-i386.c: Likewise. * config/tc-i960.c: Likewise. * config/tc-ia64.c: Likewise. * config/tc-m68hc11.c: Likewise. * config/tc-m68k.c: Likewise. * config/tc-mep.c: Likewise. * config/tc-metag.c: Likewise. * config/tc-microblaze.c: Likewise. * config/tc-mips.c: Likewise. * config/tc-ns32k.c: Likewise. * config/tc-rx.c: Likewise. * config/tc-score.c: Likewise. * config/tc-score7.c: Likewise. * config/tc-sh.c: Likewise. * config/tc-tic4x.c: Likewise. * config/tc-vax.c: Likewise. * config/tc-xstormy16.c: Likewise. * config/tc-z80.c: Likewise. * config/tc-z8k.c: Likewise. * config/obj-elf.c: Likewise. * config/tc-i386.c: Likewise. * depend.c: Spell fall through comments consistently. * config/tc-arm.c: Likewise. * config/tc-d10v.c: Likewise. * config/tc-i960.c: Likewise. * config/tc-ia64.c: Likewise. * config/tc-m68k.c: Likewise. * config/tc-mcore.c: Likewise. * config/tc-mep.c: Likewise. * config/tc-ns32k.c: Likewise. * config/tc-visium.c: Likewise. * config/tc-xstormy16.c: Likewise. * config/tc-z8k.c: Likewise. gprof/ * gprof.c: Add missing fall through comments. ld/ * lexsup.c: Spell fall through comments consistently and add missing fall through comments.
2016-09-14Add support for disabling automatic generation of .eh_frame_hdr sections in ↵Nick Clifton1-0/+2
ELF based linkers. PR ld/20537 * emultempl/elf32.em: More OPTION_xxx values into an enum. Add OPTION_NO_EH_FRAME_HDR. (_add_options): Add support for --no-eh-frame-hdr. * ld.texinfo: Document new option. * lexsup.c (elf_shlib_list_options): List new option. * NEWS: Mention the new option.
2016-07-15Add support for creating ELF import librariesThomas Preud'homme1-0/+5
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
2016-06-27Allow a second -T<section>=<addr> to override a previous version on the same ↵Nick Clifton1-0/+1
linker command line. PR ld/20302 * lexsup.c (set_segment_start): If resetting the start address of a section, remember to generate a new script element as well. * testsuite/ld-scripts/pr20302.d: New test. * testsuite/ld-scripts/scripts.exp: Run the new test.
2016-06-24Check DEFAULT_LD_Z_RELRO for -z relro help messageH.J. Lu1-1/+8
* lexsup.c (elf_shlib_list_options): Check DEFAULT_LD_Z_RELRO for -z relro help message.
2016-02-26Properly implement STT_COMMONH.J. Lu1-0/+4
The BFD configure option, --enable-elf-stt-common, can't be to used to verify STT_COMMON implementation with the normal binutils build. Instead, this patch removes it from BFD. It adds --elf-stt-common=[no|yes] to ELF assembler/objcopy and adds -z common/-z nocommon to ld. A configure option, --enable-elf-stt-common, is added to gas to specify whether ELF assembler should generate common symbols with the STT_COMMON type by default. Since BSF_KEEP_G is never used, it is renamed to BSF_ELF_COMMON for ELF common symbols. bfd/ PR ld/19645 * bfd.c (bfd): Change flags to 20 bits. (BFD_CONVERT_ELF_COMMON): New. (BFD_USE_ELF_STT_COMMON): Likewise. (BFD_FLAGS_SAVED): Add BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON. (BFD_FLAGS_FOR_BFD_USE_MASK): Likewise. * configure.ac: Remove --enable-elf-stt-common. * elf.c (swap_out_syms): Choose STT_COMMON or STT_OBJECT for common symbol depending on BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON. * elfcode.h (elf_slurp_symbol_table): Set BSF_ELF_COMMON for STT_COMMON. * elflink.c (bfd_elf_link_mark_dynamic_symbol): Also check STT_COMMON. (elf_link_convert_common_type): New function. (elf_link_output_extsym): Choose STT_COMMON or STT_OBJECT for common symbol depending on BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON. Set sym.st_info after sym.st_shndx. * elfxx-target.h (TARGET_BIG_SYM): Add BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON to object_flags. (TARGET_LITTLE_SYM): Likewise. * syms.c (BSF_KEEP_G): Renamed to ... (BSF_ELF_COMMON): This. * bfd-in2.h: Regenerated. * config.in: Likewise. * configure: Likewise. binutils/ PR ld/19645 * NEWS: Mention --elf-stt-common= for objcopy. * doc/binutils.texi: Document --elf-stt-common= for objcopy. * objcopy.c (do_elf_stt_common): New. (command_line_switch): Add OPTION_ELF_STT_COMMON. (copy_options): Add --elf-stt-common=. (copy_usage): Add --elf-stt-common=. (copy_object): Also check do_elf_stt_common for ELF targets. (copy_file): Handle do_elf_stt_common. (copy_main): Handle OPTION_ELF_STT_COMMON. * readelf.c (apply_relocations): Support STT_COMMON. * testsuite/binutils-all/common-1.s: New file. * testsuite/binutils-all/common-1a.d: Likewise. * testsuite/binutils-all/common-1b.d: Likewise. * testsuite/binutils-all/common-1c.d: Likewise. * testsuite/binutils-all/common-1d.d: Likewise. * testsuite/binutils-all/common-1e.d: Likewise. * testsuite/binutils-all/common-1f.d: Likewise. * testsuite/binutils-all/common-2.s: Likewise. * testsuite/binutils-all/common-2a.d: Likewise. * testsuite/binutils-all/common-2b.d: Likewise. * testsuite/binutils-all/common-2c.d: Likewise. * testsuite/binutils-all/common-2d.d: Likewise. * testsuite/binutils-all/common-2e.d: Likewise. * testsuite/binutils-all/common-2f.d: Likewise. * testsuite/binutils-all/objcopy.exp (objcopy_test_elf_common_symbols): New proc. Run objcopy_test_elf_common_symbols for ELF targets gas/ PR ld/19645 * NEWS: Mention --enable-elf-stt-common and --elf-stt-common= for ELF assemblers. * as.c (flag_use_elf_stt_common): New. (show_usage): Add --elf-stt-common=. (option_values): Add OPTION_ELF_STT_COMMON. (std_longopts): Add --elf-stt-common=. (parse_args): Handle --elf-stt-common=. * as.h (flag_use_elf_stt_common): New. * config.in: Regenerated. * configure: Likewise. * configure.ac: Add --enable-elf-stt-common and define DEFAULT_GENERATE_ELF_STT_COMMON. * gas/write.c (write_object_file): Set BFD_CONVERT_ELF_COMMON and BFD_USE_ELF_STT_COMMON if flag_use_elf_stt_common is set. * doc/as.texinfo: Document --elf-stt-common=. * testsuite/gas/elf/common3.s: New file. * testsuite/gas/elf/common3a.d: Likewise. * testsuite/gas/elf/common3b.d: Likewise. * testsuite/gas/elf/common4.s: Likewise. * testsuite/gas/elf/common4a.d: Likewise. * testsuite/gas/elf/common4b.d: Likewise. * testsuite/gas/i386/dw2-compress-3b.d: Likewise. * testsuite/gas/i386/dw2-compressed-3b.d: Likewise. * testsuite/gas/elf/elf.exp: Run common3a, common3b, common4a and common4b. * testsuite/gas/i386/dw2-compress-3.d: Renamed to ... * testsuite/gas/i386/dw2-compress-3a.d: This. Pass --elf-stt-common=no to as. * testsuite/gas/i386/dw2-compressed-3.d: Renamed to ... * testsuite/gas/i386/dw2-compressed-3a.d: This. Pass --elf-stt-common=no to as. * testsuite/gas/i386/i386.exp: Run dw2-compress-3a, dw2-compress-3b, dw2-compressed-3a and dw2-compressed-3b instead of dw2-compress-3 and dw2-compressed-3. include/ PR ld/19645 * bfdlink.h (bfd_link_elf_stt_common): New enum. (bfd_link_info): Add elf_stt_common. ld/ PR ld/19645 * NEWS: Mention -z common/-z nocommon for ELF targets. * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Handle -z common and -z nocommon. * ld.texinfo: Document -z common/-z nocommon. * lexsup.c (elf_shlib_list_options): Add -z common/-z nocommon. * testsuite/ld-elf/tls_common.exp: Test --elf-stt-common=no and --elf-stt-common=yes with assembler. * testsuite/ld-elfcomm/common-1.s: New file. * testsuite/ld-elfcomm/common-1a.d: Likewise. * testsuite/ld-elfcomm/common-1b.d: Likewise. * testsuite/ld-elfcomm/common-1c.d: Likewise. * testsuite/ld-elfcomm/common-1d.d: Likewise. * testsuite/ld-elfcomm/common-1e.d: Likewise. * testsuite/ld-elfcomm/common-1f.d: Likewise. * testsuite/ld-elfcomm/common-2.s: Likewise. * testsuite/ld-elfcomm/common-2a.d: Likewise. * testsuite/ld-elfcomm/common-2b.d: Likewise. * testsuite/ld-elfcomm/common-2c.d: Likewise. * testsuite/ld-elfcomm/common-2d.d: Likewise. * testsuite/ld-elfcomm/common-2e.d: Likewise. * testsuite/ld-elfcomm/common-2f.d: Likewise. * testsuite/ld-elfcomm/common-3a.rd: Likewise. * testsuite/ld-elfcomm/common-3b.rd: Likewise. * testsuite/ld-i386/pr19645.d: Likewise. * testsuite/ld-i386/pr19645.s: Likewise. * testsuite/ld-x86-64/largecomm-1.s: Likewise. * testsuite/ld-x86-64/largecomm-1a.d: Likewise. * testsuite/ld-x86-64/largecomm-1b.d: Likewise. * testsuite/ld-x86-64/largecomm-1c.d: Likewise. * testsuite/ld-x86-64/largecomm-1d.d: Likewise. * testsuite/ld-x86-64/largecomm-1e.d: Likewise. * testsuite/ld-x86-64/largecomm-1f.d: Likewise. * testsuite/ld-x86-64/pr19645.d: Likewise. * testsuite/ld-x86-64/pr19645.s: Likewise. * testsuite/ld-elfcomm/elfcomm.exp: Test --elf-stt-common=yes with assembler. (assembler_generates_commons): Removed. Run -z common/-z nocommon tests. Run *.d tests. * testsuite/ld-i386/i386.exp: Run pr19645. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-x86-64/dwarfreloc.exp: Test --elf-stt-common with assembler. Test STT_COMMON with readelf.
2016-02-11Enable -Bsymbolic and -Bsymbolic-functions to PIEH.J. Lu1-6/+5
Before binutils 2.26, -Bsymbolic and -Bsymbolic-functions were also applied to PIE so that "ld -pie -Bsymbolic -E" can be used to export symbols in PIE with local binding. This patch re-enables -Bsymbolic and -Bsymbolic-functions for PIE. PR ld/19615 * ld.texinfo: Document -Bsymbolic and -Bsymbolic-functions for PIE. * lexsup.c (parse_args): Enable -Bsymbolic and -Bsymbolic-functions for PIE. * testsuite/ld-i386/i386.exp: Run pr19175. * testsuite/ld-i386/pr19615.d: New file. * testsuite/ld-i386/pr19615.s: Likewise. * testsuite/ld-x86-64/pr19615.d: Likewise. * testsuite/ld-x86-64/pr19615.s: Likewise.
2016-01-01Copyright update for binutilsAlan Modra1-1/+1
2015-10-29Fix reporting of command line options that need an argument, but which occur ↵Nick Clifton1-4/+25
as the last option on the command line. PR ld/19146 * lexsup.c (parse_args): Correct error message for an option that is missing its argument if that option is the last one on the command line.
2015-10-21Reset x86 Linux targets to not compressing debug sections by default. ↵Nick Clifton1-0/+7
Enable compression of debug sections by default in the linker, if so configured. PR gas/19109 . * configure.ac: Note the 'none' is an acceptable argument to --enable-compressed-debug-sections. * configure: Regenerate. gas * configure.ac: Restore --enable-compressed-debug-sections. Do not enable compressed debug sections by default for x86 Linux targets. * configure: Regenerate. ld * configure.ac: Add --enable-compressed-debug-sections. * configure: Regenerate. * config.in: Regenerate. * ld.texinfo: Document how to determine the default action for debug sections. * ldmain.c (main): If DEFAULT_FLAG_COMPRESS_DEBUG is defined then set the compress_debug field of the link_info structure to zlib-gabi. * lexsup.c (elf_static_list_options): Output the default setting for the --compress-debug-sections option. * NEWS: Mention the new configure option.
2015-09-20Add --no-dynamic-linker option to ld, for static PIE useRich Felker1-0/+7
Inhibits output of .interp section in ELF executables. include/ * bfdlink.h (struct bfd_link_info): Add "nointerp" field. bfd/ * elflink.c (_bfd_elf_link_create_dynamic_sections): Don't create .interp when info->nointerp. (bfd_elf_size_dynamic_sections): Adjust assert. * elf32-arm.c (elf32_arm_size_dynamic_sections): Don't size .interp when info->nointerp. * elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise. * elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise. * elf32-cris.c (elf_cris_size_dynamic_sections): Likewise. * elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise. * elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise. * elf32-i370.c (i370_elf_size_dynamic_sections): Likewise. * elf32-i386.c (elf_i386_size_dynamic_sections): Likewise. * elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise. * elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise. * elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise. * elf32-metag.c (elf_metag_size_dynamic_sections): Likewise. * elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise. * elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise. * elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise. * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise. * elf32-s390.c (elf_s390_size_dynamic_sections): Likewise. * elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise. * elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise. * elf32-sh.c (sh_elf_size_dynamic_sections): Likewise. * elf32-tic6x.c (elf32_tic6x_size_dynamic_sections): Likewise. * elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise. * elf32-vax.c (elf_vax_size_dynamic_sections): Likewise. * elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise. * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise. * elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise. * elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise. * elf64-s390.c (elf_s390_size_dynamic_sections): Likewise. * elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewise. * elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise. * elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise. * elfnn-ia64.c (elfNN_ia64_size_dynamic_sections): Likewise. * elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise. * elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise. ld/ * ld.texinfo (--no-dynamic-linker): Document. * ldlex.h (enum option_values): Add OPTION_NO_DYNAMIC_LINKER. * lexsup.c (ld_options, parse_args): Handle --no-dynamic-linker.
2015-09-04ld: Extend options for altering orphan handling behaviour.Andrew Burgess1-10/+17
Replace the options --warn-orphan and --no-warn-orphan with a single option --orphan-handling=MODE, where mode can be place, warn, error, and discard. Mode 'place' is the default, and is the current behaviour, placing the orphan section into a suitable output section. Mode 'warn' is the same as '--warn-orphan'. The orphan is also placed using the same algorithm as for 'place'. Mode 'error' is the same as '--warn-orphan' and '--fatal-warnings'. Mode 'discard' assigns all output sections to the /DISCARD/ section. ld/ChangeLog: * ld.h (enum orphan_handling_enum): New. (ld_config_type): Remove warn_orphan, add orphan_handling. * ldemul.c (ldemul_place_orphan): Remove warning about orphan sections. * ldlang.c (ldlang_place_orphan): New function. (lang_place_orphans): Call ldlang_place_orphan. * ldlex.h (enum option_values): Remove OPTION_WARN_ORPHAN and OPTION_NO_WARN_ORPHAN, add OPTION_ORPHAN_HANDLING. * lexsup.c (ld_options): Remove 'warn-orphan' and 'no-warn-orphan', add 'orphan-handling'. (parse_args): Remove handling for OPTION_WARN_ORPHAN and OPTION_NO_WARN_ORPHAN, add handling for OPTION_ORPHAN_HANDLING. * NEWS: Replace text about --warn-orphan with --orphan-handling. * ld.texinfo (Options): Remove --warn-orphan entry and add entry on --orphan-handling. (Orphan Sections): Add reference to relevant command line options. ld/testsuite/ChangeLog: * ld-elf/elf.exp: Switch to rely on run_dump_test. * ld-elf/orphan-5.l: Update expected output. * ld-elf/orphan-5.d: New file. * ld-elf/orphan-6.d: New file. * ld-elf/orphan-6.l: New file. * ld-elf/orphan-7.d: New file. * ld-elf/orphan-7.map: New file. * ld-elf/orphan-8.d: New file. * ld-elf/orphan-8.map: New file.
2015-08-19Remove link_info.picAlan Modra1-3/+1
Adding type_pie to output_type allows us to remove link_info.pic and with some reordering of the enum, produces better code. include/ * bfdlink.h (enum output_type): Delete type_executable, add type_pde and type_pie. Reorder. (struct bfd_link_info): Delete pic field. (bfd_link_executable, bfd_link_pde, bfd_link_pie, bfd_link_pic): Adjust. ld/ * emultempl/aix.em: Don't set link_info.pic. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/sunos.em: Likewise. * lexsup.c (parse_args): Likewise. Set type_pie for -pie. * plugin.c (set_tv_header <LDPT_LINKER_OUTPUT>): Simplify.
2015-08-18Add output_type to bfd_link_infoH.J. Lu1-19/+27
The "shared" field in bfd_link_info is set for both DSO and and PIE. There are separate fields for executable and relocatable outputs. This patch adds an "output_type" field: enum output_type { type_unknown = 0, type_executable, type_dll, type_relocatable }; and a "pic" field to bfd_link_info to replace shared, executable and relocatable fields so that we can use the "output_type" field to check for output type and the "pic" field check if output is PIC. Macros, bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie, are provided to check for output features. bfd/ * bfd/aoutx.h: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * bfd/bout.c: Likewise. * bfd/coff-alpha.c: Likewise. * bfd/coff-arm.c: Likewise. * bfd/coff-i386.c: Likewise. * bfd/coff-i960.c: Likewise. * bfd/coff-m68k.c: Likewise. * bfd/coff-mcore.c: Likewise. * bfd/coff-mips.c: Likewise. * bfd/coff-ppc.c: Likewise. * bfd/coff-rs6000.c: Likewise. * bfd/coff-sh.c: Likewise. * bfd/coff-tic80.c: Likewise. * bfd/coff-x86_64.c: Likewise. * bfd/coff64-rs6000.c: Likewise. * bfd/coffgen.c: Likewise. * bfd/cofflink.c: Likewise. * bfd/ecoff.c: Likewise. * bfd/ecofflink.c: Likewise. * bfd/elf-bfd.h: Likewise. * bfd/elf-eh-frame.c: Likewise. * bfd/elf-ifunc.c: Likewise. * bfd/elf-m10200.c: Likewise. * bfd/elf-m10300.c: Likewise. * bfd/elf-s390-common.c: Likewise. * bfd/elf-vxworks.c: Likewise. * bfd/elf.c: Likewise. * bfd/elf32-arm.c: Likewise. * bfd/elf32-avr.c: Likewise. * bfd/elf32-bfin.c: Likewise. * bfd/elf32-cr16.c: Likewise. * bfd/elf32-cr16c.c: Likewise. * bfd/elf32-cris.c: Likewise. * bfd/elf32-crx.c: Likewise. * bfd/elf32-d10v.c: Likewise. * bfd/elf32-dlx.c: Likewise. * bfd/elf32-epiphany.c: Likewise. * bfd/elf32-fr30.c: Likewise. * bfd/elf32-frv.c: Likewise. * bfd/elf32-ft32.c: Likewise. * bfd/elf32-h8300.c: Likewise. * bfd/elf32-hppa.c: Likewise. * bfd/elf32-i370.c: Likewise. * bfd/elf32-i386.c: Likewise. * bfd/elf32-i860.c: Likewise. * bfd/elf32-ip2k.c: Likewise. * bfd/elf32-iq2000.c: Likewise. * bfd/elf32-lm32.c: Likewise. * bfd/elf32-m32c.c: Likewise. * bfd/elf32-m32r.c: Likewise. * bfd/elf32-m68hc11.c: Likewise. * bfd/elf32-m68hc1x.c: Likewise. * bfd/elf32-m68k.c: Likewise. * bfd/elf32-mcore.c: Likewise. * bfd/elf32-mep.c: Likewise. * bfd/elf32-metag.c: Likewise. * bfd/elf32-microblaze.c: Likewise. * bfd/elf32-moxie.c: Likewise. * bfd/elf32-msp430.c: Likewise. * bfd/elf32-mt.c: Likewise. * bfd/elf32-nds32.c: Likewise. * bfd/elf32-nios2.c: Likewise. * bfd/elf32-or1k.c: Likewise. * bfd/elf32-ppc.c: Likewise. * bfd/elf32-rl78.c: Likewise. * bfd/elf32-rx.c: Likewise. * bfd/elf32-s390.c: Likewise. * bfd/elf32-score.c: Likewise. * bfd/elf32-score7.c: Likewise. * bfd/elf32-sh-symbian.c: Likewise. * bfd/elf32-sh.c: Likewise. * bfd/elf32-sh64.c: Likewise. * bfd/elf32-spu.c: Likewise. * bfd/elf32-tic6x.c: Likewise. * bfd/elf32-tilepro.c: Likewise. * bfd/elf32-v850.c: Likewise. * bfd/elf32-vax.c: Likewise. * bfd/elf32-visium.c: Likewise. * bfd/elf32-xc16x.c: Likewise. * bfd/elf32-xstormy16.c: Likewise. * bfd/elf32-xtensa.c: Likewise. * bfd/elf64-alpha.c: Likewise. * bfd/elf64-hppa.c: Likewise. * bfd/elf64-ia64-vms.c: Likewise. * bfd/elf64-mmix.c: Likewise. * bfd/elf64-ppc.c: Likewise. * bfd/elf64-s390.c: Likewise. * bfd/elf64-sh64.c: Likewise. * bfd/elf64-x86-64.c: Likewise. * bfd/elflink.c: Likewise. * bfd/elfnn-aarch64.c: Likewise. * bfd/elfnn-ia64.c: Likewise. * bfd/elfxx-mips.c: Likewise. * bfd/elfxx-sparc.c: Likewise. * bfd/elfxx-tilegx.c: Likewise. * bfd/i386linux.c: Likewise. * bfd/linker.c: Likewise. * bfd/m68klinux.c: Likewise. * bfd/pdp11.c: Likewise. * bfd/pe-mips.c: Likewise. * bfd/peXXigen.c: Likewise. * bfd/reloc.c: Likewise. * bfd/reloc16.c: Likewise. * bfd/sparclinux.c: Likewise. * bfd/sunos.c: Likewise. * bfd/vms-alpha.c: Likewise. * bfd/xcofflink.c: Likewise. include/ * include/bfdlink.h (output_type): New enum. (bfd_link_executable): New macro. (bfd_link_dll): Likewise. (bfd_link_relocatable): Likewise. (bfd_link_pic): Likewise. (bfd_link_pie): Likewise. (bfd_link_info): Remove shared, executable, pie and relocatable. Add output_type and pic. ld/ * ld/ldctor.c: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * ld/ldemul.c: Likewise. * ld/ldfile.c: Likewise. * ld/ldlang.c: Likewise. * ld/ldmain.c: Likewise. * ld/ldwrite.c: Likewise. * ld/lexsup.c: Likewise. * ld/pe-dll.c: Likewise. * ld/plugin.c: Likewise. * ld/emultempl/aarch64elf.em: Likewise. * ld/emultempl/aix.em: Likewise. * ld/emultempl/alphaelf.em: Likewise. * ld/emultempl/armcoff.em: Likewise. * ld/emultempl/armelf.em: Likewise. * ld/emultempl/avrelf.em: Likewise. * ld/emultempl/beos.em: Likewise. * ld/emultempl/cr16elf.em: Likewise. * ld/emultempl/elf-generic.em: Likewise. * ld/emultempl/elf32.em: Likewise. * ld/emultempl/genelf.em: Likewise. * ld/emultempl/generic.em: Likewise. * ld/emultempl/gld960.em: Likewise. * ld/emultempl/gld960c.em: Likewise. * ld/emultempl/hppaelf.em: Likewise. * ld/emultempl/irix.em: Likewise. * ld/emultempl/linux.em: Likewise. * ld/emultempl/lnk960.em: Likewise. * ld/emultempl/m68hc1xelf.em: Likewise. * ld/emultempl/m68kcoff.em: Likewise. * ld/emultempl/m68kelf.em: Likewise. * ld/emultempl/metagelf.em: Likewise. * ld/emultempl/mipself.em: Likewise. * ld/emultempl/mmo.em: Likewise. * ld/emultempl/msp430.em: Likewise. * ld/emultempl/nds32elf.em: Likewise. * ld/emultempl/needrelax.em: Likewise. * ld/emultempl/nios2elf.em: Likewise. * ld/emultempl/pe.em: Likewise. * ld/emultempl/pep.em: Likewise. * ld/emultempl/ppc32elf.em: Likewise. * ld/emultempl/ppc64elf.em: Likewise. * ld/emultempl/sh64elf.em: Likewise. * ld/emultempl/solaris2.em: Likewise. * ld/emultempl/spuelf.em: Likewise. * ld/emultempl/sunos.em: Likewise. * ld/emultempl/tic6xdsbt.em: Likewise. * ld/emultempl/ticoff.em: Likewise. * ld/emultempl/v850elf.em: Likewise. * ld/emultempl/vms.em: Likewise. * ld/emultempl/vxworks.em: Likewise.
2015-08-04ld: Add '--require-defined' command line option.Andrew Burgess1-0/+6
Add a new command line option '--require-defined' to the linker. This option operates identically to the '--undefined' option, except that if the symbol is not defined in the final output file then the linker will exit with an error. When making use of --gc-section, or just when trying to pull in parts of a library, it is not uncommon for a user to use the '--undefined' command line option to specify a symbol that the user then expects to be defined by one of the object files supplied to the link. However, if for any reason the symbol is not satisfied by an object provided to the link the user will be left with an undefined symbol in the output file, instead of a defined symbol. In some cases the above behaviour is what the user wants, in other cases though we can do better. The '--require-defined' option tries to fill this gap. The symbol passed to the '--require-defined' option is treated exactly as if the symbol was passed to '--undefined', however, before the linker exits a check is made that all symbols passed to '--require-defined' are actually defined, if any are not then the link will fail with an error. ld/ChangeLog: * ld.texinfo (Options): Document --require-defined option. * ldlang.c (struct require_defined_symbol): New structure. (require_defined_symbol_list): New variable. (ldlang_add_require_defined): New function. (ldlang_check_require_defined_symbols): New function. (lang_process): Check required symbols are defined. * ldlang.h (ldlang_add_require_defined): Declare. * ldlex.h (enum option_values): Add OPTION_REQUIRE_DEFINED_SYMBOL. * lexsup.c (ld_options): Add '--require-defined' entry. (parse_args): Handle '--require-defined' entry. * NEWS: Mention new '--require-defined' option. ld/testsuite/ChangeLog: * ld-undefined/require-defined-1.d: New file. * ld-undefined/require-defined-2.d: New file. * ld-undefined/require-defined-3.d: New file. * ld-undefined/require-defined-4.d: New file. * ld-undefined/require-defined-5.d: New file. * ld-undefined/require-defined.exp: New file. * ld-undefined/require-defined.s: New file.
2015-07-29Don't set link_info.executable for "ld -r"H.J. Lu1-1/+1
This patch changes "ld -r" not to set link_info.executable. It removes !info->relocatable check for info->executable and adds it for !info->executable in elflink.c. bfd/ * elflink.c (elf_link_add_object_symbols): Remove !info->relocatable check for info->executable. Add !info->relocatable check for !info->executable. (elf_link_output_extsym): Remove !info->relocatable check for info->executable. ld/ * lexsup.c (parse_args): Don't set link_info.executable to TRUE for link_info.relocatable.
2015-06-12Add new ld option: --print-memory-usageTristan Gingold1-0/+6
ld/ * NEWS: Mention new option. * lexsup.c (parse_args): Handle --print-memory-usage. (ld_options): Add --print-memory-usage. * ldmain.c (main): Call lang_print_memory_usage. * ldlex.h (enum option_values): Add OPTION_PRINT_MEMORY_USAGE. * ldlang.h: Add prototype of lang_print_memory_usage. * ldlang.c (lang_print_memory_size, lang_print_memory_usage): New functions. * ld.texinfo (Options): Document --print-memory-usage. * ld.h (args_type): Add print_memory_usage field. ld/testsuite/ * ld-scripts/print-memory-usage-1.t, * ld-scripts/print-memory-usage-1.s, * ld-scripts/print-memory-usage-1.l, * ld-scripts/print-memory-usage-2.t, * ld-scripts/print-memory-usage-2.l, * ld-scripts/print-memory-usage-3.s, * ld-scripts/print-memory-usage-3.t, * ld-scripts/print-memory-usage-3.l, * ld-scripts/print-memory-usage.t: New tests. * ld-scripts/print-memory-usage.exp: Run them.
2015-04-14Add --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi]H.J. Lu1-0/+3
This patch adds --compress-debug-sections=[none|zlib|zlib-gnu|zlib-gabi] to ld for ELF targets to support generating compressed DWARF debug sections. We always generate .zdebug_* section since section names have been finalized and they can't be changed easily when compression is being performed. bfd/ * bfd-in.h (compressed_debug_section_type): New. * compress.c (bfd_compress_section_contents): Add an argument for linker write compression and always generate .zdebug_* section when linking. (bfd_init_section_compress_status): Pass FALSE to bfd_compress_section_contents. (bfd_compress_section): New function. * elf.c (elf_fake_sections): For linking, set SEC_ELF_COMPRESS on DWARF debug sections if COMPRESS_DEBUG is set and rename section if COMPRESS_DEBUG_GABI_ZLIB isn't set. (assign_file_positions_for_non_load_sections): Set sh_offset to -1 if SEC_ELF_COMPRESS is set. (assign_file_positions_except_relocs): Likwise. (_bfd_elf_assign_file_positions_for_relocs): Renamed to ... (_bfd_elf_assign_file_positions_for_non_load): This. Change return time to bfd_boolean. Compress the section if SEC_ELF_COMPRESS is set. (_bfd_elf_write_object_contents): Updated. (_bfd_elf_set_section_contents): Write section contents to the buffer if SEC_ELF_COMPRESS is set. * merge.c: Include "elf-bfd.h". (sec_merge_emit): Add arguments for contents and offset. Write to contents with offset if contents isn't NULL. (_bfd_write_merged_section): Write section contents to the buffer if SEC_ELF_COMPRESS is set. Pass contents and output_offset to sec_merge_emit. * elflink.c (bfd_elf_final_link): Allocate the buffer for output section contents if SEC_ELF_COMPRESS is set. * section.c (SEC_ELF_COMPRESS): New. * bfd-in2.h: Regenerated. gas/ * as.h (compressed_debug_section_type): Removed. include/ * bfdlink.h (bfd_link_info): Add compress_debug. ld/ * ld.texinfo: Document --compress-debug-sections=. * ldmain.c (main): Set BFD_COMPRESS on output_bfd if COMPRESS_DEBUG is set. Set BFD_COMPRESS_GABI on output_bfd for COMPRESS_DEBUG_GABI_ZLIB. * lexsup.c (elf_static_list_options): Add --compress-debug-sections=. * emultempl/elf32.em (OPTION_COMPRESS_DEBUG): New. (xtra_long): Add "compress-debug-sections". (gld${EMULATION_NAME}_handle_option): Handle OPTION_COMPRESS_DEBUG. ld/testsuite/ * ld-elf/compress.exp (build_tests): Add tests for --compress-debug-sections=. (run_tests): Likewise. Add additonal tests for --compress-debug-sections=. * ld-elf/gabiend.rt: New file. * ld-elf/gabinormal.rt: Likewise. * ld-elf/gnubegin.rS: Likewise. * ld-elf/gnunormal.rS: Likewise. * ld-elf/zlibbegin.rS: Likewise. * ld-elf/zlibnormal.rS: Likewise.
2015-04-08Add ld_list_optionsH.J. Lu1-0/+108
This patch adds ld_list_options for ELF targets to avoid duplicated outputs from ld --help. * Makefile.am (ELF_CLFAGS): New. (AM_CFLAGS): Add $(ELF_CLFAGS). * configure.ac (elf_list_options): New. AC_SUBST. (elf_shlib_list_options): Likewise. (elf_plt_unwind_list_options): Likewise. * lexsup.c (elf_shlib_list_options): New. (elf_static_list_options): Likewise. (elf_plt_unwind_list_options): Likewise. (ld_list_options): Likewise. (help): Call ld_list_options. * Makefile.in: Regenerated. * configure: Likewise. * emulparams/plt_unwind.sh (PLT_UNWIND): New. (PARSE_AND_LIST_OPTIONS): Removed. * emultempl/elf32.em (gld_list_options): New. (gld${EMULATION_NAME}_list_options): Define only if BNDPLT or PARSE_AND_LIST_OPTIONS is defined. (ld_${EMULATION_NAME}_emulation): Replace gld${EMULATION_NAME}_list_options with ${gld_list_options.
2015-04-07Add new linker option: --warn-orphan which generates warning messages when ↵Nick Clifton1-0/+10
orphan sections are detected. ld * ld.h (struct ld_config_type): Add new field: warn_orphan. * ldlex.h (enum option_values): Add OPTION_WARN_ORPHAN and OPTION_NO_WARN_ORPHAN. * lexsup.c (ld_options): Add --warn-orphan and --no-warn-orphan. (parse_args): Handle the new options. * ldemul.c (ldemul_place_orphan): If requested, generate a warning message when an orphan section is placed in the output file. * ld.texinfo: Document the new option. * NEWS: Mention the new feature. tests * ld-elf/orphan-5.l: New test - checks the linker's output with --warn-orphan enabled. * ld-elf/elf.exp: Run the new test.
2015-02-23Fixes a problem where "ld -ixxx" would report an error of "ld: bad -rpath ↵Nick Clifton1-1/+1
option". * lexsup.c (parse_args): Produce a more reasonable error message when -ixxx or -rxxx is the last option on the linker command line.
2015-02-11Add --[no-]map-whole-files for gold compatibilityH.J. Lu1-0/+6
Gold supports: --map-whole-files Map whole files to memory (default on 64-bit hosts) --no-map-whole-files Map relevant file parts to memory (default on 32-bit hosts) This patch adds --[no-]map-whole-files command line options for gold compatibility. They are ignored for ld. * lexsup.c (ld_options): Add --[no-]map-whole-files for gold option compatibility.
2015-01-02ChangeLog rotatation and copyright year updateAlan Modra1-1/+1
2014-10-17Implement --print-sysroot in ld.Hans-Peter Nilsson1-0/+7
* ldlex.h (enum option_values): Add entry OPTION_PRINT_SYSROOT. * lexsup.c (ld_options): Add entry for --print-sysroot. (parse_args) <OPTION_PRINT_SYSROOT>: Print sysroot and exit early.
2014-08-08 * ldlang.h (struct lang_input_statement_flags): Add pushedUlrich Drepper1-0/+23
member. * ldlex.h (enum option_values): Add OPTION_PUSH_STATE and OPTION_POP_STATE. * lexsup.c (ld_options): Add entries for --push-state and --pop-state. (parse_args): Handle OPTION_PUSH_STATE and OPTION_POP_STATE. * ld.texinfo: Document --push-state and --pop-state.
2014-06-30 lexsup.c (parse_args): Check whether provided SONAME is emptyUlrich Drepper1-1/+11
string. If yes, warn and ignore it. Don't overwrite valid SONAME with empty string.
2014-03-05Update copyright yearsAlan Modra1-3/+1
2013-01-14 * ld.texinfo (-Tldata-segment): Describe.Alan Modra1-0/+5
* ldlex.h (OPTION_TLDATA_SEGMENT): New enum value. * lexsup.c (ld_options): Add -Tldata-segment. (parse_args): Handle OPTION_TLDATA_SEGMENT. * scripttempl/elf.sc: Support LARGE_DATA_ADDR.
2013-01-07Add fuse-ld= for GCC linker option compatibilityH.J. Lu1-0/+3
* lexsup.c (ld_options): Add fuse-ld= for GCC linker option compatibility.
2012-12-18ld/Roland McGrath1-3/+8
* ld.texinfo (Options): Describe -Trodata-segment. * ldlex.h (enum option_values): Add OPTION_TRODATA_SEGMENT. * lexsup.c (ld_options, parse_args): Handle -Trodata-segment. * scripttempl/elf.sc (RODATA_ADDR, SHLIB_RODATA_ADDR): Wrap SEGMENT_START("rodata-segment", ...) + SIZEOF_HEADERS around the value.
2012-12-03Improve plugin error handlingH.J. Lu1-3/+1
ld/ PR ld/14904 * ldmain.c (main): Don't check plugin_load_plugins return. * lexsup.c (parse_args): Don't check plugin_opt_plugin return. * plugin.c (dlerror): New. Defined if HAVE_DLFCN_H isn't defined. (plugin_opt_plugin): Change return type to void. Stop on dlopen error and report error with dlerror (). (plugin_load_plugins): Change return type to void. Stop on dlsym error and report error with dlerror (). Don't use set_plugin_error. (plugin_call_cleanup): Issue an error for each plugin. * plugin.h (plugin_opt_plugin): Change return type to void. (plugin_load_plugins): Likewise. ld/testsuite/ PR ld/14904 * ld-plugin/plugin-2.d: Update expected error message. * ld-plugin/plugin-4.d: Likewise.
2012-10-22include/Alan Modra1-0/+7
PR ld/14426 * bfdlink.h (bfd_link_info): Add ignore_hash. ld/ PR ld/14426 * ldlex.h (option_values): Add OPTION_IGNORE_UNRESOLVED_SYMBOL. * lexsup.c (parse_args): Likewise. (ld_options): Describe --ignore-unresolved-symbol. * ldmain.h (add_ignoresym): Declare. * ldmain.c (add_ignoresym): New function, extracted from.. (undefined_symbol): ..here. Return if the symbol is in ignore_hash. (constructor_callback): Don't use global link_info here. (reloc_overflow): Likewise.
2012-07-13 PR ld/14357Nick Clifton1-1/+1
* ldmain.c (trace_file_tries): Rename to 'verbose'. * ldfile.c: Likewise. * ldlang.c: Likewise. * ldmain.h: Likewise. * lexsup.c: Likewise. * emultempl/elf32.em: Likewise. * emultemp/spuelf.em: Likewise. * pe-dll.c (pe_dll_generate_implib): Only print creation message in verbose mode.
2012-05-26ld/Alan Modra1-113/+0
* ldlex.h (enum option_values): Move from.. * lexsup.c: ..here. * emultempl/ppc32elf.em: Include ldlex.h. (PARSE_AND_LIST_ARGS_CASES): Disable optimisations when --traditional-format. * emultempl/ppc64elf.em: Likewise. ld/testsuite/ * ld-srec/srec.exp: Remove powerpc64 flag setting.
2012-03-262012-03-26 Tristan Gingold <gingold@adacore.com>Tristan Gingold1-1/+1
* lexsup.c (parse_args): Add a missing '\n'.
2012-03-05 * ldlang.h (struct lang_input_statement_flags): New, extract from..Alan Modra1-15/+15
(lang_input_statement_type): ..here. New field "flags". (input_flags): Declare. (missing_file): Delete. * ldmain.h (whole_archive): Delete. (add_DT_NEEDED_for_regular, add_DT_NEEDED_for_dynamic): Delete. * ld.h (ld_config_type <dynamic_link>): Delete. * ldmain.c (whole_archive): Delete. (add_DT_NEEDED_for_regular, add_DT_NEEDED_for_dynamic): Delete. * ldlang.c (missing_file, ldlang_sysrooted_script): Delete. (input_flags): New variable. Replace all uses of config.dynamic_link, missing_file, ldlang_sysrooted_script, whole_archive, add_DT_NEEDED_for_regular and add_DT_NEEDED_for_dynamic with fields from here. * ldfile.c: Likewise. * ldgram.y: Likewise. * ldmain.c: Likewise. * ldwrite.c: Likewise. * lexsup.c: Likewise. * plugin.c: Likewise. * emultempl/aix.em: Likewise. * emultempl/armelf.em: Likewise. * emultempl/elf32.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/linux.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/scoreelf.em: Likewise. * emultempl/spuelf.em: Likewise. * emultempl/sunos.em: Likewise. * emultempl/vms.em: Likewise. * ldlang.c (new_afile): Use memset to init zero fields. (load_symbols): Simplify save and restore of flags around command file processing. * ldfile.c (is_sysrooted_pathname): Tidy.
2012-02-17 PR ld/13343Alan Modra1-7/+3
* ld.h (parsing_defsym): Delete. * ldexp.c (exp_intop, exp_bigintop, exp_relop): Set type.filename. (fold_binary, fold_name, exp_fold_tree_1, exp_get_vma, exp_get_fill, exp_get_abs_int): Add tree arg for %S in error messages. Don't fudge lineno. (exp_binop, exp_unop, exp_nameop, exp_assop, exp_assert): Copy type.filename from sub-tree. (exp_trinop): Likewise, and use "cond" rather than "lhs". * ldexp.h (node_type): Add filename field to struct. * ldfile.c (ldfile_input_filename): Delete. Remove all refs. * ldfile.h (ldfile_input_filename): Delete. * ldgram.y (phdr_type, phdr_qualifiers, yyerror): Add NULL arg for %S in error messages. * ldemul.c (syslib_default, hll_default): Likewise. * ldlang.c (lang_memory_region_lookup, lang_memory_region_alias, lang_get_regions, lang_new_phdr): Likewise. (lang_size_sections_1): Pass addr_tree for %S. * ldlex.h (lex_redirect): Update prototype. (ldlex_filename): Declare. * ldlex.l (<EOF>): Don't set ldfile_input_filename. (lex_redirect): Add fake_filename and count params. Push fake_filename to file_name_stack and init lineno from count. (ldlex_filename): New function. (lex_warn_invalid): Use above. * ldmain.c (main): Update lex_redirect call. * ldmisc.c (vfinfo <%S>): Take file name and line number from etree_type arg, or use current if arg is NULL. * lexsup.c (parsing_defsym): Delete. (parse_args <OPTION_DEFSYM>): Update lex_redirect call.
2011-10-10 * ldmain.c (main): Move code twiddling various config and link_infoAlan Modra1-5/+65
bits to.. * lexsup.c (parse_args): ..here. Move plugin_load_plugins call into main. * plugin.c (set_tv_header): Test link_info.executable, not link_info.shared. (is_visible_from_outside): Likewise. Delete redundant is_ir_dummy_bfd check and "section" parameter.
2011-07-16Implement ld --print-output-format.Roland McGrath1-0/+6
2011-06-02Fix spelling mistakes.Nick Clifton1-2/+2
2011-03-23 * lexsup.c (parse_args): Only set report_plugin_symbols if pluginsJoseph Myers1-1/+3
are enabled. Mark level as possibly unused.
2011-03-04Report plugin symbols for --verbose=N.H.J. Lu1-2/+11
2011-03-04 H.J. Lu <hongjiu.lu@intel.com> * ld.texinfo: Document --verbose[=NUMBER]. * lexsup.c (ld_options): Update --verbose. (parse_args): Set report_plugin_symbols. * plugin.c (report_plugin_symbols): New. (get_symbols): Report plugin symbols if report_plugin_symbols is TRUE. * plugin.h (report_plugin_symbols): New.
2010-12-06Add -flto and -flto-partition=.H.J. Lu1-0/+6
2010-12-06 H.J. Lu <hongjiu.lu@intel.com> * lexsup.c (ld_options): Add -flto and -flto-partition= for GCC LTO option compatibility.