From 9a472eda40ba686e45bf4922455518ffa3c887e1 Mon Sep 17 00:00:00 2001 From: Han Shen Date: Fri, 15 Jan 2016 09:31:23 -0800 Subject: [PATCH] [gold][aarch64] PR gold/19472 - DSOs need pc-relative stubs. The stub generated during relaxation uses absolute addressing mode for shared libraries, which is not correct. Use pc-relative addressing instead. gold/ChangeLog: 2016-01-15 Han Shen PR gold/19472 - DSOs need pc-relative stubs. * aarch64.cc (Reloc_stub::stub_type_for_reloc): Return PC-relative stub type for DSOs and pie executables. --- gold/ChangeLog | 7 +++++++ gold/aarch64.cc | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index 3560e2f8afc..06cafb05a5a 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,10 @@ +2016-01-15 Han Shen + + PR gold/19472 - need pc-relative stubs. + + * aarch64.cc (Reloc_stub::stub_type_for_reloc): Return PC-relative + stub type for DSOs and pie executables. + 2016-01-12 H.J. Lu * i386.cc (Target_i386::Classify_reloc::get_r_addend): Remove diff --git a/gold/aarch64.cc b/gold/aarch64.cc index 5ad061b8979..6cd6f12abb1 100644 --- a/gold/aarch64.cc +++ b/gold/aarch64.cc @@ -1327,10 +1327,12 @@ Reloc_stub::stub_type_for_reloc( if (aarch64_valid_for_adrp_p(location, dest)) return ST_ADRP_BRANCH; - if (parameters->options().output_is_position_independent() - && parameters->options().output_is_executable()) + // Always use PC-relative addressing in case of -shared or -pie. + if (parameters->options().output_is_position_independent()) return ST_LONG_BRANCH_PCREL; + // This saves 2 insns per stub, compared to ST_LONG_BRANCH_PCREL. + // But is only applicable to non-shared or non-pie. return ST_LONG_BRANCH_ABS; } -- 2.30.2