Age | Commit message (Collapse) | Author | Files | Lines |
|
During a -r (or --emit-relocs) link, if two sections had the same name but
different section types, gold would put relocations for both sections into
the same relocation section even though the data sections remained separate.
For .eh_frame sections, when one section is PROGBITS and another is
X86_64_UNWIND, we really should be using the UNWIND section type and
combining the sections anyway. For other sections, we should be
creating one relocation section for each output data section.
gold/
PR gold/23016
* incremental.cc (can_incremental_update): Check for unwind section
type.
* layout.h (Layout::layout): Add sh_type parameter.
* layout.cc (Layout::layout): Likewise.
(Layout::layout_reloc): Create new output reloc section if data
section does not already have one.
(Layout::layout_eh_frame): Check for unwind section type.
(Layout::make_eh_frame_section): Use unwind section type for .eh_frame
and .eh_frame_hdr.
* object.h (Sized_relobj_file::Shdr_write): New typedef.
(Sized_relobj_file::layout_section): Add sh_type parameter.
(Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type
parameter.
* object.cc (Sized_relobj_file::check_eh_frame_flags): Check for
unwind section type.
(Sized_relobj_file::layout_section): Add sh_type parameter; pass it
to Layout::layout.
(Sized_relobj_file::do_layout): Make local copy of sh_type.
Force .eh_frame sections to unwind section type.
Pass sh_type to layout_section.
(Sized_relobj_file<size, big_endian>::do_layout_deferred_sections):
Pass sh_type to layout_section.
* output.cc (Output_section::Output_section): Initialize reloc_section_.
* output.h (Output_section::reloc_section): New method.
(Output_section::set_reloc_section): New method.
(Output_section::reloc_section_): New data member.
* target.h (Target::unwind_section_type): New method.
(Target::Target_info::unwind_section_type): New data member.
* aarch64.cc (aarch64_info): Add unwind_section_type.
* arm.cc (arm_info, arm_nacl_info): Likewise.
* i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise.
* mips.cc (mips_info, mips_nacl_info): Likewise.
* powerpc.cc (powerpc_info): Likewise.
* s390.cc (s390_info): Likewise.
* sparc.cc (sparc_info): Likewise.
* tilegx.cc (tilegx_info): Likewise.
* x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise.
* testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases.
* testsuite/Makefile.in: Regenerate.
* testsuite/testfile.cc: Add unwind_section_type.
* testsuite/pr23016_1.sh: New test script.
* testsuite/pr23016_1a.s: New source file.
* testsuite/pr23016_1b.s: New source file.
* testsuite/pr23016_2.sh: New test script.
* testsuite/pr23016_2a.s: New source file.
* testsuite/pr23016_2b.s: New source file.
|
|
|
|
2017-12-02 Vladimir Kondratyev <vladimir@kondratyev.su>
Cary Coutant <ccoutant@gmail.com>
gold/
PR gold/22540
* output.cc (gold_fallocate): Trivial return for len == 0.
Add fallback options when posix_fallocate and fallocate return
not-supported errors.
|
|
|
|
Linker-created symbols like __ehdr_start, __etext, __edata, and end
should be relocatable, not absolute.
gold/
* output.cc (Output_segment::first_section): Return NULL if there are
no sections in the segment.
* output.h (Output_segment::first_section_load_address): Assert that
first section is not NULL.
* symtab.cc (Symbol_table::sized_write_globals): Attach linker-created
segment-relative symbols to first section of the segment.
|
|
PR 16711 noted that gold allocates file space for BSS sections when using
a linker script. I've fixed that by rewriting set_section_addresses and
set_section_list_addresses to track the file offset separate from the
current virtual address, so that BSS sections do not move the file offset.
Now, if a series of BSS sections come at the end of a segment, we do not
allocate file space; but if a script forces them into the middle of a
segment, we will still allocate file space (matching Gnu ld behavior).
I've also added a warning when that happens.
That exposed another problem where orphan .bss sections were sometimes
placed in the middle of a segment. For example, if the script mentions
the .got section, but both .data and .bss are orphans, gold would put
both .data and .bss in front of .got. I've fixed that by ensuring that
orphan BSS sections are always placed after all other allocated sections.
It also exposed a problem where the SUBALIGN property is not handled
properly. The ld manual clearly states that it should override input section
alignment, whether greater or less than the given alignment, but gold would
only increase an input section's alignment. Gold would also place the output
section based on its original alignment before the SUBALIGN property took
effect, leading to a misaligned output section (where the input section
was properly aligned in memory, but was not aligned relative to the start
of the section), in violation of the ELF/gABI spec. I've fixed that by
making sure that the SUBALIGN property overrides the internal alignment of
the input sections as well as the external alignment of the output section.
This affected the behavior of script_test_2, which was written to expect
a misaligned section.
The net effect is, I think, improved compatibility with the BFD linker.
There are still cases where orphan placement differs, but the differences
should be rarer and less important. ALIGN and SUBALIGN behavior is closer,
but still not an exact match -- I still found cases where ld would create
a misaligned output section, and where gold will properly align it.
gold/
PR gold/16711
* output.cc (Output_section::set_final_data_size): Calculate data size
based on relative offset rather than file offset.
(Output_segment::set_section_addresses): Track file offset separately
from address offset.
(Output_segment::set_section_list_addresses): Add pfoff parameter.
Track file offset separately. Don't move file offset for BSS
sections.
* output.h (Output_segment::set_section_list_addresses): Add pfoff
parameter.
* script-sections.cc (Orphan_section_placement): Add PLACE_LAST_ALLOC.
(Orphan_section_placement::Orphan_section_placement): Initialize it.
(Orphan_section_placement::output_section_init): Track last allocated
section.
(Orphan_section_placement::find_place): Place BSS after last allocated
section.
(Output_section_element_input::set_section_addresses): Always override
input section alignment when SUBALIGN is specified.
(Output_section_definition::set_section_addresses): Override alignment
of output section when SUBALIGN is specified.
* testsuite/Makefile.am (script_test_15a, script_test_15b)
(script_test_15c): New test cases.
* testsuite/Makefile.in: Regenerate.
* testsuite/script_test_2.cc: Adjust expected layout.
* testsuite/script_test_15.c: New source file.
* testsuite/script_test_15a.sh: New shell script.
* testsuite/script_test_15a.t: New linker script.
* testsuite/script_test_15b.sh: New shell script.
* testsuite/script_test_15b.t: New linker script.
* testsuite/script_test_15c.sh: New shell script.
* testsuite/script_test_15c.t: New linker script.
|
|
* aarch64.cc (Target_aarch64::is_erratum_835769_sequence): Avoid
compiler warning.
* output.cc (Output_segment::set_section_addresses): Likewise.
|
|
Includes DT_MIPS_RLD_MAP and DT_MIPS_RLD_MAP_REL dynamic tags and
__RLD_MAP symbol.
2016-06-20 Vladimir Radosavljevic <Vladimir.Radosavljevic@imgtec.com>
elfcpp/
* elfcpp.h (DT_MIPS_RLD_MAP_REL): New enum constant.
gold/
* mips.cc (Target_mips::Target_mips): Initialize rld_map_.
(Target_mips::rld_map_): New data member.
(Target_mips::do_finalize_sections): Add support for
DT_MIPS_RLD_MAP and DT_MIPS_RLD_MAP_REL dynamic tags,
.rld_map section, and __RLD_MAP symbol.
(Target_mips::do_dynamic_tag_custom_value): Add support for
DT_MIPS_RLD_MAP_REL dynamic tag.
* output.cc (Output_data_dynamic::get_entry_offset): New method
definition.
* output.h (Output_data_dynamic::get_entry_offset): New method
declaration.
|
|
This patch is a simple refactoring that will allow the MIPS backend to
replace the Output_data_reloc_base::do_write() method without copying
its entire implementation. I've moved the implementation of do_write()
into a function template, which can be instantiated with a custom
class to write the MIPS-specific relocation format. The custom class
for MIPS needs access to the symbol index and address from
Output_reloc, so I've included the part of Vlad's MIPS-64 patch that
makes those accessor methods public.
2016-03-08 Cary Coutant <ccoutant@gmail.com>
Vladimir Radosavljevic <vladimir.radosavljevic@imgtec.com>
gold/
* output.cc (Output_reloc_writer): New type.
(Output_data_reloc_base::do_write): Move implementation to template
in output.h and replace with invocation of template.
* output.h (Output_file): Move to top of file.
(Output_reloc::get_symbol_index): Move to public interface.
(Output_reloc::get_address): Likewise.
(Output_data_reloc_base::do_write_generic): New function template.
|
|
|
|
gold/
* object.cc (Sized_relobj::do_for_all_local_got_entries): Use
Local_got_entry_key for searching in local_got_offsets_.
* object.h (class Local_got_entry_key): New class.
(Relobj::local_has_got_offset): New overloaded method.
(Relobj::local_got_offset): Likewise.
(Relobj::set_local_got_offset): Likewise.
(Relobj::do_local_has_got_offset): Add addend argument.
(Relobj::do_local_got_offset): Likewise.
(Relobj::do_set_local_got_offset): Likewise.
(Sized_relobj::do_local_has_got_offset): Add addend argument, and use
Local_got_entry_key for searching through local_got_offsets_.
(Sized_relobj::do_local_got_offset): Likewise.
(Sized_relobj::do_set_local_got_offset): Likewise.
(Sized_relobj::Local_got_offsets): Change type of the key from
unsigned int to Local_got_entry_key, and add hash and equal_to.
* output.cc (Got_entry::write): Take addend into account for
calculating value of the local symbol for GOT.
(Output_data_got::add_local): New definition of overloaded method.
(Output_data_got::add_local_with_rel): Likewise.
(Output_data_got::add_local_pair_with_rel): Likewise.
* output.h (Output_data_got::add_local): New declaration of overloaded
method.
|
|
2015-04-29 Cary Coutant <cary@google.com>
Rafael Ávila de Espíndola <rafael.espindola@gmail.com>
gold/
* gc.h (Garbage_collection::is_section_garbage): Change Object*
to Relobj*.
(Garbage_collection::add_reference): Likewise.
(Garbage_collection::gc_process_relocs): Likewise. Don't push
object/shndx pair onto *secvec for dynamic objects. Don't follow
relocations pointing to dynamic objects for GC.
* icf.cc (Icf::find_identical_sections): Change Object* to Relobj*.
(Icf::unfold_section): Likewise.
(Icf::is_section_folded): Likewise.
(Icf::get_folded_section): Likewise.
* icf.h: (Icf::get_folded_section): Likewise.
(Icf::unfold_section): Likewise.
(Icf::is_section_folded): Likewise.
(Icf::section_has_function_pointers): Likewise.
(Icf::set_section_has_function_pointers): Likewise.
* object.h (Section_id): Likewise.
(Const_section_id): Likewise.
* output.cc (Output_section::update_section_layout): Likewise.
* output.h: (Output_section_lookup_maps::find_relaxed_input_section):
Likewise.
* plugin.cc (update_section_order): Likewise.
(unique_segment_for_sections): Likewise.
* powerpc.cc (Powerpc_relobj::add_reference): Likewise.
(Target_powerpc::do_gc_add_reference): Likewise.
(Target_powerpc::gc_process_relocs): Likewise.
(Target_powerpc::do_gc_add_reference): Likewise.
* symtab.cc (Symbol_table::is_section_folded): Likewise.
(Symbol_table::gc_mark_symbol): Likewise.
* symtab.h: (Symbol_table::is_section_folded): Likewise.
* target.h: (Sized_target::gc_add_reference): Likewise.
(Sized_target::do_gc_add_reference): Likewise.
|
|
When Output_section::is_input_address_mapped is called we have entries for
all dropped ranges, but not for all ranges.
|
|
Now that Input_merge_map has an Output_section_data, we can use it in
implementing find_merge_section and replace the only use of is_merge_section_for
with it.
|
|
When calculating the padding necessary to align the end of the relro
segment to a page boundary, gold erroneously ignores the .tdata section
when checking to see if there are any relro sections (so if .tdata
is the only relro section, we fail to align the segment properly),
and erroneously pads the cumulative size of the segment based on
the alignment of .tbss. If there are no relro sections following .tbss,
it then fails to note the padding needed at the end of .tdata.
This patch fixes both problems. is_first_section_relro() will return
true when it sees a .tdata section, and we do not align the cumulative
size until after checking for the .tbss section.
gold/
PR gold/14217
* output.cc (Output_segment::is_first_section_relro): Don't ignore
.tdata section.
(Output_segment::set_section_addresses): Don't align size of relro
segment for .tbss.
|
|
2015-03-02 Rafael Ávila de Espíndola <rafael.espindola@gmail.com>
* ehframe.cc (Cie::set_output_offset): Pass in and use a
Output_section_data instead of a Merge_map.
(Eh_frame::Eh_frame): Don't initialize merge_map_.
(Eh_frame::read_cie): Use add_merge_mapping instead of
Merge_map::add_mapping.
(Eh_frame::read_fde): Ditto.
(Eh_frame::set_final_data_size): Use this instead of this->merge_map_.
(Eh_frame::do_output_offset): Use merge_output_offset istead of
merge_map_->get_output_offset.
(Eh_frame::do_is_merge_section_for): Delete.
* ehframe.h (Fde::add_mapping): Pass in and use a Output_section_data
instead of a Merge_map.
(Cie::set_output_offset): Pass in a Output_section_data instead of a
Merge_map.
(Eh_frame::do_is_merge_section_for): Delete.
(Eh_frame::merge_map_): Delete.
* merge.cc (Object_merge_map::get_or_make_input_merge_map): Pass in
and use a Output_section_data instead of a Merge_map.
(Object_merge_map::add_mapping): Ditto.
(Object_merge_map::get_output_offset): Remove the merge_map argument.
(Object_merge_map::is_merge_section_for): Pass in and use a
Output_section_data instead of a Merge_map.
(Merge_map): Delete.
(Output_merge_base::do_output_offset): Use merge_output_offset instead
of merge_map_.get_output_offset.
(Output_merge_base::do_is_merge_section_for): Delete.
(Output_merge_data::do_add_input_section): Use
object->add_merge_mapping instead of add_mapping.
(Output_merge_string<Char_type>::finalize_merged_data): Ditto.
* merge.h (Merge_map): Delete forward declaration.
(Object_merge_map::add_mapping): Pass in and use a Output_section_data
instead of a Merge_map.
(Object_merge_map::get_output_offset): Remove the merge_map argument.
(Object_merge_map::is_merge_section_for): Pass in and use a
Output_section_data instead of a Merge_map.
(Input_merge_map::Object_merge_map::merge_map): Replace with
output_data.
(Object_merge_map::get_or_make_input_merge_map): Pass in and use a
Output_section_data instead of a Merge_map.
(Merge_map): Delete.
(Output_merge_base::Output_merge_base): Don't initialize merge_map_.
(Output_merge_base::do_is_merge_section_for): Delete.
(Output_merge_base::add_mapping): Delete.
(Output_merge_base::merge_map_): Delete.
* object.cc (Relobj::initialize_input_to_output_map): New.
(Relobj::initialize_input_to_output_map): New.
(Relobj::merge_output_offset): New.
(Relobj::is_merge_section_for): New.
(Relobj::initialize_input_to_output_map): Instantiate for 32 and 64
bits.
* object.h (Relobj::merge_map): Delete.
(initialize_input_to_output_map): New.
(set_merge_map): Delete.
(add_merge_mapping): New.
(merge_output_offset): New.
(is_merge_section_for): New.
* output.cc (Output_section::Input_section::is_merge_section_for):
Use object->is_merge_section_for.
* output.h (Output_section_data::is_merge_section_for): Delete.
(Output_section_data::do_is_merge_section_for): Delete.
* reloc.cc (Merged_symbol_value<size>::initialize_input_to_output_map):
Use object->initialize_input_to_output_map.
(Merged_symbol_value<size>::value_from_output_section): Use
object->merge_output_offset.
|
|
2015-02-04 Peter Collingbourne <pcc@google.com>
Cary Coutant <ccoutant@google.com>
gold/
* output.cc (Output_section::add_merge_input_section): Do not
attempt to merge sections with an entsize of 0.
|
|
gold/
* output.cc (Output_segment::set_section_addresses): Fix calculation
of size of relro segment.
|
|
|
|
When --sort-section=name is used, gold will sort the linker-generated contents
of .eh_frame (after optimization) after the endcap provided by crtendS.o.
This causes two problems: the .eh_frame_hdr section is generated assuming that
the optimized .eh_frame contents will be placed at the very beginning of the
section, and the endcap no longer appears at the end of the section.
This patch fixes the first problem by adjusting FDE offsets to take into account
the actual starting offset within the output section, and fixes the second
problem by sorting linker-generated (Output_section_data) sections based on the
name of the output section.
gold/
PR gold/17005
* ehframe.cc (Fde::write): Add output_offset parameter.
(Cie::write): Likewise.
(Eh_frame::set_final_data_size): Account for offset within output
section.
(Eh_frame::do_sized_write): Likewise.
* ehframe.h (Fde::write): Add output_offset parameter.
(Cie::write): Likewise.
* output.cc (Output_section::Input_section_sort_entry): Remove
section_has_name_; add output_section_name parameter. Use
output section name for non-input sections.
(Output_section::Input_section_sort_entry::section_has_name): Remove.
(Output_section::Input_section_sort_entry::section_has_name_): Remove.
(Output_section::Input_section_sort_compare): Remove logic for
sections without names.
(Output_section::Input_section_sort_init_fini_compare): Likewise.
(Output_section::Input_section_sort_section_prefix_special_ordering_compare):
Likewise.
(Output_section::Input_section_sort_section_name_compare): Likewise.
|
|
2014-03-10 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
gold/
* output.cc (Output_data_dynamic::Dynamic_entry::write):
Get the value of DYNAMIC_CUSTOM dynamic entry.
* output.h (Output_data_dynamic::add_custom): New function.
(Dynamic_entry::Dynamic_entry): New constructor for DYNAMIC_CUSTOM
dynamic entry.
(enum Dynamic_entry::Classification): Add DYNAMIC_CUSTOM.
* target.h (Target::dynamic_tag_custom_value): New function.
(Target::do_dynamic_tag_custom_value): New function.
|
|
|
|
* target.h (Target::adjust_elf_header, Target::do_adjust_elf_header):
Remove const from declaration.
* target.cc (Sized_target::do_adjust_elf_header): Update definition.
* sparc.cc (Target_sparc::do_adjust_elf_header): Likewise.
* output.h (Output_file_header): Remove const from member target_
and corresponding constructor argument.
* output.cc (Output_file_header::Output_file_header): Update prototype.
(Output_file_header::do_sized_write): Use this->target_ in place
of parameters()->target().
|
|
* output.cc (Output_segment::set_section_addresses): Take new
Target* argument. If target->isolate_execinstr() and the segment
is executable and starts at a target->abi_pagesize() boundary,
pad its end out to a target->abi_pagesize() boundary with code fill.
* output.h (Output_segment::set_section_addresses): Update decl.
* layout.h (Layout::check_output_data_for_reset_values): Take new
argument RELAX_OUTPUTS.
(Layout): New member relax_output_list_.
(Layout::add_relax_output): New method.
* layout.cc (Layout::Layout): Update constructor.
(Layout::reset_relax_output): New method.
(Layout::clean_up_after_relaxation): Call it.
(Layout::prepare_for_relaxation): Update caller.
(Layout::set_segment_offsets): Update callers of set_section_addresses.
Call reset_relax_output before re-processing segments for
isolate_execinstr case.
(Layout::write_data): Handle relax_output_list_.
(Layout::Relaxation_debug_check::check_output_data_for_reset_values):
Take new argument RELAX_OUTPUTS. Assert it's an empty collection.
|
|
Sriraman Tallam <tmsriram@google.com>
* options.h (sort_section): New option.
* output.h (Input_section_sort_section_prefix_special_ordering_compare):
Rename from Input_section_sort_section_name_special_ordering_compare.
(Input_section_sort_section_name_compare): New struct.
* output.cc (Output_section::Input_section_sort_section_name_compare::
operator()): New function.
(Output_section::sort_attached_input_sections): Use new sort function
for .text if --sort-section=name is specified.
* layout.cc (Layout::make_output_section):
Add sorting by name when --sort-section=name is specified.
* testsuite/Makefile.am (text_section_grouping): Test option
--sort-section=name.
* testsuite/Makefile.in: Regenerate.
* testsuite/section_sorting_name.cc: New file.
* testsuite/section_sorting_name.sh: New file.
|
|
gold/
* output.cc (Output_section::add_merge_input_section): Allow
to merge sections if the alignment is more than character size.
* merge.h (Output_merge_string::Output_merge_string): Remove
assert.
* merge.cc (Output_merge_string<Char_type>::do_add_input_section): Count
only not-null strings. Check the alignment of strings.
* stringpool.h
(Stringpool_template<Stringpool_char>::Stringpool_template): Add
alignment as the argument.
(Stringpool_template<Stringpool_char>::addralign_): New class member.
* stringpool.cc (Stringpool_template<Stringpool_char>::new_key_offset):
Align non-zero length strings according to the addralign_.
(Stringpool_template<Stringpool_char>::set_string_offsets):
Updating offsets according to the given alignment.
* testsuite/Makefile.am (text_section_grouping): Test if string
literals are getting merged.
* testsuite/Makefile.in: Regenerate.
* testsuite/merge_string_literals_1.c: New file.
* testsuite/merge_string_literals_2.c: Ditto.
* testsuite/merge_string_literals.sh: Ditto.
|
|
2013-01-24 Sriraman Tallam <tmsriram@google.com>
* layout.cc (Layout::layout): Check for option text_reorder.
(Layout::make_output_section): Ditto.
* options.h (text_reorder): New option.
* output.cc (Input_section_sort_compare): Remove special ordering
of section names.
(Output_section::
Input_section_sort_section_name_special_ordering_compare::
operator()): New function.
(Output_section::sort_attached_input_sections): Use new sort function
for .text.
* output.h (Input_section_sort_section_name_special_ordering_compare):
New struct.
* testsuite/Makefile.am (text_section_grouping): Test option
--no-text-reorder
* testsuite/Makefile.in: Regenerate.
* testsuite/text_section_grouping.sh: Check order of functions without
default text reordering.
|
|
PR gold/14993
* output.cc (Output_section::add_input_section): For incremental
updates, don't track input sections that are allocated from patch
space.
|
|
function.
(Layout::layout): If input section requires special ordering, must
sort input sections.
(Layout::make_output_section): May sort .text input sections.
(Layout::is_section_name_prefix_grouped): Remove.
* layout.h (class Layout): Declare
special_ordering_of_input_section. Don't declare
is_section_name_prefix_grouped.
* output.cc (Output_section::add_input_section): Revert last
change.
(Output_section::Input_section_sort::match_file_name): Don't crash
if called on output section data.
(Output_section::Input_section_sort_compare): Sort based on
special ordering.
(Output_section::Input_section_sort_section_order_index_compare):
Revert last patch.
(Output_section::sort_attached_input_sections): Likewise.
|
|
by default.
2012-12-18 Sriraman Tallam <tmsriram@google.com>
* layout.cc (Layout::is_section_name_prefix_grouped): New function.
* layout.h (Layout::is_section_name_prefix_grouped): New function.
* output.cc (Output_section::add_input_section): Check if section
name contains special prefix. Keep input sections to sort such
sections.
(Output_section::Input_section_sort_section_order_index_compare
::operator()): Group sections according to prefixes.
* (Output_section::sort_attached_input_sections): Add condition
to Input_section_entry constructor call.
* testsuite/Makefile.am (text_section_grouping): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/text_section_grouping.cc: New file.
* testsuite/text_section_grouping.sh: New file.
|
|
* layout.cc (Layout::get_executable_sections): New function.
* arm.cc (Target_arm::group_sections): Use it.
(Arm_output_section::group_sections): Delete now redundant test.
* output.cc (Output_reloc::Output_reloc): Add is_relative.
param to handle relative relocs.
* output.h (Output_reloc::Output_reloc <absolute reloc>): Likewise.
(Output_data_reloc::add_absolute): Adjust.
(Output_data_reloc::add_relative): New function.
(Output_data::reset_data_size): New function.
(Output_relaxed_input_section::set_relobj, set_shndx): New functions.
(Output_section::set_addralign): New function.
(Output_section::checkpoint_set_addralign): New function.
(Output_section::clear_section_offsets_need_adjustment): New function.
(Output_section::input_sections): Make public.
* powerpc.cc (class Output_data_brlt_powerpc): New.
(class Stub_table, class Stub_control): New.
(Powerpc_relobj::has14_, set_has_14bit_branch, has_14bit_branch,
stub_table_, set_stub_table, stub_table): New vectors and accessor
functions.
(Target_powerpc::do_may_relax, do_relax, push_branch,
new_stub_table, stub_tables, brlt_section, group_sections,
add_branch_lookup_table, find_branch_lookup_table,
write_branch_lookup_table, make_brlt_section): New functions.
(Target_powerpc::struct Sort_sections, class Branch_info): New.
(Target_powerpc::brlt_section_, stub_tables_, branch_lookup_table_,
branch_info_): New vars.
(Target_powerpc::make_plt_entry, make_local_ifunc_plt_entry): Don't
make call stubs here.
(Output_data_glink): Remove all call stub handling from this class.
(Target_powerpc::Scan::local, global): Save interesting branch
relocs and relocs for ifunc. Adjust calls to plt entry functions.
(Target_powerpc::do_finalize_sections): Only make reg save/restore
functions on final link.
(Target_powerpc::Relocate::relocate): Adjust lookup of call stubs.
Handle long branch destinations too.
(Target_powerpc::do_dynsym_value, do_plt_address_for_global,
do_plt_address_for_local): Adjust lookup of plt call stubs.
|
|
* dwarf_reader.cc (Sized_elf_reloc_mapper::symbol_section): Cast
SYMNDX to off_t before comparing it to this->data_size().
* output.cc (Output_symtab_xindex::endian_do_write): Likewise.
* incremental.cc (Output_section_incremental_inputs::do_write):
Cast GLOBAL_SYM_COUNT to off_t before comparing it to SYMTAB_SIZE.
|
|
address_for_local): Add plt offset to returned value. Adjust uses.
* sparc.cc (Output_data_plt_sparc::address_for_global,
address_for_local): Likewise.
* tilegx.cc (Output_data_plt_tilegx::address_for_global,
address_for_local): Likewise.
* x86_64.cc (Output_data_plt_x86_64::address_for_global,
address_for_local): Likewise.
* target.h (Target::plt_address_for_global, plt_address_for_local):
Update comment.
* output.cc (Output_reloc::symbol_value): Don't add plt offset here.
(Output_data_got::Got_entry::write): Nor here.
* output.h: Comment fix.
|
|
* output.cc: Rename Output_data_got template parameter from size
to got_size for all functions. Compile all variants of
Output_data_got.
(Output_data_got::Got_entry::write): Correct use of size for
symbol value. Use local_is_tls rather than casting to
Sized_relobj_file.
* object.h (class Object): Add local_is_tls and do_local_is_tls.
(class Sized_relobj_file): Add do_local_is_tls.
* incremental.h (class Sized_relobj_incr): Add do_local_is_tls.
|
|
* layout.cc (Layout::set_segment_offsets): When using
common-page-size alignment, ensure we are on a new max-page-size
page.
* output.cc (Output_segment::set_section_addresses): Use
abi_pagesize, not common_pagesize for relro boundary.
(Output_segment::set_offset): Likewise.
|
|
add_local_tls_pair): New functions.
(Output_data_got::add_local_pair_with_rel): Remove second
reloc param. Expand comment.
(Output_data_got::Got_entry): Rename use_plt_offset_ to
use_plt_or_tls_offset_, similarly for constructor param.
(Output_data_got::Got_entry::write): Add got_index param.
* output.cc (Output_data_got::add_global_tls, add_local_tls,
add_local_tls_pair): New functions.
(Output_data_got::Got_entry::write): Handle tls symbols
with use_plt_or_tls_offset_ set specially.
(Output_data_got::add_local_pair_with_rel): Only one reloc.
(Output_data_got::do_write): Replace iterator with index, pass
index to entry write function.
* target.h (Target::tls_offset_for_local, tls_offset_for_global,
do_tls_offset_for_local, do_tls_offset_for_global): New functions.
* arm.cc (Target_arm::Scan::local): Update add_local_pair_with_rel
call.
* i386.cc (Target_i386::Scan::local): Likewise.
* sparc.cc (Target_sparc::Scan::local): Likewise.
* x86_64.cc (Target_x86_64::Scan::local): Likewise.
* powerpc.cc (Target_powerpc::do_tls_offset_for_local,
do_tls_offset_for_global): New functions.
(Target_powerpc::Scan::local): Correct TLS relocations and got
entry values.
(Target_powerpc::Scan::global): Don't emit unnecessary
dynamic relocations on TLS GOT entries.
|
|
(Sized_relobj_file::emit_relocs_reltype): Delete.
* reloc.cc (Sized_relobj_file::do_relocate_sections): Call target
relocate_relocs for --emit-relocs.
(Sized_relobj_file::emit_relocs, emit_relocs_reltype): Delete.
* output.h: Update comment.
(Output_segment::first_section): New function.
(Output_segment::first_section_load_address): Use first_section.
* output.cc (Output_segment::first_section): New function extracted..
(Output_segment::first_section_load_address): ..from here. Delete.
* target-reloc.h (relocate_for_relocatable): Rename to relocate_relocs.
* target.h (Sized_target::relocate_for_relocatable): Likewise.
* arm.cc (Target_arm::relocate_for_relocatable): Likewise, and
adjust call to target.h function.
* i386.cc (Target_i386): Likewise.
* sparc.cc (Target_sparc): Likewise.
* x86_64.cc (Target_x86_64): Likewise.
* powerpc.cc (Target_powerpc): Likewise.
(Target_powerpc::Scan::local, global): Handle R_POWERPC_TLS. Ensure
first tls section has section symbol for optimised local dynamic
output relocs.
(Target_powerpc::Relocate::relocate): Correct local dynamic value.
(Target_powerpc::relocate_relocs): Adjust relocs emitted for
optimised tls code.
* testsuite/testfile.cc (Target_test::relocate_for_relocatable):
Rename to relocate_relocs. Update error message.
|
|
is_relative param. Adjust calls.
(Output_reloc::add_output_section_relative): New functions.
* output.cc (Output_reloc::Output_reloc <output section>): Handle
is_relative.
(Output_reloc::symbol_value): Handle SECTION_CODE.
|
|
segments.
2012-08-24 Sriraman Tallam <tmsriram@google.com>
* gold.cc (queue_middle_tasks): Call layout again when unique
segments for sections is desired.
* layout.cc (Layout::Layout): Initialize new members.
(Layout::get_output_section_flags): New function.
(Layout::choose_output_section): Call get_output_section_flags.
(Layout::layout): Make output section for mapping to a unique segment.
(Layout::insert_section_segment_map): New function.
(Layout::attach_allocated_section_to_segment): Make unique segment for
output sections marked so.
(Layout::segment_precedes): Check for unique segments when sorting.
* layout.h (Layout::Unique_segment_info): New struct.
(Layout::Section_segment_map): New typedef.
(Layout::insert_section_segment_map): New function.
(Layout::get_output_section_flags): New function.
(Layout::is_unique_segment_for_sections_specified): New function.
(Layout::set_unique_segment_for_sections_specified): New function.
(Layout::unique_segment_for_sections_specified_): New member.
(Layout::section_segment_map_): New member.
* object.cc (Sized_relobj_file<size, big_endian>::do_layout):
Rename is_gc_pass_one to is_pass_one.
Rename is_gc_pass_two to is_pass_two.
Rename is_gc_or_icf to is_two_pass.
Check for which pass based on whether symbols data is present.
Make it two pass when unique segments for sections is desired.
* output.cc (Output_section::Output_section): Initialize new
members.
* output.h (Output_section::is_unique_segment): New function.
(Output_section::set_is_unique_segment): New function.
(Output_section::is_unique_segment_): New member.
(Output_section::extra_segment_flags): New function.
(Output_section::set_extra_segment_flags): New function.
(Output_section::extra_segment_flags_): New member.
(Output_section::segment_alignment): New function.
(Output_section::set_segment_alignment): New function.
(Output_section::segment_alignment_): New member.
(Output_segment::Output_segment): Initialize is_unique_segment_.
(Output_segment::is_unique_segment): New function.
(Output_segment::set_is_unique_segment): New function.
(Output_segment::is_unique_segment_): New member.
* plugin.cc (allow_unique_segment_for_sections): New function.
(unique_segment_for_sections): New function.
(Plugin::load): Add new functions to transfer vector.
* Makefile.am (plugin_final_layout.readelf.stdout): Add readelf output.
* Makefile.in: Regenerate.
* testsuite/plugin_final_layout.sh: Check if unique segment
functionality works.
* testsuite/plugin_section_order.c (onload): Check if new interfaces
are available.
(allow_unique_segment_for_sections): New global.
(unique_segment_for_sections): New global.
(claim_file_hook): Call allow_unique_segment_for_sections.
(all_symbols_read_hook): Call unique_segment_for_sections.
2012-08-24 Sriraman Tallam <tmsriram@google.com>
* plugin-api.h (ld_plugin_allow_unique_segment_for_sections):
New interface.
(ld_plugin_unique_segment_for_sections): New interface.
(LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS): New enum val.
(LDPT_UNIQUE_SEGMENT_FOR_SECTIONS): New enum val.
(tv_allow_unique_segment_for_sections): New member.
(tv_unique_segment_for_sections): New member.
|
|
(Sized_relobj_file::find_special_sections): New function.
* object.cc (Sized_relobj_file::find_shdr): New function.
(Sized_relobj_file::find_eh_frame): Use find_shdr.
(Sized_relobj_file::find_special_sections): New function, split out..
(Sized_relobj_file::do_read_symbols): ..from here.
* output.h (Output_data_got::replace_constant): New function.
(Output_data_got::num_entries): New function.
(Output_data_got::last_got_offset,set_got_size): Use num_entries.
(Output_data_got::got_offset): Protected rather than private.
(Output_data_got::replace_got_entry): New function.
* output.cc (Output_data_got::replace_got_entry): New function.
* powerpc.cc (class Powerpc_relobj): New.
(class Powerpc_relocate_functions): Delete all psymval variants or
convert to value,addend type. Delete pcrela, pcrela_unaligned.
Implement _ha functions using corresponding _hi function.
(Powerpc_relobj::find_special_sections): New function.
(Target_powerpc::do_make_elf_object): New function.
(class Output_data_got_powerpc): New.
(class Output_data_glink): New.
(class Powerpc_scan_relocatable_reloc): New.
Many more changes througout file.
|
|
* configure.ac: Add check for fallocate.
* configure: Regenerate.
* config.in: Regenerate.
* options.h (class General_options): Add --mmap-output-file and
--posix-fallocate options.
* output.cc: (posix_fallocate): Remove; replace with...
(gold_fallocate): New function.
(Output_file::map_no_anonymous): Call gold_fallocate.
(Output_file::map): Check --mmap-output-file option.
|
|
gold/
* output.h (Output_reloc): Allow use_plt_offset for global relocs too.
(class Output_data_reloc): Adjust calls to Output_reloc_type.
(Output_data_reloc::add_global_relative): (RELA only) Add use_plt_offset.
* output.cc (Output_reloc::Output_reloc): Add use_plt_offset flag for
global relocs too.
(Output_reloc::symbol_value): Respect use_plt_offset_ for global symbols.
* powerpc.cc (Target_powerpc::Scan::global): Adjust add_global_relative
calls.
* sparc.cc (Target_sparc::Scan::global): Likewise.
* x86_64.cc (Target_x86_64::Scan::global): Likewise.
|
|
Use abstract base class for GOT.
* gold/output.h (class Output_data_got_base): New abstract base class.
(class Output_data_got): Derive from new base class, adjust ctors.
(Output_data_got::reserve_slot): Make virtual; rename to
do_reserve_slot; Adjust callers.
* gold/target.h (Sized_target::init_got_plt_for_update): Return
pointer to abstract base class.
* gold/x86_64.cc (Target_x86_64::init_got_plt_for_update): Likewise.
|
|
(Relobj::local_plt_offset): New function.
(Relobj::local_has_got_offset): New function.
(Relobj::local_got_offset): New function.
(Relobj::set_local_got_offset): New function.
(Relobj::do_local_symbol_value): New pure virtual function.
(Relobj::do_local_plt_offset): Likewise.
(Relobj::do_local_has_got_offset): Likewise.
(Relobj::do_local_got_offset): Likewise.
(Relobj::do_set_local_got_offset): Likewise.
(Sized_relobj::do_local_has_got_offset): Rename from
local_has_got_offset.
(Sized_relobj::do_local_got_offset): Rename from local_got_offset.
(Sized_relobj::do_set_local_got_offset): Rename from
set_local_got_offset.
(Sized_relobj_file::do_local_plt_offset): Rename from
local_plt_offset.
(Sized_relobj_file::do_local_symbol_value): New function.
* object.cc (Sized_relobj_file::do_local_plt_offset): Rename from
local_plt_offset.
* output.cc (Output_data_got::Got_entry::write): Change object to
Relobj. Use local_symbol_value.
(Output_data_got::add_global_with_rel): Change rel_dyn to
Output_data_reloc_generic*. Use add_global_generic.
(Output_data_got::add_global_with_rela): Remove. Change all
callers to use add_global_with_rel.
(Output_data_got::add_global_pair_with_rel): Change rel_dyn to
Output_data_reloc_generic*. Use add_global_generic.
(Output_data_got::add_global_pair_with_rela): Remove. Change all
callers to use add_global_pair_with_rel.
(Output_data_got::add_local): Change object to Relobj*.
(Output_data_got::add_local_plt): Likewise.
(Output_data_got::add_local_with_rel): Change object to Relobj*,
change rel_dyn to Output_data_reloc_generic*. Use
add_local_generic.
(Output_data_got::add_local_with_rela): Remove. Change all
callers to use all_local_with_rel.
(Output_data_got::add_local_pair_with_rel): Change object to
Relobj*, change rel_dyn to Output_data_reloc_generic*. Use
add_output_section_generic.
(Output_data_got::add_local_pair_with_rela): Remove. Change all
callers to use add_local_pair_with_rel.
(Output_data_got::reserve_local): Change object to Relobj*.
* output.h: (class Output_data_reloc_generic): Add pure virtual
declarations for add_global_generic, add_local_generic,
add_output_section_generic.
(class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new
functions for Output_data_reloc_generic. Update declarations for
changes listed in output.cc.
(class Output_data_got): Change template parameter to got_size.
Don't define Rel_dyn or Rela_dyn. Update declarations per above.
* incremental.h (Sized_relobj_incr::do_local_symbol_value): New
function.
(Sized_relobj_incr::do_local_plt_offset): New function.
* copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call
add_global_generic.
|
|
(Output_file::map_no_anonymous): Check for non-zero
return code from posix_fallocate.
|
|
::read returns less than requested size.
|
|
* gold/output.cc (Output_reloc::Output_reloc): Add use_plt_offset flag.
(Output_reloc::symbol_value): Return PLT offset if flag is set.
* gold/output.h (class Output_reloc): Add use_plt_offset flag.
(Output_reloc::type_): Adjust size of bit field.
(Output_reloc::use_plt_offset_): New bit field.
(class Output_data_reloc): Adjust all calls to Output_reloc_type.
(Output_data_reloc::add_local_relative): (RELA only) Add use_plt_offset
flag. Adjust all callers.
* gold/x86_64.cc (Target_x86_64::Scan::local): Check for IFUNC when
creating RELATIVE relocations.
|
|
* layout.h (section_order_map_): New member.
(get_section_order_map): New member function.
* output.cc (Output_section::add_input_section): Check for patterns
only when --section-ordering-file is specified.
* gold.cc (queue_middle_tasks): Delay updating order of sections till
output_sections have been formed.
* layout.cc (Layout_Layout): Initialize section_order_map_.
* plugin.cc (update_section_order): Store order in order_map. Do not
update the order.
* testsuite/Makefile.am: Add test case for plugin_final_layout.
* testsuite/Makefile.in: Regenerate.
* testsuite/plugin_section_order.c: New file.
* testsuite/plugin_final_layout.cc: New file.
* testsuite/plugin_final_layout.sh: New file.
|
|
(Output_fill_debug_line::do_write): Likewise.
|
|
casts to match formatting specs.
(Output_fill_debug_line::do_minimum_hole_size): Likewise.
|