diff --git a/gcc/varasm.c b/gcc/varasm.c
index 310647e..bb4721b 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -6621,15 +6621,15 @@ default_binds_local_p_1 (const_tree exp, int shlib)
     local_p = false;
   /* If defined in this object and visibility is not default, must be
      local.  */
-  else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
-    local_p = true;
-  /* Default visibility weak data can be overridden by a strong symbol
-     in another module and so are not local.  */
   else if (DECL_WEAK (exp))
     local_p = false;
   /* If PIC, then assume that any global name can be overridden by
      symbols resolved from other modules, unless we are compiling with
      -fwhole-program, which assumes that names are local.  */
+  else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
+    local_p = true;
+  /* Default visibility weak data can be overridden by a strong symbol
+     in another module and so are not local.  */
   else if (shlib)
     local_p = flag_whole_program;
   /* Uninitialized COMMON variable may be unified with symbols
