This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Mips patch to UNIQUE_SECTION (committed)
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 03 May 2002 18:10:37 +0100
- Subject: Mips patch to UNIQUE_SECTION (committed)
This patch applies the usual asm-fs-1 fix to mips's UNIQUE_SECTION.
It also removes the elf64.h version, which was identical to the
mips.c one.
Tested on mips64-elf, approved by Eric, committed.
Richard
* config/mips/elf64.h (UNIQUE_SECTION): Use mips_unique_section.
* config/mips/mips.c (mips_unique_section): Strip encoding from
decl name.
Index: config/mips/elf64.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/config/mips/elf64.h,v
retrieving revision 1.67
diff -c -p -d -r1.67 elf64.h
*** config/mips/elf64.h 2002/03/22 13:12:34 1.67
--- config/mips/elf64.h 2002/04/19 11:38:53
*************** do { \
*** 209,279 ****
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
#undef UNIQUE_SECTION
! #define UNIQUE_SECTION(DECL,RELOC) \
! do { \
! int len, size, sec; \
! const char *name, *prefix; \
! char *string; \
! static const char *const prefixes[4][2] = { \
! { ".text.", ".gnu.linkonce.t." }, \
! { ".rodata.", ".gnu.linkonce.r." }, \
! { ".data.", ".gnu.linkonce.d." }, \
! { ".sdata.", ".gnu.linkonce.s." } \
! }; \
! \
! name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
! size = int_size_in_bytes (TREE_TYPE (decl)); \
! \
! /* Determine the base section we are interested in: \
! 0=text, 1=rodata, 2=data, 3=sdata, [4=bss]. */ \
! if (TREE_CODE (DECL) == FUNCTION_DECL) \
! sec = 0; \
! else if (DECL_INITIAL (DECL) == 0 \
! || DECL_INITIAL (DECL) == error_mark_node) \
! sec = 2; \
! else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) \
! && TREE_CODE (decl) == STRING_CST \
! && !flag_writable_strings) \
! { \
! /* For embedded position independent code, put constant strings \
! in the text section, because the data section is limited to \
! 64K in size. For mips16 code, put strings in the text \
! section so that a PC relative load instruction can be used to \
! get their address. */ \
! sec = 0; \
! } \
! else if (TARGET_EMBEDDED_DATA) \
! { \
! /* For embedded applications, always put an object in read-only data \
! if possible, in order to reduce RAM usage. */ \
! \
! if (DECL_READONLY_SECTION (DECL, RELOC)) \
! sec = 1; \
! else if (size > 0 && size <= mips_section_threshold) \
! sec = 3; \
! else \
! sec = 2; \
! } \
! else \
! { \
! /* For hosted applications, always put an object in small data if \
! possible, as this gives the best performance. */ \
! \
! if (size > 0 && size <= mips_section_threshold) \
! sec = 3; \
! else if (DECL_READONLY_SECTION (DECL, RELOC)) \
! sec = 1; \
! else \
! sec = 2; \
! } \
! \
! prefix = prefixes[sec][DECL_ONE_ONLY (DECL)]; \
! len = strlen (name) + strlen (prefix); \
! string = alloca (len + 1); \
! sprintf (string, "%s%s", prefix, name); \
! \
! DECL_SECTION_NAME (DECL) = build_string (len, string); \
! } while (0)
/* A list of other sections which the compiler might be "in" at any
given time. */
--- 209,216 ----
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
#undef UNIQUE_SECTION
! #define UNIQUE_SECTION(DECL,RELOC) \
! mips_unique_section ((DECL), (RELOC))
/* A list of other sections which the compiler might be "in" at any
given time. */
Index: config/mips/mips.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/config/mips/mips.c,v
retrieving revision 1.278.2.7
diff -c -p -d -r1.278.2.7 mips.c
*** config/mips/mips.c 2002/04/19 08:00:36 1.278.2.7
--- config/mips/mips.c 2002/04/19 11:38:54
*************** mips_unique_section (decl, reloc)
*** 11819,11824 ****
--- 11967,11973 ----
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
size = int_size_in_bytes (TREE_TYPE (decl));
+ STRIP_NAME_ENCODING (name, name);
/* Determine the base section we are interested in:
0=text, 1=rodata, 2=data, 3=sdata, [4=bss]. */