From 3b516badec25151acd4a96fa4ef07b3f88e3f053 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 12 Feb 2015 10:55:55 -0800
Subject: [PATCH] A variable is local if specified by user
And it is resolved or defined locally, not compiling for PIC or not weak.
---
gcc/varasm.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
@@ -6838,15 +6838,21 @@ default_binds_local_p_2 (const_tree exp, bool shlib, bool weak_dominate)
resolved_locally = true;
}
- /* Undefined (or non-dominant) weak symbols are not defined locally. */
- if (DECL_WEAK (exp) && !resolved_locally)
- return false;
-
- /* A variable is local if the user has said explicitly that it will be. */
+ /* A variable is local if the user has said explicitly that it will
+ be and it is resolved or defined locally, not compiling for PIC or
+ not weak. */
if (DECL_VISIBILITY_SPECIFIED (exp)
+ && (resolved_locally
+ || !flag_pic
+ || !DECL_EXTERNAL (exp)
+ || !DECL_WEAK (exp))
&& DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
return true;
+ /* Undefined (or non-dominant) weak symbols are not defined locally. */
+ if (DECL_WEAK (exp) && !resolved_locally)
+ return false;
+
/* Variables defined outside this object might not be local. */
if (DECL_EXTERNAL (exp) && !resolved_locally)
return false;
--
1.9.3