This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Don't use small data accesses for weak symbols on MIPS
- From: Richard Sandiford <richard at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 08 Oct 2006 08:59:43 +0100
- Subject: Don't use small data accesses for weak symbols on MIPS
This patch fixes the attr-weakref-1.c failure on mipsisa64-elf. The
sizes of the variables in this test fall within the default small data
limit, so gcc was trying to use %gp_rel accesses. This isn't valid for
weak symbols as they may end up being zero. (This is true of
locally-defined objects too, if overridden by a strong definition
of zero. AIUI, gcc does support that case.)
Weak symbols should continue to be into the small data section
if they are small enough -- for compatibility reasons if nothing
else -- so the patch changes mips_classify_symbol instead.
Tested on mipsisa64-elf and applied.
Richard
gcc/
* config/mips/mips.c (mips_classify_symbol): Do not return
SYMBOL_SMALL_DATA if SYMBOL_REF_WEAK.
(mips_in_small_data_p): Tweak comments.
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c (revision 117551)
+++ gcc/config/mips/mips.c (working copy)
@@ -1221,7 +1221,10 @@ mips_classify_symbol (rtx x)
return SYMBOL_SMALL_DATA;
}
- if (SYMBOL_REF_SMALL_P (x))
+ /* Do not use small-data accesses for weak symbols; they may end up
+ being zero. */
+ if (SYMBOL_REF_SMALL_P (x)
+ && !SYMBOL_REF_WEAK (x))
return SYMBOL_SMALL_DATA;
if (TARGET_ABICALLS)
@@ -7313,8 +7316,10 @@ mips_function_rodata_section (tree decl)
return data_section;
}
-/* Implement TARGET_IN_SMALL_DATA_P. Return true if it would be safe to
- access DECL using %gp_rel(...)($gp). */
+/* Implement TARGET_IN_SMALL_DATA_P. This function controls whether
+ locally-defined objects go in a small data section. It also controls
+ the setting of the SYMBOL_REF_SMALL_P flag, which in turn helps
+ mips_classify_symbol decide when to use %gp_rel(...)($gp) accesses. */
static bool
mips_in_small_data_p (tree decl)