From: Christophe Lyon Date: Fri, 13 Jan 2017 13:11:07 +0000 (+0000) Subject: backport: re PR target/78253 ([ARM] call weak function instead of strong when called... X-Git-Tag: releases/gcc-5.5.0~588 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=570fd49c50e6a9db1ea6f55e34a4edc386ea7077;p=thirdparty%2Fgcc.git backport: re PR target/78253 ([ARM] call weak function instead of strong when called through pointer) 2017-01-11 Christophe Lyon Backport from mainline r244320. 2017-01-11 Christophe Lyon PR target/78253 * config/arm/arm.c (legitimize_pic_address): Handle reference to weak symbol. (arm_assemble_integer): Likewise. From-SVN: r244438 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 81888b4ed12a..1a56b1c5d072 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2017-01-11 Christophe Lyon + + Backport from mainline r244320. + 2017-01-11 Christophe Lyon + + PR target/78253 + * config/arm/arm.c (legitimize_pic_address): Handle reference to + weak symbol. + (arm_assemble_integer): Likewise. + 2016-01-12 Kyrylo Tkachov * postreload.c (reload_cse_simplify): Check for NO_FUNCTION_CSE diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 5c975625bfa2..6f9518995a38 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -6631,9 +6631,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); @@ -22438,8 +22442,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);