Age | Commit message (Collapse) | Author | Files | Lines |
|
This is a feature required in chromeos arm development work.
Tested:
1) Built passed all-gold on x86_64 machine
2) Tested with basic gold aarch64 ifunc unittests -
a) global ifunc, statically/non-statically linked
b) local ifunc, statically/non-statically linked
c) global/local, other shared library routine mixed,
statically/non-statically linked
d) arm/thumb mode ifunc
e) linking chrome browser passed
|
|
|
|
* aarch64.cc (AArch64_relocate_functions::maybe_apply_stub):
Cast current_group_size to unsigned long when reporting error.
|
|
This patch gives current stub-group-size in error message when stub
is too far away.
* aarch64.cc (Target_aarch64): Add new variable: stub_group_size_.
(AArch64_relocate_functions::maybe_apply_stub): Add new parameter.
Update error message.
(Target_aarch64::do_relax): Use absolute value of option
stub_group_size. Replace local variable with class member
stub_group_size_.
|
|
(Also included in this patch is a minor typo fix in gold/ChangeLog.)
When linking the following tlsdesc access sequence into an executable with -pie,
adrp x0, :tlsdesc:tls_gd
ldr x1, [x0, #:tlsdesc_lo12:tls_gd]
add x0, x0, :tlsdesc_lo12:tls_gd
.tlsdesccall tls_gd
blr x1
mrs x1, tpidr_el0
add x0, x1, x0
ldr w0, [x0]
current gold-aarch64 backend does tls-desc-gd-to-ie relaxation, into
adrp x0, 1000 <__FRAME_END__+0x720>
ldr x1, [x0,#4064] ;; <=== the target register should be x0
nop
nop
mrs x1, tpidr_el0
add x0, x1, x0
ldr w0, [x0]
This code is wrong. The fix changes ldr target register into x0.
|
|
The patch does the following things:
-- Add support for ifunc.
-- Enable safe icf
-- Add support for TLSLD relocations
R_AARCH64_TLSLD_ADR_PAGE21,
R_AARCH64_TLSLD_ADD_LO12_NC,
R_AARCH64_TLSLD_MOVW_DTPREL_G1,
R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC.
(R_AARCH64_TLSLD_MOVW_* are used by LLVM.)
-- Add support for TLSLD->TLSLE relaxation.
-- Add support for R_AARCH64_LD_PREL_LO19, R_AARCH64_ADR_PREL_LO21.
-- Fix 2 encoding bugs in AArch64_relocate_functions::update_movnz.
-- Correct TLS relocation properties in gold/aarch64-reloc.def.
-- Update testsuite/icf_safe_so_test.cc, testsuite/icf_safe_test.sh.
gold/
2014-10-29 Han Shen <shenhan@google.com>
Jing Yu <jingyu@google.com>
* aarch64-reloc.def: Add LD_PREL_LO12, ADR_PREL_LO21,
TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC, TLSLD_MOVW_DTPREL_G1,
TLSLD_MOVW_DTPREL_G0_NC. Change property of TLS relocations to
Symbol::TLS_REF.
* aarch64.cc (Target_aarch64::do_can_check_for_function_pointers): New
method.
(Target_aarch64::reloc_needs_plt_for_ifunc): New method.
(Target_aarch64::tls_ld_to_le): New method.
(Target_aarch64::aarch64_info): Enable can_icf_inline_merge_sections
for 64bit targets.
(Output_data_plt_aarch64::irelative_rel_): New data member.
(Output_data_plt_aarch64::add_entry): Add irelative entries to plt.
(Output_data_plt_aarch64::add_local_ifunc_entry): New method.
(Output_data_plt_aarch64::add_relocation): New method.
(Output_data_plt_aarch64::do_write): Add gold_assert on got_irelative
offset. Add got_irelative size to got size.
(AArch64_relocate_functions): Typedef AArch64_valtype. Replace long
type string with the new typename.
(AArch64_relocate_functions::update_adr): Replace parameter x with
immed.
(AArch64_relocate_functions::update_movnz): Correct wrong val mask.
(AArch64_relocate_functions::reloc_common): New method.
(AArch64_relocate_funcsions::rela_general): Extract common part out
into reloc_common method.
(AArch64_relocate_functions::rela_general): Likewise.
(AArch64_relocate_functions::pcrela_general): Likewise.
(AArch64_relocate_functions::adr): New method.
(AArch64_relocate_functions::adrp): Calculate immed before calling
update_adr.
(AArch64_relocate_functions::adrp): Likewise.
(AArch64_relocate_functions::movnz): Cast x to SignedW type when
comparing x to 0. Calculate immed from ~x when x < 0.
(Target_aarch64::optimize_tls_reloc): Add new cases for
TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC, TLSLD_MOVW_DTPREL_G1,
TLSLD_MOVW_DTPREL_G0_NC.
(Target_aarch64::possible_function_pointer_reloc): Implement this
method.
(Target_aarch64::Scan::local_reloc_may_be_function_pointer): Update
comment.
(Target_aarch64::Scan::local): Add codes to handle STT_GNU_IFUNC
symbol. Add cases for TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC,
TLSLD_MOVW_DTPREL_G1, TLSLD_MOVW_DTPREL_G0_NC.
(Target_aarch64::Scan::global): Add codes to handle STT_GNU_IFUNC
symbol. Add cases for TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC,
TLSLD_MOVW_DTPREL_G1, TLSLD_MOVW_DTPREL_G0_NC.
(Target_aarch64::make_plt_entry): Call add_entry with two more
parameters.
(Target_aarch64::make_local_ifunc_plt_entry): New method.
(Target_aarch64::Relocate::relocate): Add cases for LD_PREL_LO19,
ADR_PREL_LO21, TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC,
TLSLD_MOVW_DTPREL_G1, TLSLD_MOVW_DTPREL_G0_NC.
(Target_aarch64::Relocate::relocate_tls): Add cases for
TLSLD_ADR_PAGE21, TLSLD_ADD_LO12_NC, TLSLD_MOVW_DTPREL_G1,
TLSLD_MOVW_DTPREL_G0_NC.
* testsuite/icf_safe_so_test.cc: Correct test comment.
* testsuite/icf_safe_test.sh: Add AArch64 arch.
|
|
gold/
* aarch64.cc (AArch64_relocate_functions::maybe_apply_stub):
Add "typename" keyword.
|
|
In short relaxation is the linker's generation of stubs that fixes the
out-of-range jumps/branches in the original object file.
With this implementation, we are able to link a 456MB aarch64 application.
Tested:
1) Build natively on x86_64 and aarch64 machines.
2) Pass unit tests regarding relaxation.
|
|
elfcpp/ChangeLog:
2014-09-17 Han Shen <shenhan@google.com>
* aarch64.h (R_AARCH64_TLS_DTPREL64): Switch enum value with ...
(R_AARCH64_TLS_DTPMOD64): ... enum value.
gold/ChangeLog:
2014-09-17 Han Shen <shenhan@google.com>
Jing Yu <jingyu@google.com>
* aarch64-reloc.def: Add TLSGD_ADR_PAGE21, TLSGD_ADD_LO12_NC,
TLSDESC_ADR_PAGE21, TLSDESC_LD64_LO12, TLSDESC_ADD_LO12, TLSDESC_CALL.
* aarch64.cc (Target_aarch64): Add data members
got_irelative_, got_tlsdesc_, rela_irelative_, got_mod_index_offset_,
tlsdesc_reloc_info_, tls_base_symbol_defined_. Initialize them in
constructor.
(Target_aarch64::do_reloc_symbol_index): New method.
(Target_aarch64::do_reloc_addend): New method.
(Target_aarch64::add_tlsdesc_info): New method.
(Target_aarch64::do_dynsym_value): New method.
(Target_aarch64::do_make_data_plt): Add new parameters: got,
got_irelative. Pass them to Output_data_plt_aarch64_standard.
(Target_aarch64::make_data_plt): Add new parameters: got,
got_irelative. Pass them to do_make_data_plt.
(Target_aarch64::Relocate): Add skip_call_tls_get_addr_ variable.
(Target_aarch64::Relocate:tls_gd_to_le): New method.
(Target_aarch64::Relocate:tls_ie_to_le): New method.
(Target_aarch64::Relocate:tls_desc_gd_to_le): New method.
(Target_aarch64::Relocate:tls_desc_gd_to_ie): New method.
(Target_aarch64::got_tlsdesc_section): New method.
(Target_aarch64::make_local_ifunc_plt_entry): New method.
(Target_aarch64::define_tls_base_symbol): New method.
(Target_aarch64::reserve_tlsdesc_entries): New method.
(Target_aarch64::got_mod_index_entry): New method.
(Target_aarch64::rela_tlsdesc_section): New method.
(Target_aarch64::rela_irelative_section): New method.
(Target_aarch64::Tlsdesc_info): New struct.
(Target_aarch64::got_section): Create .got.plt space for IRELATIVE
relocations and tlsdesc relocations.
(Target_aarch64::optimize_tls_reloc): Implement method.
(Output_data_plt_aarch64): Add member variables: tlsdesc_rel_, got_,
got_irelative_, irelative_count_, tlsdesc_got_offset_. Initialize them
in constructor.
(Output_data_plt_aarch64::reserve_tlsdesc_entry): New method.
(Output_data_plt_aarch64::has_tlsdesc_entry): New method.
(Output_data_plt_aarch64::get_tlsdesc_got_offset): New method.
(Output_data_plt_aarch64::get_tlsdesc_plt_offset): New method.
(Output_data_plt_aarch64::rela_tlsdesc): New method.
(Output_data_plt_aarch64::rela_irelative): New method.
(Output_data_plt_aarch64::entry_count): Count IRELATIVE relocations.
(Output_data_plt_aarch64::first_plt_entry_offset): Add const attribute.
(Output_data_plt_aarch64::get_plt_tlsdesc_entry_size): New method.
(Output_data_plt_aarch64::fill_tlsdesc_entry): New method.
(Output_data_plt_aarch64::do_get_plt_tlsdesc_entry_size): New method.
(Output_data_plt_aarch64::do_fill_tlsdesc_entry): New method.
(Output_data_plt_aarch64_standard): New member variables:
plt_tlsdesc_entry_size, tlsdesc_plt_entry.
(Output_data_plt_aarch64_standard::Output_data_plt_aarch64_standard):
New parameter: got, got_irelative.
(Output_data_plt_aarch64_standard::do_get_plt_entry_size): New method.
(Output_data_plt_aarch64_standard::do_fill_tlsdesc_entry): New method.
(Output_data_plt_aarch64::do_write): Replace got_address with
gotplt_address. Add irelative_count_ to count. Write tlsdesc entry.
(AArch64_relocate_functions::update_movnz): New method.
(AArch64_relocate_functions): Correct format.
(AArch64_relocate_functions::movnz): New method.
(Target_aarch64::Scan::local): Correct format. Move r_sym, got to
before the switch. Add new cases to switch.
Check ie_to_le relaxation on tlsie relocations. Add code handling
tlsgd tlsdesc cases.
(Target_aarch64::Scan::global): Move arp to front. Do copy_reloc when
needed. Add new cases to switch. Insert dynamic RELATIVE relocation
when needed. Add code handling tlsgd, tlsie, tlsdesc cases.
Call reloc_name_in_error_message to print unsupported reloc.
(Target_aarch64::make_plt_section): Pass got_ and got_irelative_ to
make_data_plt.
(Target_aarch64::do_finalize_sections): Emit relocs to save COPY
relocs. Fill in some more dynamic tags.
(Target_aarch64::Relocate::relocate): Handle tlsgd, tlsdesc relocs.
Skip call tls_get_addr when tlsgd is relaxed.
(Target_aarch64::Relocate::relocate_tls): Correct format. Add code
handling tlsgd, tlsdesc relocs, and tls gd->le, ie->le, tlsdesc->le,
tlsdesc->ie relaxation.
|
|
This enables -
1. static linking hello world
2. limited support for TLSIE and TLSLE
3. limited support for linking shared library, linking executable against shared
library.
gold/ChangeLog
2014-08-29 Han Shen <shenhan@google.com>
Jing Yu <jingyu@google.com>
* aarch64-reloc-property.cc
(AArch64_reloc_property_table::reloc_name_in_error_message): Fix bug in
reference reloc property in the table.
* aarch64-reloc.def: Add TLSLE reloc types and fix some errors in
3 other entries.
* aarch64.cc: (Output_data_got_aarch64::add_static_reloc):
2 new overloaded methods.
(Output_data_got_aarch64::do_write): Add code to write out
static relocs.
(class Output_data_got_aarch64::Static_reloc): New class to wrap
static relocs.
(Output_data_got_aarch64::static_relocs): New vector to
hold static relocs.
(Target_aarch64::TCB_SIZE): New const static memeber.
(Target_aarch64::tcb_size): New method.
(Target_aarch64::Relocate::relocate): Add code handling new reloc types.
(Target_aarch64::Relocate::relocate_tls): New method.
(Target_aarch64::Scan::local): Add code handling new reloc types.
(Target_aarch64::Scan::global): Add code handling new reloc types.
|
|
elfcpp/ChangeLog:
2014-08-08 Han Shen <shenhan@google.com>
* aarch64.h (withdrawn): Replaced with R_AARCH64_withdrawn.
2014-08-08 Jing Yu <jingyu@google.com>
Han Shen <shenhan@google.com>
* Makefile.am (HFILES): Add aarch64-reloc-property.h.
(DEFFILES): add aarch64-reloc.def.
(TARGETSOURCES): Add aarch64-reloc-property.cc.
(ALL_TARGETOBJS): Add aarch64-reloc-property.$(OBJEXT).
* Makefile.in: Regenerate.
* aarch64-reloc-property.cc: New file.
* aarch64-reloc-property.h: New file.
* aarch64-reloc.def: New file.
* aarch64.cc: Include aarch64-reloc-property.h. Replace spaces
with tab to make the format consistent.
(Output_data_got_aarch64::symbol_table_): New method.
(Target_aarch64::do_plt_address_for_global): New method.
(Target_aarch64::do_plt_address_for_local): New method.
(Target_aarch64::do_select_as_default_target): New method.
(Target_aarch64::do_make_data_plt): New method.
(Target_aarch64::make_data_plt): New method.
(Output_data_plt_aarch64::has_irelative_section): New method.
(Output_data_plt_aarch64::address_for_global): New method.
(Output_data_plt_aarch64::address_for_local): New method.
(Output_data_plt_aarch64::irelative_rel_): New parameter.
(Output_data_plt_aarch64::add_entry): Implement contents.
(Output_data_plt_aarch64::set_final_data_size): Fix typo.
(Output_data_plt_aarch64::do_write): Remove useless got_base. Set
the got_pov entry to plt0.
(Output_data_plt_aarch64_standard::do_fill_first_plt_entry):
Implement contents.
(Output_data_plt_aarch64_standard::do_fill_plt_entry): Implement.
(AArch64_howto): New struct.
(aarch64_howto[]): New static const array.
(AArch64_relocate_functions): New class.
(Target_aarch64::Scan::get_reference_flags): Remove method.
(Target_aarch64::Scan::local): Implement to support a few relocations.
(Target_aarch64::Scan::global): Implement to support a few relocations.
(Target_aarch64::make_plt_section): Implement contents.
(Target_aarch64::make_plt_entry): Implement contents.
(Target_aarch64::do_finalize_sections): Implement contents.
(Target_aarch64::Relocate::relocate): Implement a few relocations.
(Target_aarch64::relocate_section): Implement contents.
|
|
Initial patch to enable gold aarch64 backend.
This patch is just a skeleton which almost does nothing.
It does not support ILP32 now.
gold/ChangeLog:
* aarch64.cc: New file
* Makefile.am (TARGETSOURCES): Add aarch64.cc
(ALL_TARGETOBJS): Add aarch64.$(OBJEXT)
* Makefile.in: Regenerate.
* configure.tgt: Add entries for aarch64*.
* configure.ac: Likewise.
* configure: Likewise.
elfcpp/ChangeLog:
* aarch64.h: New file. New enums for aarch64-elf64 relocations.
* elfcpp.h (EM_AARCH64, SHT_AARCH64_ATTRIBUTES, PT_AARCH64_ARCHEXT,
PT_AARCH64_UNWIND): New enum constant.
|