This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
mips address splitting breaks named section support
- To: Jim Wilson <wilson at cygnus dot com>
- Subject: mips address splitting breaks named section support
- From: Gavin Romig-Koch <gavin at cygnus dot com>
- Date: Wed, 29 Jul 1998 12:57:53 -0400 (EDT)
- CC: egcs-patches at cygnus dot com
I think mips cc1's address splitting code is conflicting with
gas' generation of gp relative references to objects specifically
put in the named .sdata section. If optimization is turned on,
CC1 is splitting the address of objects placed into the .sdata
section, and so gas doesn't generated a gp relative address for
the object. In contrast, CC1 does not split the address of
objects who's size is under the -G threshold (thus allowing gas
to generate a gp reference to it).
This patch changes CC1's treatment of objects in named sections
to be the same as that of objects under the -G threshold.
OK to push to EGCS?
-gavin...
For example:
int i __attribute__((section(".sdata"))) = 0;
int k;
extern int j;
void func ( int jj )
{
i = j;
k = i;
}
$ gcc -G 0 -O4 test.c
Patch:
* mips/mips.h (ENCODE_SECTION_INFO): Set SYMBOL_REF_FLAG for
VAR_DECL's in named sections.
Index: config/mips/mips.h
===================================================================
***************
*** 3123,3130 ****
constants which are put in the .text section. We also record the
total length of all such strings; this total is used to decide
whether we need to split the constant table, and need not be
! precisely correct. */
#define ENCODE_SECTION_INFO(DECL) \
do \
{ \
--- 3123,3136 ----
constants which are put in the .text section. We also record the
total length of all such strings; this total is used to decide
whether we need to split the constant table, and need not be
! precisely correct.
+ When not mips16 code nor embedded PIC, if a symbol is in a
+ particular section, SYMBOL_REF_FLAG is set prevent gcc from
+ splitting the reference so that gas can generate a gp relative
+ reference (just like optimizing for $gp pointer).
+ */
+
#define ENCODE_SECTION_INFO(DECL) \
do \
{ \
***************
*** 3148,3153 ****
--- 3154,3165 ----
SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (DECL), 0)) = 0; \
else \
SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (DECL), 0)) = 1; \
+ } \
+ \
+ else if (TREE_CODE (DECL) == VAR_DECL \
+ && DECL_SECTION_NAME (DECL) != NULL_TREE) \
+ { \
+ SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1; \
} \
\
else if (TARGET_GP_OPT && TREE_CODE (DECL) == VAR_DECL) \