Hi, PR 78253 shows that the handling of weak references has changed for ARM with gcc-5.
When r220674 was committed, default_binds_local_p_2 gained a new parameter (weak_dominate), which, when true, implies that a reference to a weak symbol defined locally will be resolved locally, even though it could be overridden by a strong definition in another object file. With r220674, default_binds_local_p forces weak_dominate=true, effectively changing the previous behavior. The attached patch introduces default_binds_local_p_4 which is a copy of default_binds_local_p_2, but using weak_dominate=false, and updates the ARM target to call default_binds_local_p_4 instead of default_binds_local_p_2. I ran cross-tests on various arm* configurations with no regression, and checked that the test attached to the original bugzilla now works as expected. I am not sure why weak_dominate defaults to true, and I couldn't really understand why by reading the threads related to r220674 and following updates to default_binds_local_p_* which all deal with other corner cases and do not discuss the weak_dominate parameter. Or should this patch be made more generic? Thanks, Christophe
2016-11-09 Christophe Lyon <christophe.l...@linaro.org> PR target/78253 * output.h (default_binds_local_p_4): New. * varasm.c (default_binds_local_p_4): New, use weak_dominate=false. * config/arm/linux-elf.h (TARGET_BINDS_LOCAL_P): Define to default_binds_local_p_4.
diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h index cc17b51..4f32ce8 100644 --- a/gcc/config/arm/linux-elf.h +++ b/gcc/config/arm/linux-elf.h @@ -110,7 +110,7 @@ strong definitions in dependent shared libraries, will resolve to COPY relocated symbol in the executable. See PR65780. */ #undef TARGET_BINDS_LOCAL_P -#define TARGET_BINDS_LOCAL_P default_binds_local_p_2 +#define TARGET_BINDS_LOCAL_P default_binds_local_p_4 /* Define this to be nonzero if static stack checking is supported. */ #define STACK_CHECK_STATIC_BUILTIN 1 diff --git a/gcc/output.h b/gcc/output.h index 0924499..11b5ce5 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -585,6 +585,7 @@ extern bool default_binds_local_p (const_tree); extern bool default_binds_local_p_1 (const_tree, int); extern bool default_binds_local_p_2 (const_tree); extern bool default_binds_local_p_3 (const_tree, bool, bool, bool, bool); +extern bool default_binds_local_p_4 (const_tree); extern void default_globalize_label (FILE *, const char *); extern void default_globalize_decl_name (FILE *, tree); extern void default_emit_unwind_label (FILE *, tree, int, int); diff --git a/gcc/varasm.c b/gcc/varasm.c index 6a7ffc2..7a3cf99 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6952,6 +6952,16 @@ default_binds_local_p_2 (const_tree exp) !flag_pic); } +/* Similar to default_binds_local_p_2, but local weak definition does + not imply local resolution (weak_dominate is false). */ + +bool +default_binds_local_p_4 (const_tree exp) +{ + return default_binds_local_p_3 (exp, flag_shlib != 0, false, true, + !flag_pic); +} + bool default_binds_local_p_1 (const_tree exp, int shlib) {