argument and emits the string followed by a comma and then the length of
the string.
(CONST_STRNEQ): New macro. Checks to see if a variable string has a constant
string as its initial characters.
(CONST_STRNCPY): New macro. Copies a constant string to the start of a
variable string.
* bfd-in2.h: Regenerate.
* <remainign files>: Make use of the new macros.
PR ld/2290
* NEWS: Updated for the Linux linker search order change.
* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Call
gld${EMULATION_NAME}_check_ld_so_conf before checking default
search directories for DT_NEEDED entries.
* ldexp.h: ..here. Add lang_mark_phase_enum.
(node_type): Remove etree_undef and etree_unspec.
(exp_data_seg): Delete.
(struct ldexp_control, expld): New.
(invalid, exp_mark_used_section): Delete.
(exp_fold_tree, exp_get_vma, exp_get_value_int, exp_get_fill,
exp_get_abs_int): Update prototypes.
* ldexp.c (assigning_to_dot): Delete.
(expld): Define.
(make_abs): Operate directly on expld.result. Update all callers.
(new_abs): Likewise. Return void.
(new_rel_from_abs): Rename from new_rel_from_section.
(new_rel, new_rel_from_abs): Operate on expld.result and return void.
Update all callers.
(fold_unary): Operate on expld.result and return void. Remove
"current_section", "allocation_done", "dot", "dotp" and "mark_used"
params. Update all callers.
(fold_binary, fold_trinary, fold_name, exp_fold_tree_1): Likewise.
(fold_unary <ALIGN_K>): Ensure alignment is absolute.
(fold_unary <ABSOLUTE>): Use make_abs.
(fold_unary <DATA_SEGMENT_END>): Evaluate mark_phase as for
allocating_phase.
(fold_binary <DATA_SEGMENT_ALIGN, DATA_SEGMENT_RELRO_END, >): Ditto.
(fold_binary <'%','/'>): Don't error if marking.
(fold_name <SIZEOF_HEADERS>): Don't call bfd_sizeof_headers when
marking.
(fold_name <NAME>): Remove FIXME; -R is handled correctly. Don't
error when marking.
(fold_name <ADDR, LOADADDR, SIZEOF>): Don't set SEC_KEEP.
(exp_fold_tree_1): Don't error when marking.
(exp_fold_tree_1 <etree_rel>): Evaluate in all phases except first.
(exp_fold_tree_1 <etree_assign to dot>): Don't check for NULL
current section, instead check for NULL dotp.
(exp_fold_tree_1 <etree_provide>): Don't evaluate the assignment
source unless the symbol is referenced and undefined.
(exp_fold_tree): Remove "allocation_done" and "dot" params. Save
params to expld.
(exp_fold_tree_no_dot): Remove "current_section", "allocation_done
and "mark_used" params. Save params to expld. Update all callers.
(exp_assop): Do without temp var.
(exp_print_tree <etree_undef>): Delete code.
(exp_get_vma): Remove "allocation_done" param. Correct error return.
(exp_get_fill, exp_get_abs_int): Likewise.
(exp_get_value_int): Remove "allocation_done" param.
(exp_mark_used_section): Delete.
* ldgram.y (fill_exp): Update exp_get_fill call.
(origin_spec, length_spec): Update exp_get_vma call.
* ldlang.c (lang_init): Don't bother clearing lang_statement_iteration.
(lang_mark_used_section_1, lang_mark_used_section): Delete.
(strip_excluded_output_sections): Call one_lang_size_sections_pass in
marking mode. Merge old lang_mark_used_section code. Correct handling
of output sections with excluded input sections and data statements.
Don't drop non-zero sized sections. Don't zap os->bfd_section.
Do set SEC_EXCLUDE when appropriate.
(print_output_section_statement): Update for changed ldexp.c
interface.
(print_assignment, lang_size_sections_1): Likewise.
(lang_do_assignments_1, lang_enter_output_section_statement): Likewise.
(lang_new_phdr, lang_record_phdrs): Likewise.
(lang_size_sections): Likewise.
(insert_pad): Use following statement if it is a pad, rather than
creating a new one.
(lang_size_sections_1 <lang_output_section_statement_enum>): Do
process ignored output section to set vma and lma, but don't
update dot for these sections. Don't error if marking.
(lang_size_sections_1 <lang_assignment_statement_enum>): Don't
update dot for ignored sections.
(lang_size_sections_1 <lang_data_statement_enum>): Don't mark absolute
section with SEC_ALLOC.
(one_lang_size_sections_pass): New function.
(lang_size_sections): Remove first five params. Set expld.phase on
entry and exit. Use one_lang_size_sections_pass.
(lang_do_assignments): Remove all params. Update all callers.
(lang_reset_memory_regions): Clear os->processed for all output
section statements.
* ldlang.h (lang_do_assignments): Update prototype.
(lang_size_sections): Likewise.
(one_lang_size_sections_pass): Declare.
* pe-dll.c (pe_dll_fill_sections, pe_exe_fill_sections): Update
lang_size_sections and lang_do_assignments calls.
* emultempl/elf32.em (layout_sections_again): Likewise.
* emultempl/ppc64elf.em (ppc_before_allocation): Use
one_lang_size_sections_pass.
* emultempl/elf32.em (gld${EMULATION_NAME}_provide_bound_symbols):
Use the first SEC_ALLOC section which isn't SEC_READONLY or the
last SEC_ALLOC section if such a section doesn't exist.
2005-03-22 H.J. Lu <hongjiu.lu@intel.com>
* bfd-in.h (_bfd_elf_provide_symbol): New.
* bfd-in2.h: Regenerated.
* elf32-ppc.c (set_linker_sym): Moved to elflink.c.
(ppc_elf_set_sdata_syms): Call _bfd_elf_provide_symbol instead
of set_linker_sym.
* elflink.c (_bfd_elf_provide_symbol): New. Moved and renamed
from elf32-ppc.c.
ld/
2005-03-22 H.J. Lu <hongjiu.lu@intel.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_provide_bound_symbols): New
(gld${EMULATION_NAME}_finish): Call
gld${EMULATION_NAME}_provide_bound_symbols to provide
__preinit_array_start, __preinit_array_end, __init_array_start,
__init_array_end, __fini_array_start and __fini_array_end.
* scripttempl/elf.sc: Don't provide __preinit_array_start,
__preinit_array_end, __init_array_start, __init_array_end,
__fini_array_start nor __fini_array_end.
* elflink.c (elf_link_add_object_symbols): Set SEC_EXCLUDE on
.gnu.warning.* sections.
ld/
* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Set
SEC_EXCLUDE on .gnu.warning sections.
* configure: Regenerated.
* emultempl/elf32.em (<glob.h>): Do not include if HAVE_GLOB is
not defined.
(gld${EMULATION_NAME}_parse_ld_so_conf_include): Do not use glob
if HAVE_GLOB is not defined.
* elflink.c (bfd_elf_record_link_assignment): Do "provide" symbol
lookup here. Set to new before calling bfd_link_repair_undef_list.
(elf_smash_syms): Check that u.undef.weak isn't the not_needed bfd.
ld/
emultempl/elf32.em (gld${EMULATION_NAME}_find_exp_assignment): Don't
look up symbol for etree_provide here.
* elflink.c (elf_link_add_object_symbols): Don't create link dynamic
sections immediately when linking shared libs. Instead, wait until
we know a lib is needed.
(_bfd_elf_link_create_dynstrtab): Extract from..
(_bfd_elf_link_create_dynamic_sections_): ..here.
(elf_add_dt_needed_tag): Call _bfd_elf_link_create_dynstrtab and
_bfd_elf_link_create_dynamic_sections. Add abfd param. Allow
for non-existent .dynamic.
(elf_link_output_extsym): Don't complain about undefined symbols
in as-needed dynamic libs that aren't actually linked.
ld/
* emultempl/elf32.em (gld${EMULATION_NAME}_try_needed): Formatting.
(gld${EMULATION_NAME}_after_open): Ignore needed libs if they were
only needed by an as-needed lib that didn't get linked.
PR 63
* ldlang.h (lang_output_section_statement_type): Make "next" a
struct lang_output_section_statement_struct *.
(struct orphan_save): Move from elf32.em. Add "name" and "flags".
(lang_output_section_find_by_flags, lang_insert_orphan): Declare.
* ldlang.c (lang_output_section_find_1): Adjust for changed
output_section_statement "next".
(strip_excluded_output_sections): Likewise.
(lang_record_phdrs): Likewise.
(lang_output_section_find_by_flags): New function.
(output_prev_sec_find): Move from pe.em. Adjust iterator.
(lang_insert_orphan): New function. Tail end of elf32.em's
place_orphan merged with that from pe.em. Allow bfd_section to
be placed first. New heuristic for placing new output section
statement in existing script, and accompanying split of __start
symbol alignment into a separate assignment to dot.
(lang_add_section): Consistently use output->bfd_section rather than
an alias, section->output_section.
(map_input_to_output_sections): Rename overly long arg. Move
initialization of data_statement output section to here..
(lang_check_section_addresses): ..from here.
(print_assignment): Correct printing of etree_assert.
(print_all_symbols): Don't bomb if userdata is NULL.
(IGNORE_SECTION): Rearrange.
* emultempl/elf32.em (output_rel_find): Adjust interator.
(output_prev_sec_find): Delete.
(struct orphan_save): Delete.
(gld${EMULATION_NAME}_place_orphan): Cater for zero bfd_section
flags without creating a duplicate output section statement.
Revise code holding history of various orphan section placements.
Allow orphan sections to place before script specified output
sections. Call lang_output_section_find_by_flags when placement
by name fails. Use lang_insert_orphan.
* emultempl/mmo.em (output_prev_sec_find): Delete.
(struct orphan_save): Delete.
(mmo_place_orphan): Revise code holding history of orphan placement.
Allow orphans to place before existing output sections. Use
lang_insert_orphan.
* emultempl/pe.em (output_prev_sec_find): Delete.
(struct orphan_save): Delete.
(gld_${EMULATION_NAME}_place_orphan): Revise to suit use of
lang_insert_orphan.
ld/testsuite/
* ld-scripts/overlay-size.d: Update for changed orphan section
placement.
* ld-mmix/bpo-18.d: Likewise.
(gld${EMULATION_NAME}_parse_ld_so_conf,
gld${EMULATION_NAME}_parse_ld_so_conf_include): New functions.
(gld${EMULATION_NAME}_check_ld_so_conf): Use them.
2004-07-19 H.J. Lu <hongjiu.lu@intel.com>
* bfd-in.h (dynamic_lib_link_class): Add DYN_NO_ADD_NEEDED and
DYN_NO_NEEDED.
(bfd_elf_get_dyn_lib_class): New prototype.
* elf.c (bfd_elf_get_dyn_lib_class): New function.
* elflink.c (elf_link_add_object_symbols): Check DYN_AS_NEEDED,
DYN_DT_NEEDED and DYN_NO_NEEDED bits to see if a DT_NEEDED
entry is needed. Issue an error if a DT_NEEDED entry is needed
for a file marked DYN_NO_NEEDED.
(elf_link_check_versioned_symbol): Check the DYN_DT_NEEDED bit
for DT_NEEDED tags.
* bfd-in2.h: Regenerated.
ld/
2004-07-19 H.J. Lu <hongjiu.lu@intel.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_load_symbols): Also
check the add_needed field.
(dt_needed): New struct.
(gld${EMULATION_NAME}_try_needed): Change the first argument
to a pointer to struct dt_needed. Check the DYN_NO_ADD_NEEDED
bit in the file where the DT_NEEDED entry comes from.
(gld${EMULATION_NAME}_search_needed): Change the second
argument to a pointer to struct dt_needed.
(gld${EMULATION_NAME}_check_ld_so_conf): Updated.
(gld${EMULATION_NAME}_after_open): Likewise.
* ld.texinfo: Add --add-needed document.
* ldlang.c (new_afile): Set p->add_needed.
* ldlang.h (lang_input_statement_type): Add add_needed field.
* ldmain.h (add_needed): Declare.
* ldmain.c (add_needed): New global var.
* lexsup.c (option_values): Add OPTION_ADD_NEEDED and
OPTION_NO_ADD_NEEDED.
(ld_options): Likewise.
(parse_args): Handle them.
* elf.c (_bfd_elf_make_section_from_shdr): Don't set SEC_EXCLUDE
for SHT_GROUP sections.
ld/
* ldlang.c (lang_add_section): Set SEC_EXCLUDE for SEC_GROUP
sections when doing a final link. Clear SEC_EXCLUDE when doing
a relocable link, except for SEC_DEBUGGING sections.
* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Use the
same condition here to drop SEC_EXCLUDE orphan sections.
hash table type rather than testing creator flavour.
* emultempl/hppaelf.em (hppaelf_create_output_section_statements):
Only create stub_file bfd if hash table creator is as expected.
(gld${EMULATION_NAME}_finish): Test stub_file.
.rel.dyn before other reloc sections. Don't stop looking for reloc
sections on finding one that isn't allocated. Match .rel even when
placing .rela and vice versa, when setting last_rel and
last_rel_alloc for the first time. If no reloc sections in script,
prefer allocated section over non-alloc.
(gld${EMULATION_NAME}_place_orphan): Handle orphan .rel.dyn.
reloc sections just before .rel.plt/.rela.plt.
(gld${EMULATION_NAME}_place_orphan <.rel>): Remove combreloc code.
Only put loadable reloc sections in hold_rel.
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.