diff -u gcc-5-5.4.0/debian/changelog gcc-5-5.4.0/debian/changelog --- gcc-5-5.4.0/debian/changelog +++ gcc-5-5.4.0/debian/changelog @@ -1,3 +1,11 @@ +gcc-5 (5.4.0-6ubuntu1~16.04.4+lp1695093.1) xenial; urgency=medium + + * Fix PR target/79041, aarch64 backend emitting R_AARCH64_ADR_PREL_PG_HI21 + relocation despite -mpc-relative-literal-loads option being used. + LP: #1695093. + + -- dann frazier Tue, 11 Jul 2017 13:22:18 -0600 + gcc-5 (5.4.0-6ubuntu1~16.04.4) xenial-security; urgency=medium * SRU diff -u gcc-5-5.4.0/debian/rules.patch gcc-5-5.4.0/debian/rules.patch --- gcc-5-5.4.0/debian/rules.patch +++ gcc-5-5.4.0/debian/rules.patch @@ -16,6 +16,8 @@ svn-updates \ $(if $(with_linaro_branch),gcc-linaro) \ $(if $(with_linaro_branch),gcc-linaro-no-macros) \ + $(if $(with_linaro_branch),mpc-relative-literal-loads-rename) \ + $(if $(with_linaro_branch),lp1695093) \ # $(if $(with_linaro_branch),gcc-linaro-revert-r236918) \ # $(if $(with_linaro_branch),gcc-linaro-revert-r236444) \ only in patch2: unchanged: --- gcc-5-5.4.0.orig/debian/patches/lp1695093.diff +++ gcc-5-5.4.0/debian/patches/lp1695093.diff @@ -0,0 +1,12 @@ +--- a/src/gcc/config/aarch64/aarch64.c 2017-07-11 17:41:55.803147289 +0000 ++++ b/src/gcc/config/aarch64/aarch64.c 2017-07-11 17:43:46.575579185 +0000 +@@ -8956,7 +8956,8 @@ aarch64_classify_symbol (rtx x, rtx offs + /* This is alright even in PIC code as the constant + pool reference is always PC relative and within + the same translation unit. */ +- if (CONSTANT_POOL_ADDRESS_P (x)) ++ if (!aarch64_pcrelative_literal_loads ++ && CONSTANT_POOL_ADDRESS_P (x)) + return SYMBOL_SMALL_ABSOLUTE; + else + return SYMBOL_FORCE_TO_MEM; only in patch2: unchanged: --- gcc-5-5.4.0.orig/debian/patches/mpc-relative-literal-loads-rename.diff +++ gcc-5-5.4.0/debian/patches/mpc-relative-literal-loads-rename.diff @@ -0,0 +1,186 @@ +Description: Backport mpc-relative-literal-loads option rename + This is a backport of a change from the linaro gcc-6 branch (by Yvan Roux), + which is itself a backport of a change by Wilco Dijkstra to the FSF tree. It + is included to simplify the backport of the fix for LP: #1695093. Original + commit message follows: + . + This patch cleans up the -mpc-relative-loads option processing. Rename to + avoid the confusing nopcrelative_literal_loads names. Fix the option + processing code to correctly support -mno-pc-relative-loads rather than + ignore it. + . + Fixed-Upstream: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=237607 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1695093 +Author: Wilco Dijkstra +Author: Yvan Roux +Author: dann frazier +Last-Update: 2017-07-11 +--- + +diff -urpN a/src/gcc/config/aarch64/aarch64.c b/src/gcc/config/aarch64/aarch64.c +--- a/src/gcc/config/aarch64/aarch64.c 2017-07-07 17:46:36.843930894 -0400 ++++ b/src/gcc/config/aarch64/aarch64.c 2017-07-10 12:36:14.637669913 -0400 +@@ -185,7 +185,7 @@ enum aarch64_processor aarch64_tune = co + unsigned long aarch64_tune_flags = 0; + + /* Global flag for PC relative loads. */ +-bool aarch64_nopcrelative_literal_loads; ++bool aarch64_pcrelative_literal_loads; + + /* Support for command line parsing of boolean flags in the tuning + structures. */ +@@ -1639,7 +1639,7 @@ aarch64_expand_mov_immediate (rtx dest, + we need to expand the literal pool access carefully. + This is something that needs to be done in a number + of places, so could well live as a separate function. */ +- if (aarch64_nopcrelative_literal_loads) ++ if (!aarch64_pcrelative_literal_loads) + { + gcc_assert (can_create_pseudo_p ()); + base = gen_reg_rtx (ptr_mode); +@@ -3779,7 +3779,7 @@ aarch64_classify_address (struct aarch64 + return ((GET_CODE (sym) == LABEL_REF + || (GET_CODE (sym) == SYMBOL_REF + && CONSTANT_POOL_ADDRESS_P (sym) +- && !aarch64_nopcrelative_literal_loads))); ++ && aarch64_pcrelative_literal_loads))); + } + return false; + +@@ -5041,7 +5041,7 @@ aarch64_secondary_reload (bool in_p ATTR + if (MEM_P (x) && GET_CODE (x) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (x) + && (SCALAR_FLOAT_MODE_P (GET_MODE (x)) + || targetm.vector_mode_supported_p (GET_MODE (x))) +- && aarch64_nopcrelative_literal_loads) ++ && !aarch64_pcrelative_literal_loads) + { + sri->icode = aarch64_constant_pool_reload_icode (mode); + return NO_REGS; +@@ -7673,32 +7673,31 @@ aarch64_override_options_after_change_1 + opts->x_align_functions = aarch64_tune_params.function_align; + } + +- /* If nopcrelative_literal_loads is set on the command line, this ++ /* We default to no pc-relative literal loads. */ ++ ++ aarch64_pcrelative_literal_loads = false; ++ ++ /* If -mpc-relative-literal-loads is set on the command line, this + implies that the user asked for PC relative literal loads. */ +- if (opts->x_nopcrelative_literal_loads == 1) +- aarch64_nopcrelative_literal_loads = false; ++ if (opts->x_pcrelative_literal_loads == 1) ++ aarch64_pcrelative_literal_loads = true; + +- /* If it is not set on the command line, we default to no pc +- relative literal loads, unless the workaround for Cortex-A53 +- erratum 843419 is in effect. */ + /* This is PR70113. When building the Linux kernel with + CONFIG_ARM64_ERRATUM_843419, support for relocations + R_AARCH64_ADR_PREL_PG_HI21 and R_AARCH64_ADR_PREL_PG_HI21_NC is + removed from the kernel to avoid loading objects with possibly +- offending sequences. With nopcrelative_literal_loads, we would ++ offending sequences. Without -mpc-relative-literal-loads we would + generate such relocations, preventing the kernel build from + succeeding. */ +- if (opts->x_nopcrelative_literal_loads == 2 +- && !TARGET_FIX_ERR_A53_843419) +- aarch64_nopcrelative_literal_loads = true; +- +- /* In the tiny memory model it makes no sense +- to disallow non PC relative literal pool loads +- as many other things will break anyway. */ +- if (opts->x_nopcrelative_literal_loads +- && (aarch64_cmodel == AARCH64_CMODEL_TINY +- || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC)) +- aarch64_nopcrelative_literal_loads = false; ++ if (opts->x_pcrelative_literal_loads == 2 ++ && TARGET_FIX_ERR_A53_843419) ++ aarch64_pcrelative_literal_loads = true; ++ ++ /* In the tiny memory model it makes no sense to disallow PC relative ++ literal pool loads. */ ++ if (aarch64_cmodel == AARCH64_CMODEL_TINY ++ || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC) ++ aarch64_pcrelative_literal_loads = true; + } + + /* 'Unpack' up the internal tuning structs and update the options +@@ -8913,18 +8912,6 @@ aarch64_classify_symbol (rtx x, rtx offs + + if (GET_CODE (x) == SYMBOL_REF) + { +- if (aarch64_cmodel == AARCH64_CMODEL_LARGE) +- { +- /* This is alright even in PIC code as the constant +- pool reference is always PC relative and within +- the same translation unit. */ +- if (nopcrelative_literal_loads +- && CONSTANT_POOL_ADDRESS_P (x)) +- return SYMBOL_SMALL_ABSOLUTE; +- else +- return SYMBOL_FORCE_TO_MEM; +- } +- + if (aarch64_tls_symbol_p (x)) + return aarch64_classify_tls_symbol (x); + +@@ -8965,6 +8952,15 @@ aarch64_classify_symbol (rtx x, rtx offs + ? SYMBOL_SMALL_GOT_28K : SYMBOL_SMALL_GOT_4G); + return SYMBOL_SMALL_ABSOLUTE; + ++ case AARCH64_CMODEL_LARGE: ++ /* This is alright even in PIC code as the constant ++ pool reference is always PC relative and within ++ the same translation unit. */ ++ if (CONSTANT_POOL_ADDRESS_P (x)) ++ return SYMBOL_SMALL_ABSOLUTE; ++ else ++ return SYMBOL_FORCE_TO_MEM; ++ + default: + gcc_unreachable (); + } +diff -urpN a/src/gcc/config/aarch64/aarch64.md b/src/gcc/config/aarch64/aarch64.md +--- a/src/gcc/config/aarch64/aarch64.md 2017-07-07 17:46:36.847930911 -0400 ++++ b/src/gcc/config/aarch64/aarch64.md 2017-07-10 12:36:14.637669913 -0400 +@@ -4718,7 +4718,7 @@ + [(set (match_operand:GPF_TF 0 "register_operand" "=w") + (mem:GPF_TF (match_operand 1 "aarch64_constant_pool_symref" "S"))) + (clobber (match_operand:P 2 "register_operand" "=&r"))] +- "TARGET_FLOAT && aarch64_nopcrelative_literal_loads" ++ "TARGET_FLOAT && !aarch64_pcrelative_literal_loads" + { + aarch64_expand_mov_immediate (operands[2], XEXP (operands[1], 0)); + emit_move_insn (operands[0], gen_rtx_MEM (mode, operands[2])); +@@ -4731,7 +4731,7 @@ + [(set (match_operand:VALL 0 "register_operand" "=w") + (mem:VALL (match_operand 1 "aarch64_constant_pool_symref" "S"))) + (clobber (match_operand:P 2 "register_operand" "=&r"))] +- "TARGET_FLOAT && aarch64_nopcrelative_literal_loads" ++ "TARGET_FLOAT && !aarch64_pcrelative_literal_loads" + { + aarch64_expand_mov_immediate (operands[2], XEXP (operands[1], 0)); + emit_move_insn (operands[0], gen_rtx_MEM (mode, operands[2])); +diff -urpN a/src/gcc/config/aarch64/aarch64.opt b/src/gcc/config/aarch64/aarch64.opt +--- a/src/gcc/config/aarch64/aarch64.opt 2017-07-07 17:46:36.847930911 -0400 ++++ b/src/gcc/config/aarch64/aarch64.opt 2017-07-10 12:36:14.637669913 -0400 +@@ -146,5 +146,5 @@ EnumValue + Enum(aarch64_abi) String(lp64) Value(AARCH64_ABI_LP64) + + mpc-relative-literal-loads +-Target Report Save Var(nopcrelative_literal_loads) Init(2) Save ++Target Report Save Var(pcrelative_literal_loads) Init(2) Save + PC relative literal loads. +diff -urpN a/src/gcc/config/aarch64/aarch64-protos.h b/src/gcc/config/aarch64/aarch64-protos.h +--- a/src/gcc/config/aarch64/aarch64-protos.h 2017-07-07 17:46:36.827930826 -0400 ++++ b/src/gcc/config/aarch64/aarch64-protos.h 2017-07-10 12:36:14.633669900 -0400 +@@ -436,7 +436,7 @@ int aarch64_ccmp_mode_to_code (enum mach + bool extract_base_offset_in_addr (rtx mem, rtx *base, rtx *offset); + bool aarch64_operands_ok_for_ldpstp (rtx *, bool, enum machine_mode); + bool aarch64_operands_adjust_ok_for_ldpstp (rtx *, bool, enum machine_mode); +-extern bool aarch64_nopcrelative_literal_loads; ++extern bool aarch64_pcrelative_literal_loads; + + /* Defined in common/config/aarch64-common.c. */ + bool aarch64_handle_option (struct gcc_options *, struct gcc_options *,