Commit Graph

156 Commits

Author SHA1 Message Date
Alan Modra 18794b0c44 * ldlang.c (init_os): Ensure sections mentioned in load_base
are initialized.
2002-12-06 22:33:18 +00:00
Alan Modra b34976b65a s/boolean/bfd_boolean/ s/true/TRUE/ s/false/FALSE/. Simplify
comparisons of bfd_boolean vars with TRUE/FALSE.  Formatting.
2002-11-30 08:39:46 +00:00
Alan Modra c4c4121963 * ldlang.c (lang_add_section): Discard debugging sections that have
been marked SEC_EXCLUDE.
2002-11-12 11:31:43 +00:00
Daniel Jacobowitz df2a731323 * emultempl/aix.em: Use include <> for generated headers.
* emultempl/beos.em: Likewise.
	* emultempl/elf32.em: Likewise.
	* emultempl/pe.em: Likewise.
	* ldctor.c: Likewise.
	* ldexp.c: Likewise.
	* ldfile.c: Likewise.
	* ldlang.c: Likewise.
	* ldlex.c: Likewise.
	* ldlex.l: Likewise.
	* ldmain.c: Likewise.
	* ldmisc.c: Likewise.
	* ldwrite.c: Likewise.
	* lexsup.c: Likewise.
	* mri.c: Likewise.
	* pe-dll.c: Likewise.
2002-10-30 03:57:39 +00:00
Alan Modra 03bdc40405 * ldlang.c (load_symbols): Revert last change. 2002-10-15 00:09:02 +00:00
Alan Modra 7c519c12a3 * ldlang.c (load_symbols): Don't call bfd_link_add_symbols when
just_syms_flag.
	(lang_reasonable_defaults): Don't compare against false.
	(size_input_section): Likewise.
	(lang_size_sections_1): Likewise.
	(lang_do_assignments): Likewise.
	(lang_add_output): Likewise.
2002-10-14 13:08:19 +00:00
Jakub Jelinek 599917b82b * ldfile.c (ldfile_try_open_bfd): When searching skip linker scripts if
they have OUTPUT_FORMAT not matching actual output format.
	* ldlang.c (lang_get_output_target): New function.
	(open_output): Use it.
	* ldlang.h (lang_get_output_target): New prototype.
2002-10-10 15:59:10 +00:00
H.J. Lu c04c958616 2002-10-08 H.J. Lu <hjl@gnu.org>
* ldlang.c (lang_file_exist): Removed.
	(new_afile): Revert the last change.
	* ldlang.h (lang_file_exist): Removed.
	* lexsup.c (parse_args): Revert the last change.
2002-10-08 20:12:45 +00:00
Nick Clifton 53b2a62f07 Abort if the filename to be added matches the linker output filename. 2002-10-07 16:08:21 +00:00
Alan Modra 7abb6dea2c * ldlang.c (offsetof): Define if not defined. 2002-08-20 23:48:18 +00:00
Alan Modra c553bb910d * emulparams/elf32_dlx.sh (TARGET_PAGE_SIZE): Set to 1.
(MAXPAGESIZE): Set to 1.

	* ld.h (ALIGN_N): Delete.
	* ldexp.h (align_n): Declare.
	* ldexp.c (align_n): New function.
	(fold_binary): Use align_n instead of ALIGN_N.
	(exp_fold_tree): Likewise.
	* ldlang.c (lang_size_sections_1): Likewise.
	(lang_one_common): Likewise.
2002-08-13 02:08:26 +00:00
H.J. Lu 3194163592 Check symbols with undefine version. 2002-08-08 03:50:18 +00:00
Jakub Jelinek 704afa601f * elf.c (elf_fake_sections): Fix up .tbss sh_size and sh_type.
* ldlang.c (lang_add_section): Don't turn .tbss into normal sections
	for relocatable link.
	(lang_size_sections_1): Don't make .tbss zero size for relocatable
	link.
2002-07-30 14:28:55 +00:00
Alan Modra 34786259b8 * ldlang.c (print_wild_statement): Fix output formatting. 2002-07-05 12:54:28 +00:00
Alan Modra 4bd5a3935b * ldlang.c: (strip_excluded_output_sections): New function.
(lang_process): Call it.
	(lang_size_sections_1): Revert 2002-06-10 change.
2002-07-04 14:41:01 +00:00
Alan Modra e3e942e990 * ldlang.h (entry_sym): Make it a struct bfd_sym_chain.
* ldlang.c (entry_sym): Likewise.
	(ldlang_undef_chain_list_type): Likewise.
	(lang_finish): Adjust references to entry_symbol.
	(lang_add_entry): Likewise.
	(lang_gc_sections): Use link_info.gc_sym_list.
	(lang_process): Set link_info.gc_sym_list.
	* ldlex.l: Include bfdlink.h.
	* ldmain.c (main): Init link_info.gc_sym_list.
	* emultempl/aix.em: Adjust references to entry_symbol.
	* emultempl/armcoff.em: Likewise.
	* emultempl/armelf.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/ppc64elf.em (ppc_after_open): New function.
	(LDEMUL_AFTER_OPEN): Define.
	* emulparams/elf64ppc.sh: KEEP .opd sections.
2002-07-01 08:07:31 +00:00
Richard Sandiford e052cfbe68 * ldlang.c (lang_size_sections_1): Skip removed output sections. 2002-06-10 16:12:04 +00:00
Alan Modra 9ad85d9b01 * ldlang.c (section_already_linked): Call bfd_discard_group. Typo fix. 2002-06-04 01:07:29 +00:00
Richard Sandiford ee3cc2e2ee * ldlang.c (lang_size_sections_1): Move check for conflicting load
addresses and regions from here...
	(lang_get_regions): ...to this new function.
	(lang_leave_output_section_statement): Use lang_get_regions.
	(lang_leave_overlay): Likewise.
	* mri.c (mri_draw_tree): Pass null as last argument to
	lang_leave_output_section_statement.
	* emultempl/elf32.em (gld*_place_orphan): Likewise.
	* emultempl/mmo.em (mmo_place_orphan): Likewise.
	* emultempl/pe.em (gld*_place_orphan): Likewise.
2002-05-27 08:22:08 +00:00
Alan Modra 0d6d936fc1 * ldlang.c (lang_process): Formatting, grammar. 2002-05-25 13:10:11 +00:00
Jakub Jelinek 13ae64f3c7 * elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL
for symbols from SHF_TLS section.
	(_bfd_elf_print_private_bfd_data): Add PT_TLS.
	(elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections.
	(map_sections_to_segments): Build PT_TLS segment if necessary.
	(assign_file_positions_for_segments): Likewise.
	(get_program_header_size): Account for PT_TLS segment.
	(swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from
	SEC_THREAD_LOCAL sections to STT_TLS.
	* reloc.c: Add 386 and IA-64 TLS relocs.
	* section.c (SEC_THREAD_LOCAL): Define.
	(SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS):
	Remove.
	* elflink.h (elf_link_add_object_symbols): Support .tcommon.
	(size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS
	unconditionally.
	(struct elf_final_link_info): Add first_tls_sec.
	(elf_bfd_final_link): Set first_tls_sec.
	Compute elf_hash_table (info)->tls_segment.
	(elf_link_output_extsym): Handle STT_TLS symbols.
	(elf_link_input_bfd): Likewise.
	* syms.c (BSF_THREAD_LOCAL): Define.
	* bfd-in2.h: Rebuilt.
	* libbfd.h: Rebuilt.
	* elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff,
	elf_i386_mkobject, elf_i386_object_p): New functions.
	(elf_howto_table): Add TLS relocs.
	(elf_i386_reloc_type_lookup): Support TLS relocs.
	(elf_i386_info_to_howto_rel): Likewise.
	(struct elf_i386_link_hash_entry): Add tls_type.
	(struct elf_i386_obj_tdata): New.
	(elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type):
	New macros.
	(struct elf_i386_link_hash_table): Add tls_ldm_got.
	(link_hash_newfunc): Clear tls_type.
	(elf_i386_check_relocs): Support TLS relocs.
	(elf_i386_gc_sweep_hook): Likewise.
	(allocate_dynrelocs): Likewise.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol): Likewise.
	(bfd_elf32_mkobject, elf_backend_object_p): Define.
	* elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset,
	dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done,
	want_tprel, want_dtpmod, want_dtprel.
	(elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions.
	(ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to
	R_IA64_LTOFF_TPREL22.
	(elf_code_to_howto_index): Add TLS relocs.
	(elfNN_ia64_check_relocs): Support TLS relocs.
	(allocate_global_data_got): Account for TLS .got data.
	(allocate_dynrel_entries): Account for TLS dynamic relocations.
	(elfNN_ia64_install_value): Supprt TLS relocs.
	(set_got_entry): Support TLS relocs.
	(elfNN_ia64_relocate_section): Likewise.

	* config/obj-elf.c (elf_common): Renamed from obj_elf_common.
	(obj_elf_common): Call elf_common.
	(obj_elf_tls_common): New function.
	(elf_pseudo_tab): Support .tls_common.
	(special_sections): Add .tdata and .tbss.
	(obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS
	sections.
	(obj_elf_parse_section_letters): Support T in section flags (SHF_TLS).
	(obj_elf_parse_section_letters): Include T in error message.
	* config/tc-ppc.c (ppc_section_letter): Likewise.
	* config/tc-alpha.c (alpha_elf_section_letter): Likewise.
	(tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as
	SEC_MERGE.
	* config/tc-sparc.c (md_apply_fix3): Likewise.
	* config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs.
	Define them if not BFD_ASSEMBLER.
	(lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF
	and @NTPOFF.
	(md_apply_fix3): Add TLS relocs.
	* config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE,
	FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE,
	FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE.
	(pseudo_func): Support @dtpmod(), @dtprel() and @tprel().
	(ia64_elf_section_letter): Include T in error message.
	(md_begin): Support TLS operators.
	(md_operand): Likewise.
	(ia64_gen_real_reloc_type): Support TLS relocs.
	* testsuite/gas/i386/tlspic.s: New file.
	* testsuite/gas/i386/tlsd.s: New file.
	* testsuite/gas/i386/tlsnopic.s: New file.
	* testsuite/gas/i386/tlsd.d: New file.
	* testsuite/gas/i386/tlsnopic.d: New file.
	* testsuite/gas/i386/tlspic.d: New file.
	* testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests.
	* testsuite/gas/ia64/tls.s: New file.
	* testsuite/gas/ia64/tls.d: New file.
	* testsuite/gas/ia64/ia64.exp: Add tls test.
	* write.c (adjust_reloc_syms): Don't change symbols in
	SEC_THREAD_LOCAL sections to STT_SECTION + addend.

	* elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define.
	* elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22.
	* elf/i386.h: Add TLS relocs.

	* scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss.
	* ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for
	output section if necessary.  Handle .tbss.
	(lang_size_sections): Clear _raw_size for .tbss section
	(it allocates space in PT_TLS segment only).
	* ldwrite.c (build_link_order): Build link order for .tbss too.

	* readelf.c (get_segment_type): Add PT_TLS.
	(get_elf_section_flags): Add SHF_TLS.
	(get_dynamic_flags): Optimize.  Add DF_STATIC_TLS.
	(process_dynamic_segment): Use puts instead of printf.
	(get_symbol_type): Support STT_TLS.
	* objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT,
	SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS.
	Add SEC_THREAD_LOCAL.
2002-05-23 13:12:53 +00:00
Alan Modra fac1652d6b * ldemul.c (ldemul_new_vers_pattern): New function.
* ldemul.h (ldemul_new_vers_pattern): Declare.
	(struct ld_emulation_xfer_struct): Add new_vers_pattern.
	* ldlang.c (lang_new_vers_pattern): Call ldemul_new_vers_pattern.
	* emultempl/ppc64elf.em (dotsyms): New static var.
	(gld${EMULATION_NAME}_new_vers_pattern): New function.
	(LDEMUL_NEW_VERS_PATTERN): Define.
	(PARSE_AND_LIST_PROLOGUE): Add OPTION_DOTSYMS, OPTION_NO_DOTSYMS.
	(PARSE_AND_LIST_LONGOPTS): Likewise.
	(PARSE_AND_LIST_ARGS_CASES): Handle them.
	* emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Update
	initialiser.
	* emultempl/armcoff.em: Likewise.
	* emultempl/armelf_oabi.em: Likewise.
	* emultempl/beos.em: Likewise.
	* emultempl/elf32.em: Likewise.
	* emultempl/generic.em: Likewise.
	* emultempl/gld960.em: Likewise.
	* emultempl/gld960c.em: Likewise.
	* emultempl/linux.em: Likewise.
	* emultempl/lnk960.em: Likewise.
	* emultempl/m68kcoff.em: Likewise.
	* emultempl/mipsecoff.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/sunos.em: Likewise.
	* emultempl/ticoff.em: Likewise.
	* emultempl/vanilla.em: Likewise.
2002-05-22 09:04:48 +00:00
Alan Modra c2c01aa78c * ldlang.c (section_already_linked): Call bfd_link_just_syms.
(lang_place_orphans): Abort if just_syms_flag.
2002-05-15 00:19:23 +00:00
Richard Sandiford 9f88b410a0 * ldlang.h (lang_output_section_statement_type): Add update_dot_tree.
(lang_enter_overlay): Remove the last two parameters.
	(lang_leave_overlay): Take them here instead.
	* ldgram.y (memspec_at_opt): Set $$ to null if no region is given.
	(section): Pass LMA and crossref flag to lang_leave_overlay rather
	than lang_enter_overlay.
	* ldlang.c (lang_memory_region_lookup): Return null for null names.
	(lang_output_section_statement_lookup): Initialize update_dot_tree.
	(lang_size_sections_1): Evaluate it.
	(lang_leave_output_section_statement): Rework LMA lookup.
	(overlay_lma, overlay_nocrossrefs): Remove.
	(lang_enter_overlay): Remove LMA and corssref arguments.
	(lang_enter_overlay_section): Don't set the LMA here.
	(lang_leave_overlay): Take LMA and crossref arguments.  Move the '.'
	assignment to the last section's update_dot_tree.  Unconditionally
	use the load and run-time regions specified in the OVERLAY statement.
	Likewise the first section's LMA.  Only set the other sections' LMAs
	when no load region is given.
2002-05-07 11:04:54 +00:00
Kazu Hirata b7a26f91f4 * ld.h: Fix formatting.
* ldexp.c: Likewise.
	* ldfile.c: Likewise.
	* ldlang.c: Likewise.
	* ldmain.c: Likewise.
	* lexsup.c: Likewise.
	* pe-dll.c: Likewise.
2002-05-03 13:48:55 +00:00
Richard Sandiford 7b17f854f7 * ldlang.c (print_assignment): Update print_dot for assignments to ".".
* ldexp.c (exp_print_token): Add "infix_p" argument.
	(exp_print_tree): Update accordingly.
2002-04-30 09:21:27 +00:00
Alan Modra d08a14c385 * ldlang.c (lang_size_sections_1): Don't complain about
SEC_NEVER_LOAD sections having no memory region specified.
2002-04-08 01:01:43 +00:00
Alan Modra fcf0e35b46 * ldlang.c (ldlang_add_undef): If the output bfd has been opened,
add the symbol to the linker hash table immediately.
	(lang_place_undefineds): Split symbol creation out..
	(insert_undefined): ..to here.
2002-03-20 07:49:53 +00:00
Alan Modra 862120bdbe * ldmain.c (main): Move .text readonly flag fudges from here..
* ldlang.c (lang_process): ..to here.
2002-03-18 02:55:51 +00:00
Alan Modra d35a52e2a7 * ldlang.c (lang_check): Remove the word size check added in last
change.  Treat emitrelocations case as for relocatable links.
2002-03-14 10:39:46 +00:00
Alan Modra 30cba02509 * ldlang.c (lang_check): Do relocatable link checks first, so that
warn_mismatch can't override.  Check compatible and word size too.
2002-03-13 02:56:36 +00:00
Alan Modra 2c382fb6f5 Support arbitrary length fill patterns.
* ldexp.h (etree_value_type): Add "str" field.
	(union etree_union): Add "str" to "value" struct.
	(exp_bigintop): Declare.
	(exp_get_fill): Declare.
	* ldexp.c: Include "safe-ctype.h".
	(exp_intop): Set value.str to NULL.
	(exp_bigintop): New function.
	(new_rel): Pass in "str", and set new.str from it.
	(new_rel_from_section): Set new.str to NULL.
	(fold_name): Adjust calls to new_rel.
	(exp_fold_tree): Likewise.
	(exp_get_fill): New function.
	* ldgram.y (struct big_int bigint, fill_type *fill): New.
	(INT): Returns a "bigint".  Adjust all code handling INTs.
	(fill_opt): Returns a "fill".
	(fill_exp): Split out of fill_opt, use for FILL.
	* ldlang.h (struct _fill_type): New.
	(fill_type): Move typedef to ldexp.h.
	(lang_output_section_statement_type): "fill" is now a pointer.
	(lang_fill_statement_type): Likewise.
	(lang_padding_statement_type): Likewise.
	(lang_add_fill): Now takes a "fill_type *" param.
	(lang_leave_output_section_statement): Likewise.
	(lang_do_assignments): Likewise.
	(lang_size_sections): Likewise.
	(lang_leave_overlay_section): Likewise.
	(lang_leave_overlay): Likewise.
	* ldlang.c: Include ldgram.h after ldexp.h.
	(lang_output_section_statement_lookup): Adjust for fill_type change.
	(print_fill_statement): Likewise.
	(print_padding_statement): Likewise.
	(insert_pad): Now takes a "fill_type *" arg.
	(size_input_section): Likewise.
	(lang_size_sections_1): Likewise.
	(lang_size_sections): Likewise.
	(lang_do_assignments): Likewise.
	(lang_add_fill): Likewise.
	(lang_leave_output_section_statement): Likewise.
	(lang_leave_overlay_section): Likewise.
	(lang_leave_overlay): Likewise.
	Adjust all callers of the above function.
	* ldlex.l: Include ldgram.h after ldexp.h.  Allow hex numbers
	starting with "0X" as well as "0x".  Return bigint.str for hex
	numbers starting with "0x" or "0X", zero bigint.str otherwise.
	Always use base 16 for numbers starting with "$".
	* ldmain.c: Include ldgram.h after ldexp.h.
	* ldwrite.c (build_link_order): Use bfd_data_link_order in place
	of bfd_fill_link_order.
	* pe-dll.c: Adjust lang_do_assignments calls.
	* emultempl/elf32.em: Likewise.
	* emultempl/hppaelf.em: Likewise.
	* emultempl/ppc64elf.em: Likewise.
	* emultempl/beos.em: Include ldgram.h after ldexp.h, adjust
	lang_add_assignment call.
	* emultempl/pe.em: Likewise.
2002-02-15 02:11:05 +00:00
Alan Modra 313e35ee7c * ld.texinfo (VERSION scripts): Symbol names are globbing patterns.
* ldgram.y (lang_new_vers_regex):  Rename to lang_new_vers_pattern;
	the pattern in question is not a regexp.
	* ldlang.c:  Likewise.
	* ldlang.h:  Likewise.
	* ldlex.l (V_IDENTIFIER):  Allow '[', ']', '-', '!', and '^' also.
2002-02-14 04:24:33 +00:00
Jakub Jelinek 2d20f7bf67 * ldlex.l (DATA_SEGMENT_ALIGN, DATA_SEGMENT_END): New tokens.
* ldgram.y (DATA_SEGMENT_ALIGN, DATA_SEGMENT_END): New tokens.
	(exp): Add DATA_SEGMENT_ALIGN (exp, exp) and DATA_SEGMENT_END (exp).
	* ldexp.c (exp_data_seg): New variable.
	(exp_print_token): Handle DATA_SEGMENT_ALIGN and DATA_SEGMENT_END.
	(fold_binary): Handle DATA_SEGMENT_ALIGN.
	(exp_fold_tree): Handle DATA_SEGMENT_END.
	Pass allocation_done when recursing instead of hardcoding
	lang_allocating_phase_enum.
	* ldexp.h (exp_data_seg): New.
	* ldlang.c (lang_size_sections_1): Renamed from lang_size_sections.
	(lang_size_sections): New.
	* ld.texinfo (DATA_SEGMENT_ALIGN, DATA_SEGMENT_END): Document.
	* scripttempl/elf.sc: Use DATA_SEGMENT_ALIGN and DATA_SEGMENT_END
	if COMMONPAGESIZE is defined.
	* emulparams/elf_i386.sh (COMMONPAGESIZE): Set to 4K.
	* emulparams/elf32_sparc.sh (COMMONPAGESIZE): Set to 8K.
	* emulparams/elf64_sparc.sh (COMMONPAGESIZE): Set to 8K.
	* emulparams/elf64alpha.sh (COMMONPAGESIZE): Set to 8K.
	* emulparams/elf64_ia64.sh (COMMONPAGESIZE): Set to 16K for shared
	libraries only.
2002-02-12 14:50:08 +00:00
Alan Modra 1e28151506 * ldlang.c (entry_section): New initialised variable.
(lang_finish): Use it.
	* ldlang.h (entry_section): Declare.
	* emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Set
	entry_section to ".opd".
2002-02-10 10:55:23 +00:00
Hans-Peter Nilsson e3dc884769 * ldlang.c (lang_reset_memory_regions): Rename from
reset_memory_regions.  Change all callers.  Make public.
	* ldlang.h (lang_reset_memory_regions): Prototype.
	* emultempl/elf32.em (gld${EMULATION_NAME}_finish): Call
	lang_reset_memory_regions before lang_size_sections.
2002-02-05 06:52:17 +00:00
Alexandre Oliva 34efb44947 * ldlang.c (walk_wild_section): Exclude object file if enclosing
archive is excluded.
2002-01-08 14:56:09 +00:00
Jakub Jelinek 6b9b879a02 * ldgram.y (vers_node): Support anonymous version tags.
* ldlang.c (lang_register_vers_node): Ensure anonymous version
	tag is not defined together with non-anonymous versions.
	* ld.texinfo: Document it.

	* elflink.h (size_dynamic_sections): Skip anonymous version tag.
	(elf_link_assign_sym_version): Don't count anonymous version tag.
2001-12-18 12:15:35 +00:00
Alan Modra abc6ab0a54 * ldlang.c (map_input_to_output_sections): Replace "break"
accidentally removed with 2001-08-03 change.
	(lang_gc_sections_1): Likewise.
2001-11-21 01:13:15 +00:00
Alan Modra 2181f54fd8 * ldlang.c (walk_wild_section): Move sec == NULL case out of loop. 2001-11-20 15:31:10 +00:00
Alan Modra 6e814ff881 * ldlang.c (lang_size_sections): Keep a valid output_offset field
for padding statements.
2001-10-31 01:12:26 +00:00
Kazu Hirata ca0c1d3ede * ldlang.c: Fix a comment typo. 2001-10-29 22:36:32 +00:00
Alan Modra 4818e05fe5 From John Reiser <jreiser@BitWagon.com>
* ldlang.c (lang_common): Conditionally inhibit Common allocation.
	* lexsup.c: Add --no-define-common commandline option.
	* ldgram.y: Add INHIBIT_COMMON_ALLOCATION script command.
	* ldlex.l: Likewise.
	* ld.h: Add command_line.inhibit_common_definition.
	* ldmain.c (main): Initialize.
	* ld.texinfo: Document.
2001-09-29 12:57:54 +00:00
Alan Modra 862517b650 * section.c (struct sec): Remove kept_section.
(STD_SECTION): Remove kept_section initialisation.
	(bfd_make_section_anyway): Here too.
	* ecoff.c (bfd_debug_section): Remove kept_section initialisation.
	* cofflink.c (_bfd_coff_link_input_bfd): Don't test kept_section.
	* elflink.h (elf_link_input_bfd): Set discarded link-once section
	symbols to zero, and remove all code involved with kept_section
	and tracking section symbol values.
	* bfd-in2.h: Regenerate.
	* configure.in: Bump version number.
	* configure: Regenerate.

	* ldlang.c (section_already_linked): Remove assignment to kept_section.
2001-09-29 12:07:01 +00:00
H.J. Lu 3882b01078 Locale changes from Bruno Haible <haible@clisp.cons.org>. 2001-09-19 05:33:36 +00:00
Alan Modra 2af022575a * ldlang.c (insert_pad): Fix typos in last patch. 2001-08-20 03:09:07 +00:00
Alan Modra bba1a0c062 * ldlang.c: When traversing lang_statement_union_type lists,
consistently use "header.next" rather than "next".
	* mpw-eppcmac.c: Likewise.
	* emultempl/beos.em: Likewise.
	* emultempl/hppaelf.em: Likewise.
	* emultempl/pe.em: Likewise.
	* ldlang.h (union lang_statement_union): Remove "next" field.
2001-08-20 02:14:50 +00:00
Alan Modra c0c330a70f * ldlang.c (insert_pad): Use offsetof macro.
(lang_size_sections): Always neuter padding statements.
	* emultempl/hppaelf.em (hppaelf_delete_padding_statements): Delete.
2001-08-20 01:21:08 +00:00
Alan Modra b3327aadfd * ldlang.c (insert_pad): Make use of an existing pad statement if
available.  Move code calculating alignment, adjusting section
	alignment power, and adjusting dot to ..
	(size_input_section): .. here.  Remove unused relax param.
	(lang_size_sections): Change boolean `relax' param to boolean *.
	Adjust call to size_input_section.  Make use of insert_pad to
	place pad after the assignment statement.  If relaxing, zap
	padding statements.
	(reset_memory_regions): Reset output_bfd section sizes too.
	(relax_again): Move to..
	(lang_process): ..here.  Adjust call to lang_size_sections, and
	remove duplicated code.
	* ldlang.h (lang_size_sections): Change `relax' param to boolean *.
2001-08-18 14:54:26 +00:00
Alan Modra 39dcfe18ca (wild_doit): Rename to lang_add_section. 2001-08-14 02:01:31 +00:00
Alan Modra b6bf44ba1b * ld.texinfo (Input Section Basics): Clarify ordering of output
sections.
	* ldlang.c (callback_t): Add wildcard_list param.
	(walk_wild_section): Remove "section" param.  Rewrite for
	lang_wild_statement_type change.  Remove unique_section_p test.
	(walk_wild_file): Remove "section" param.
	(walk_wild): Remove "section" and "file" params.
	(lang_gc_wild): Likewise.
	(wild): Likewise.  Modify for lang_wild_statement_type change.
	(wild_sort): Likewise.  Add "sec" param.
	(gc_section_callback): Likewise.
	(output_section_callback): Likewise.  Do unique_section_p test.
	(map_input_to_output_sections): Modify call to wild.
	(lang_gc_sections_1): Likewise.
	(print_wild_statement): Modify for lang_wild_statement_type
	change.
	(lang_add_wild): Replace filename, filenames_sorted param with
	filespec.  Replace section_name, sections_sorted,
	exclude_filename_list with section_list.
	* ldlang.h (lang_add_wild): Here too.
	(lang_wild_statement_type): Replace section_name, sections_sorted,
	and exclude_filename_list with section_list.
	* ldgram.y (current_file): Delete.
	(%union): Add wildcard_list.
	(file_NAME_list): Set type to wildcard_list.  Build a linked list
	rather than calling lang_add_wild for each entry.
	(input_section_spec_no_keep): Call lang_add_wild here instead.
	* ld.h (struct wildcard_list): Declare.
	* mri.c (mri_draw_tree): Modify to suit new lang_add_wild.
2001-08-03 01:11:21 +00:00
Nick Clifton 1545243be0 If a region is specified assign it to all sections inside the overlay unless they have been assigned to the own, non-default, memory region. 2001-07-19 16:21:39 +00:00
Hans-Peter Nilsson 429d935daa * ldlang.c (lang_check): Emit fatal error if relocatable link
between different object flavours with relocations in input.
2001-06-19 19:57:39 +00:00
H.J. Lu 9bf03accc3 2001-06-19 H.J. Lu <hjl@gnu.org>
* ldlang.c (lang_check): Revert the change mode on 2001-06-15.
2001-06-19 14:39:02 +00:00
H.J. Lu 6f9efd9751 2001-06-18 H.J. Lu <hjl@gnu.org>
* ldlang.c (init_os): Add the newline to the einfo call.
	(lang_check): Likewise.
	(lang_do_version_exports_section): Likewise.
2001-06-18 17:23:52 +00:00
Hans-Peter Nilsson 7e66c3f530 * ldlang.c (lang_check): Emit fatal error if relocatable link
between different object flavours.
2001-06-15 13:13:46 +00:00
Nick Clifton 6770ec8c9e Chnage load_symbols() to a boolean function 2001-06-15 09:00:11 +00:00
Alan Modra 8529105a0e * ldlang.c (record_bfd_errors): Remove.
* emultempl/aix.em: Fix copyright dates.
2001-06-08 01:58:20 +00:00
H.J. Lu 5929ebc003 2001-05-31 H.J. Lu <hjl@gnu.org>
* ldlang.c (open_input_bfds): Don't change the bfd error
	handler whilst loading symbols.
2001-05-31 21:14:59 +00:00
Alan Modra d1778b88f8 Add a flag to asection, linker_has_input, and use it to reliably
determine whether an input section is the first one assigned to
an output section.
2001-05-17 03:58:45 +00:00
Jakub Jelinek 8550eb6e64 * merge.c (struct sec_merge_hash_entry): Add u.entsize and u.suffix
fields, change sec into secinfo.
	(struct sec_merge_info): Add chain, remove last fields.
	(struct sec_merge_sec_info): Add next, sec, psecinfo fields.
	(sec_merge_hash_lookup): If lookup could not use a string only
	because it has bad alignment, mark the old string for deletion.
	(sec_merge_add): Add secinfo argument. Don't compute entry's
	position, instead record the section.
	(sec_merge_emit): Update for the sec into secinfo change in
	struct sec_merge_hash_entry.
	(_bfd_merge_section): Only record the section for merging, defer
	putting strings into the hash table.
	(cmplengthentry, last4_eq, last_eq, record_section, merge_strings,
	_bfd_merge_sections): New functions.
	(_bfd_merged_section_offset): Update for the sec_merge_hash_entry
	changes.
	* libbfd-in.h (_bfd_merge_sections): Add prototype.
	(_bfd_nolink_bfd_merge_sections): Define.
	* libbfd.h: Likewise.
	(bfd_generic_merge_sections): Add prototype.
	* targets.c (BFD_JUMP_TABLE_LINK): Add _bfd_merge_sections.
	(struct bfd_target): Likewise.
	* bfd.c (bfd_merge_sections): Define.
	* bfd-in2.h: Rebuilt.
	* elf.c (_bfd_elf_merge_sections): New function.
	* elf-bfd.h (_bfd_elf_merge_sections): Add prototype.
	* elfxx-target.h (bfd_elfNN_bfd_merge_sections): Define.
	* reloc.c (bfd_generic_merge_sections): New function.
	* vms.c (vms_bfd_merge_sections): New function.
	* aout-adobe.c (aout_32_bfd_merge_sections): Define.
	* aout-target.h (MY_bfd_merge_sections): Define.
	* aout-tic30.c (MY_bfd_merge_sections): Define.
	* binary.c (binary_bfd_merge_sections): Define.
	* bout.c (b_out_bfd_merge_sections): Define.
	* coff-alpha.c (_bfd_ecoff_bfd_merge_sections): Define.
	* coffcode.c (coff_bfd_merge_sections): Define.
	* coff-mips.c (_bfd_ecoff_bfd_merge_sections): Define.
	* i386msdos.c (msdos_bfd_merge_sections): Define.
	* i386os9k.c (os9k_bfd_merge_sections): Define.
	* ieee.c (ieee_bfd_merge_sections): Define.
	* ihex.c (ihex_bfd_merge_sections): Define.
	* nlm-target.h (nlm_bfd_merge_sections): Define.
	* oasys.c (oasys_bfd_merge_sections): Define.
	* ppcboot.c (ppcboot_bfd_merge_sections): Define.
	* som.c (som_bfd_merge_sections): Define.
	* srec.c (srec_bfd_merge_sections): Define.
	* tekhex.c (tekhex_bfd_merge_sections): Define.
	* versados.c (versados_bfd_merge_sections): Define.
	* xcoff-target.h (_bfd_xcoff_bfd_merge_sections): Define.

	* ldlang.c (lang_process): Call bfd_merge_sections.
2001-05-11 12:23:48 +00:00
H.J. Lu d1b2b2dcb9 2001-05-02 H.J. Lu <hjl@gnu.org>
* ldfile.c: Include "libiberty.h".
	* ldlex.l: Likewise.

	* ldmisc.c (buystring): Removed.
	* ldmisc.h: Likewise.

	* ldfile.c: Replace buystring with xstrdup.
	* ldlang.c: Likewise.
	* ldlex.l: Likewise.
	* ldmain.c: Likewise.
	* ldmisc.c: Likewise.
	* lexsup.c: Likewise.
	* mpw-eppcmac.c: Likewise.
2001-05-02 16:42:55 +00:00
Nick Clifton 884fb58eeb Give emulation a chance to process unrecognized file before fatal error is
reported, not after.
2001-04-28 18:00:10 +00:00
Jakub Jelinek f5fa8ca231 bfd/
* libbfd-in.h (_bfd_merge_section): New.
	(_bfd_write_merged_section): New.
	(_bfd_merged_section_offset): New.
	* libbfd.h: Rebuilt.
	* linker.c (_bfd_generic_link_output_symbols): Handle
	discard_sec_merge.
	* aoutx.h (aout_link_write_symbols): Likewise.
	* pdp11.c (aout_link_write_symbols): Likewise.
	* elflink.h (elf_link_add_object_symbols): Call _bfd_merge_section.
	(elf_bfd_final_link): Adjust global symbols pointing into SEC_MERGE
	sections.
	(elf_link_sec_merge_syms): New.
	(elf_link_input_bfd): Call _bfd_merged_section_offset
	and _bfd_write_merged_section.
	Handle discard_sec_merge.
	* elf-bfd.h (struct elf_link_hash_table): Add merge_info
	field.
	(struct bfd_elf_section_data): Likewise.
	* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_MERGE and
	SEC_STRINGS section flags and entsize from their ELF counterparts.
	(_bfd_elf_link_hash_table_init): Initialize merge_info.
	(elf_fake_sections): Set SHF_MERGE, SHF_STRINGS and sh_entsize
	from their BFD counterparts.
	* merge.c: New file.
	* Makefile.am: Add strtab.lo.
	* Makefile.in: Rebuilt.
include/
	* bfdlink.h (bfd_link_discard): Add discard_sec_merge.
gas/
	* config/obj-elf.c (obj_elf_change_section): Add entsize argument,
	handle SHF_MERGE and SHF_STRINGS.
	(obj_elf_parse_section_letters): Set SHF_MERGE and SHF_STRINGS.
	(obj_elf_section): Allow additional argument specifying entity size.
	* write.c (adjust_reloc_syms): Keep relocations against local symbols
	in SEC_MERGE sections.
ld/
	* ldmain.c (main): Default to discard_sec_merge.
	* lexsup.c (OPTION_DISCARD_NONE): Define.
	(ld_options): Add --discard-none.
	(parse_args): Handle OPTION_DISCARD_NONE.
	* ldlang.c (wild_doit): SEC_MERGE should be set in the output
	section only if SEC_MERGE and SEC_STRINGS flags and entsize of
	all its input sections match.
2001-04-13 00:34:36 +00:00
Nick Clifton a2b64bede3 Fixtypos in ChangeLogs, fix copyright dates in files 2001-03-13 06:14:29 +00:00
Nick Clifton 1276aefac0 BFD: Catch & report unhandled PE section flags.
LD: Catch BFD errors whilst loading symbols and do not produce an executable.
2001-02-27 01:38:06 +00:00
Alan Modra 02aa14fb32 (lang_leave_overlay): Don't set lma_region when load_base is specified. 2001-01-25 02:31:42 +00:00
Alan Modra c1eb148815 Only set lma_region from the default for the first section
of a group of overlay sections.
2001-01-23 11:48:28 +00:00
H.J. Lu b92473047e 2001-01-16 H.J. Lu <hjl@gnu.org>
* ldlang.c (lang_check): Merge the private data only if the
	input file has contents.
2001-01-16 21:04:29 +00:00
Alan Modra 577a062318 Extend "ld --unique" functionality. 2001-01-14 04:36:35 +00:00
Nick Clifton 037849a9a0 Revert the last beautification with "innocent" whitespace,
it breaks the K&R C preprocessor.
2000-12-13 18:28:52 +00:00
Nick Clifton 2be3aa031f Add support for x86_64-*-linux-gnu* target 2000-11-30 19:30:33 +00:00
Alan Modra 24376d1b58 Another try at correcting relocations against discarded
link-once section symbols.
2000-10-12 03:44:51 +00:00
Kazu Hirata 89cdebba13 2000-10-09 Kazu Hirata <kazu@hxi.com>
* ldcref.c: Fix formatting.
	* ldctor.h: Likewise.
	* ldemul.c: Likewise.
	* ldemul.h: Likewise.
	* ldexp.c: Likewise.
	* ldexp.h: Likewise.
	* ldfile.c: Likewise.
	* ldfile.h: Likewise.
	* ld.h: Likewise.
	* ldlang.c: Likewise.
	* ldlang.h: Likewise.
	* ldmain.c: Likewise.
2000-10-09 15:09:17 +00:00
Kazu Hirata 08da4cac4a 2000-10-05 Kazu Hirata <kazu@hxi.com>
* ldlang.c: Fix formatting.
2000-10-05 13:03:30 +00:00
Kazu Hirata 4de2d33d1b 2000-09-29 Kazu Hirata <kazu@hxi.com>
* ldcref.c: Fix formatting.
	* ldctor.c: Likewise.
	* ldemul.c: Likewise.
	* ldexp.c: Likewise.
	* ldfile.c: Likewise.
	* ldlang.c: Likewise.
2000-09-29 11:18:18 +00:00
Alan Modra 5f992e6228 A tidy of ld/ldlang.c, and add missing Makefile dependencies
I should have added with the 2000-07-28 patch.
2000-09-05 03:21:16 +00:00
Nick Clifton c13b1b775b When choosing the target for a particular endianness, do nothing if the target
is not supported.
2000-08-25 20:44:09 +00:00
Alan Modra b71e277823 Remove some forward declarations in ldemul.h and ldfile.h, and
re-arrange header include order.
Fix shadowing warnings in ldlang.h
Fix compile errors in mpw-elfmips.c
2000-07-11 03:42:41 +00:00
Timothy Wall 74459f0e3e tic54x/ibmc54xdsp target for ld. 2000-06-20 13:29:07 +00:00
H.J. Lu cd4c806ac9 2000-05-10 H.J. Lu <hjl@gnu.org>
* ldlang.c (open_input_bfds): Don't load the same file within
	a group again if the whole archive has been loaded already.
2000-05-10 23:12:35 +00:00
Alan Modra aea4bd9d34 place_orphan optimisations 2000-04-25 05:14:16 +00:00
Alan Modra f6af82bd44 This lot mainly cleans up `comparison between signed and unsigned' gcc
warnings.  One usused var, and a macro parenthesis fix too.  Also check
input sections are elf when doing gc in elflink.h.
2000-02-21 12:01:27 +00:00
Timothy Wall 562d3460fb Add LMA memory region functionality. 2000-02-16 18:53:32 +00:00
Timothy Wall 9e4ed18ce8 These snippets were missed in the previous bytes vs octets patch to
the linker.
2000-02-09 14:42:48 +00:00
Timothy Wall 32edc927fa Fix typo in ALIGN_N usage. 2000-02-04 19:49:21 +00:00
Timothy Wall 4cbfc3ac19 Add octets vs bytes functionality to LD. 2000-02-03 18:24:46 +00:00
Nick Clifton 13392b77a7 fix typo in comment. 2000-01-21 17:44:51 +00:00
Nick Clifton cce4c4c5bd Apply H.J.'s patch to fix NOLOAD section sizes and dot updates 2000-01-18 23:58:58 +00:00
Catherine Moore 18625d5459 * ld.h (wildcard_spec): Change exclude_name to exclude_name_list.
(name_list): New.
        * ld.texinfo (EXCLUDE_FILE): Update documentation.
        * ldgram.y (wildcard_spec): Support a list of excluded_files.
        (exclude_name_list): New.
        ldlang.c (walk_wild_section): Support list of excluded files.
        (print_wild_statement): Likewise.
        (lang_add_wild): Likewise.
        * ldlang.h (lang_wild_statement_type): Likewise.
        * scripttempl/elf.sc (OTHER_EXCLUDE_FILES): Support.
2000-01-05 14:12:23 +00:00
Nick Clifton 50e05050cd Fix bug in previous delta 1999-11-24 11:43:11 +00:00
Nick Clifton 33275c22c0 Do not check sections without a LOAD attribute for overlap 1999-11-23 14:13:07 +00:00
Ian Lance Taylor 9503fd8735 1999-11-01 Steve Chamberlain <sac@pobox.com>
* ldlang.c (section_already_linked): Rework to use hash table.
	(already_linked_newfunc): New function.
	(already_linked_table_init): New function.
	(already_linked_table_free): New function.
	(lang_process): Initialize and free the already_linked hash table.
1999-11-01 23:37:48 +00:00
Ian Lance Taylor bb8fe706a0 1999-09-12 Donn Terry <donn@interix.com>
* ldlang.c (section_already_linked): Use comdat information if it
	is available.
1999-09-12 16:10:00 +00:00
Ian Lance Taylor 1b69a0bfca * ldlang.c (open_output): Change local variable desired_endian
from int to enum bfd_endian.
1999-09-12 14:50:15 +00:00
Ian Lance Taylor fe9edd2275 From Wally Iimura <iimura@microunity.com>:
* ldlang.c (lang_size_sections): When checking whether an address
	is within a region, don't get confused by wrapping around at the
	end of the address space.
1999-08-09 06:14:09 +00:00
Ian Lance Taylor 667f51773f * ldlang.c (wild_doit): Update for renaming of SEC_SHORT to
SEC_SMALL_DATA.
1999-08-09 03:22:27 +00:00
Doug Evans 7c83b342ee * ldlang.c (lang_gc_sections): Only handle the start symbol
specially if there is one.
1999-07-20 22:27:31 +00:00
Nick Clifton e50d80767c Improve selection of output format 1999-07-19 14:57:03 +00:00
Richard Henderson 9e41f97317 * ldlang.c (wild_doit): Copy SEC_SHORT to output section. 1999-07-14 16:45:13 +00:00