aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2017-01-12 13:49:58 +0100
committerYvan Roux <yvan.roux@linaro.org>2017-01-17 22:48:37 +0100
commite2d9470e70c308801630031771c9d709efb4d6a1 (patch)
tree142331e1af9bb28a135e6af861179f22bc47dccf
parentb8cc503ec1640707a7ae4fae7953c42a85dfa8e1 (diff)
gcc/
Backport from trunk r244320. 2017-01-11 Christophe Lyon <christophe.lyon@linaro.org> PR target/78253 * config/arm/arm.c (legitimize_pic_address): Handle reference to weak symbol. (arm_assemble_integer): Likewise. Change-Id: Ie610a0e65939a37b6a3bb49be23f3568b5e4bb93
-rw-r--r--gcc/config/arm/arm.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 08e3f4cc499..1038ab11040 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -6863,9 +6863,13 @@ legitimize_pic_address (rtx orig, machine_mode mode, rtx reg)
same segment as the GOT. Unfortunately, the flexibility of linker
scripts means that we can't be sure of that in general, so assume
that GOTOFF is never valid on VxWorks. */
+ /* References to weak symbols cannot be resolved locally: they
+ may be overridden by a non-weak definition at link time. */
if ((GET_CODE (orig) == LABEL_REF
- || (GET_CODE (orig) == SYMBOL_REF &&
- SYMBOL_REF_LOCAL_P (orig)))
+ || (GET_CODE (orig) == SYMBOL_REF
+ && SYMBOL_REF_LOCAL_P (orig)
+ && (SYMBOL_REF_DECL (orig)
+ ? !DECL_WEAK (SYMBOL_REF_DECL (orig)) : 1)))
&& NEED_GOT_RELOC
&& arm_pic_data_is_text_relative)
insn = arm_pic_static_addr (orig, reg);
@@ -22422,8 +22426,14 @@ arm_assemble_integer (rtx x, unsigned int size, int aligned_p)
{
/* See legitimize_pic_address for an explanation of the
TARGET_VXWORKS_RTP check. */
+ /* References to weak symbols cannot be resolved locally:
+ they may be overridden by a non-weak definition at link
+ time. */
if (!arm_pic_data_is_text_relative
- || (GET_CODE (x) == SYMBOL_REF && !SYMBOL_REF_LOCAL_P (x)))
+ || (GET_CODE (x) == SYMBOL_REF
+ && (!SYMBOL_REF_LOCAL_P (x)
+ || (SYMBOL_REF_DECL (x)
+ ? DECL_WEAK (SYMBOL_REF_DECL (x)) : 0))))
fputs ("(GOT)", asm_out_file);
else
fputs ("(GOTOFF)", asm_out_file);