diff options
author | Jason Merrill <merrill@gnu.org> | 1997-04-30 18:13:30 +0000 |
---|---|---|
committer | Jason Merrill <merrill@gnu.org> | 1997-04-30 18:13:30 +0000 |
commit | ad4ff31086d8e338ebd7b30725145f6ad57d63ae (patch) | |
tree | 08953da2d888b7041436e28ef4a8fa401e61163b | |
parent | a4b3b54a70b9c9cccd9b715ec896e25bfc48131f (diff) | |
download | gcc-ad4ff31086d8e338ebd7b30725145f6ad57d63ae.zip gcc-ad4ff31086d8e338ebd7b30725145f6ad57d63ae.tar.gz gcc-ad4ff31086d8e338ebd7b30725145f6ad57d63ae.tar.bz2 |
x
From-SVN: r13994
-rw-r--r-- | gcc/config/a29k/a29k.h | 2 | ||||
-rw-r--r-- | gcc/config/alpha/elf.h | 4 | ||||
-rw-r--r-- | gcc/config/arm/coff.h | 4 | ||||
-rw-r--r-- | gcc/config/h8300/h8300.h | 2 | ||||
-rw-r--r-- | gcc/config/i386/cygwin32.h | 17 | ||||
-rw-r--r-- | gcc/config/i386/go32.h | 7 | ||||
-rw-r--r-- | gcc/config/i386/sco5.h | 6 | ||||
-rw-r--r-- | gcc/config/i386/winnt.c | 5 | ||||
-rw-r--r-- | gcc/config/m68k/coff.h | 4 | ||||
-rw-r--r-- | gcc/config/mips/elf64.h | 4 | ||||
-rw-r--r-- | gcc/config/mips/iris6.h | 4 | ||||
-rw-r--r-- | gcc/config/mips/netbsd.h | 4 | ||||
-rw-r--r-- | gcc/config/pa/pa.h | 4 | ||||
-rw-r--r-- | gcc/config/psos.h | 4 | ||||
-rw-r--r-- | gcc/config/ptx4.h | 4 | ||||
-rw-r--r-- | gcc/config/rs6000/sysv4.h | 4 | ||||
-rw-r--r-- | gcc/config/sh/sh.h | 2 | ||||
-rw-r--r-- | gcc/config/sparc/sysv4.h | 4 | ||||
-rw-r--r-- | gcc/config/svr4.h | 46 | ||||
-rw-r--r-- | gcc/output.h | 16 | ||||
-rw-r--r-- | gcc/varasm.c | 67 |
21 files changed, 114 insertions, 100 deletions
diff --git a/gcc/config/a29k/a29k.h b/gcc/config/a29k/a29k.h index 2b607e7..59e9a13 100644 --- a/gcc/config/a29k/a29k.h +++ b/gcc/config/a29k/a29k.h @@ -1450,7 +1450,7 @@ extern int a29k_debug_reg_map[]; /* This how to write an assembler directive to FILE to switch to section NAME for DECL. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ fprintf (FILE, "\t.sect %s, bss\n\t.use %s\n", NAME, NAME) /* This is how to output the definition of a user-level label named NAME, diff --git a/gcc/config/alpha/elf.h b/gcc/config/alpha/elf.h index 62d00ad..6eb94cd 100644 --- a/gcc/config/alpha/elf.h +++ b/gcc/config/alpha/elf.h @@ -276,10 +276,10 @@ dtors_section () \ We make the section read-only and executable for a function decl, read-only for a const data decl, and writable for a non-const data decl. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \ (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ - (DECL) && TREE_READONLY (DECL) ? "a" : "aw") + (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw") /* A C statement (sans semicolon) to output an element in the table of diff --git a/gcc/config/arm/coff.h b/gcc/config/arm/coff.h index ebc8a8c..18a0718 100644 --- a/gcc/config/arm/coff.h +++ b/gcc/config/arm/coff.h @@ -87,11 +87,11 @@ do { \ NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or NULL_TREE. Some target formats do not support arbitrary sections. Do not define this macro in such cases. */ -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ do { \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \ - else if ((DECL) && TREE_READONLY (DECL)) \ + else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \ else \ fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \ diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h index 8e42f47..60a0532 100644 --- a/gcc/config/h8300/h8300.h +++ b/gcc/config/h8300/h8300.h @@ -1182,7 +1182,7 @@ readonly_data() \ NULL_TREE. Some target formats do not support arbitrary sections. Do not define this macro in such cases. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ fprintf (FILE, "\t.section %s\n", NAME) /* This is how to output the definition of a user-level label named NAME, diff --git a/gcc/config/i386/cygwin32.h b/gcc/config/i386/cygwin32.h index ec2661c..88b367b 100644 --- a/gcc/config/i386/cygwin32.h +++ b/gcc/config/i386/cygwin32.h @@ -172,27 +172,22 @@ while (0) symbols must be explicitly imported from shared libraries (DLLs). */ #define MULTIPLE_SYMBOL_SPACES -/* For objects going into their own sections, a C expression of name of the - section, expressed as a STRING_CST node, to put DECL into. The - STRING_CST node must be allocated in the saveable obstack. Function - build_string can be used to do this. Define this macro if the name of a - symbol cannot be used as its section name. */ -extern union tree_node *i386_pe_unique_section (); -#define UNIQUE_SECTION(DECL) i386_pe_unique_section (DECL) +#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL) +extern void i386_pe_unique_section (); +#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC) -#define MAKE_DECL_ONE_ONLY(DECL) \ - DECL_SECTION_NAME (DECL) = UNIQUE_SECTION (DECL) +#define SUPPORTS_ONE_ONLY 1 /* A C statement to output something to the assembler file to switch to section NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or NULL_TREE. Some target formats do not support arbitrary sections. Do not define this macro in such cases. */ #undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ do { \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \ - else if ((DECL) && TREE_READONLY (DECL)) \ + else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \ else \ fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \ diff --git a/gcc/config/i386/go32.h b/gcc/config/i386/go32.h index 933f184..c256f7d 100644 --- a/gcc/config/i386/go32.h +++ b/gcc/config/i386/go32.h @@ -58,7 +58,7 @@ dtor_section () \ } while (0) /* Allow (eg) __attribute__((section "locked")) to work */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME)\ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)\ do { \ fprintf (FILE, "\t.section %s\n", NAME); \ } while (0) @@ -81,11 +81,6 @@ dtor_section () \ output_file_directive (FILE, main_input_filename); \ } while (0) -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME)\ - do { \ - fprintf (FILE, "\t.section %s\n", NAME); \ - } while (0) - /* This is how to output an assembler line that says to advance the location counter to a multiple of 2**LOG bytes. */ diff --git a/gcc/config/i386/sco5.h b/gcc/config/i386/sco5.h index d156cab..d5471ec 100644 --- a/gcc/config/i386/sco5.h +++ b/gcc/config/i386/sco5.h @@ -477,18 +477,18 @@ do { \ #define USER_LABEL_PREFIX "" #undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ do { \ char *snam = NAME ; \ if (strcmp(NAME, ".gcc_except_table") == 0) snam = ".gccexc" ; \ if (TARGET_ELF) \ fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \ (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ - (DECL) && TREE_READONLY (DECL) ? "a" : "aw"); \ + (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw"); \ else \ fprintf (FILE, ".section\t%s,\"%s\"\n", snam, \ (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "x" : \ - (DECL) && TREE_READONLY (DECL) ? "a" : "w"); \ + (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "w"); \ } while (0) #undef ASM_OUTPUT_SKIP diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index 9a32aaa..7266692 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -67,8 +67,9 @@ gen_stdcall_suffix (decl) /* Cover function for UNIQUE_SECTION. */ tree -i386_pe_unique_section (decl) +i386_pe_unique_section (decl, reloc) tree decl; + int reloc; { int len; char *name,*string,*prefix; @@ -80,7 +81,7 @@ i386_pe_unique_section (decl) (everything from the $ on is stripped). */ if (TREE_CODE (decl) == FUNCTION_DECL) prefix = ".text$"; - else if (TREE_READONLY (decl)) + else if (DECL_READONLY_SECTION (decl, reloc)) prefix = ".rdata$"; else prefix = ".data$"; diff --git a/gcc/config/m68k/coff.h b/gcc/config/m68k/coff.h index 85b1061..acd45e7 100644 --- a/gcc/config/m68k/coff.h +++ b/gcc/config/m68k/coff.h @@ -103,10 +103,10 @@ Boston, MA 02111-1307, USA. */ /* Support generic sections */ #undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ fprintf((FILE), ".section\t%s,\"%c\"\n", (NAME), \ (DECL) && (TREE_CODE (DECL) == FUNCTION_DECL || \ - TREE_READONLY (DECL)) ? 'x' : 'd') + DECL_READONLY_SECTION (DECL, RELOC)) ? 'x' : 'd') /* Support the ctors and dtors sections for g++. */ diff --git a/gcc/config/mips/elf64.h b/gcc/config/mips/elf64.h index 358316c..3d1a91b 100644 --- a/gcc/config/mips/elf64.h +++ b/gcc/config/mips/elf64.h @@ -83,12 +83,12 @@ do { \ NULL_TREE. Some target formats do not support arbitrary sections. Do not define this macro in such cases. */ -#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \ do { \ extern FILE *asm_out_text_file; \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ - else if ((DECL) && TREE_READONLY (DECL)) \ + else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \ else \ fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \ diff --git a/gcc/config/mips/iris6.h b/gcc/config/mips/iris6.h index c9ec59d..dd99145 100644 --- a/gcc/config/mips/iris6.h +++ b/gcc/config/mips/iris6.h @@ -338,12 +338,12 @@ dtors_section () \ NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or NULL_TREE. */ -#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \ do { \ extern FILE *asm_out_text_file; \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ fprintf (asm_out_text_file, "\t.section %s,1,6,4,4\n", (NAME)); \ - else if ((DECL) && TREE_READONLY (DECL)) \ + else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ fprintf (F, "\t.section %s,1,2,0,8\n", (NAME)); \ else \ fprintf (F, "\t.section %s,1,3,0,8\n", (NAME)); \ diff --git a/gcc/config/mips/netbsd.h b/gcc/config/mips/netbsd.h index 1973cc3..9ed8dfd 100644 --- a/gcc/config/mips/netbsd.h +++ b/gcc/config/mips/netbsd.h @@ -211,12 +211,12 @@ do { \ NULL_TREE. Some target formats do not support arbitrary sections. Do not define this macro in such cases. */ -#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \ do { \ extern FILE *asm_out_text_file; \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ - else if ((DECL) && TREE_READONLY (DECL)) \ + else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \ else \ fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \ diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 30a070b..4751a8d 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -1976,7 +1976,7 @@ do { fputs ("\t.SPACE $PRIVATE$\n\ We make the section read-only and executable for a function decl, read-only for a const data decl, and writable for a non-const data decl. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ { \ fputs ("\t.SPACE $TEXT$\n", FILE); \ @@ -1984,7 +1984,7 @@ do { fputs ("\t.SPACE $PRIVATE$\n\ "\t.SUBSPA %s%s%s,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY,SORT=24\n",\ TARGET_GAS ? "" : "$", NAME, TARGET_GAS ? "" : "$"); \ } \ - else if (DECL && TREE_READONLY (DECL)) \ + else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ { \ fputs ("\t.SPACE $TEXT$\n", FILE); \ fprintf (FILE, \ diff --git a/gcc/config/psos.h b/gcc/config/psos.h index 0299a35..d404300 100644 --- a/gcc/config/psos.h +++ b/gcc/config/psos.h @@ -87,10 +87,10 @@ while (0) /* Switch into a generic section. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \ (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ - (DECL) && TREE_READONLY (DECL) ? "a" : "aw") + (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw") /* Define the pseudo-ops used to switch to the .ctors and .dtors diff --git a/gcc/config/ptx4.h b/gcc/config/ptx4.h index 7bda47c..80b7b16 100644 --- a/gcc/config/ptx4.h +++ b/gcc/config/ptx4.h @@ -541,10 +541,10 @@ dtors_section () \ We make the section read-only and executable for a function decl, read-only for a const data decl, and writable for a non-const data decl. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \ (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ - (DECL) && TREE_READONLY (DECL) ? "a" : "aw") + (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw") /* A C statement (sans semicolon) to output an element in the table of diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index 867b328..635bb32 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -865,7 +865,7 @@ do { \ */ #undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ do { \ static struct section_info \ { \ @@ -883,7 +883,7 @@ do { \ \ if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ type = SECT_EXEC, mode = "ax"; \ - else if (DECL && TREE_READONLY (DECL) && !TARGET_RELOCATABLE && !flag_pic) \ + else if (DECL && DECL_READONLY_SECTION (DECL, RELOC) && !TARGET_RELOCATABLE && !flag_pic) \ type = SECT_RO, mode = "a"; \ else \ type = SECT_RW, mode = "aw"; \ diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index e88fa08..022c9bc 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -1373,7 +1373,7 @@ dtors_section() \ NULL_TREE. Some target formats do not support arbitrary sections. Do not define this macro in such cases. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ do { fprintf (FILE, ".section\t%s\n", NAME); } while (0) #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ diff --git a/gcc/config/sparc/sysv4.h b/gcc/config/sparc/sysv4.h index 4dfde2a..96e49f9 100644 --- a/gcc/config/sparc/sysv4.h +++ b/gcc/config/sparc/sysv4.h @@ -186,12 +186,12 @@ do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3); \ define this macro in such cases. */ #undef ASM_OUTPUT_SECTION_NAME /* Override svr4.h's definition. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ do { \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ fprintf (FILE, ".section\t\"%s%s\",#alloc,#execinstr\n", \ flag_function_sections ? ".text%" : "", (NAME)); \ - else if ((DECL) && TREE_READONLY (DECL)) \ + else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ fprintf (FILE, ".section\t\"%s\",#alloc\n", (NAME)); \ else \ fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME)); \ diff --git a/gcc/config/svr4.h b/gcc/config/svr4.h index 19d566d..d70aa11 100644 --- a/gcc/config/svr4.h +++ b/gcc/config/svr4.h @@ -593,19 +593,17 @@ dtors_section () \ } \ } - -/* - * Switch into a generic section. - * - * We make the section read-only and executable for a function decl, - * read-only for a const data decl, and writable for a non-const data decl. - * - * If the section has already been defined, we must not - * emit the attributes here. The SVR4 assembler does not - * recognize section redefinitions. - * If DECL is NULL, no attributes are emitted. - */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ +/* Switch into a generic section. + + We make the section read-only and executable for a function decl, + read-only for a const data decl, and writable for a non-const data decl. + + If the section has already been defined, we must not + emit the attributes here. The SVR4 assembler does not + recognize section redefinitions. + If DECL is NULL, no attributes are emitted. */ + +#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ do { \ static struct section_info \ { \ @@ -623,7 +621,7 @@ do { \ \ if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ type = SECT_EXEC, mode = "ax"; \ - else if (DECL && TREE_READONLY (DECL)) \ + else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ type = SECT_RO, mode = "a"; \ else \ type = SECT_RW, mode = "aw"; \ @@ -647,21 +645,20 @@ do { \ } \ } while (0) -/* A C statement (sans semicolon) to mark DECL to be emitted as a - public symbol such that extra copies in multiple translation units will - be discarded by the linker. */ -#define MAKE_DECL_ONE_ONLY(DECL) \ +#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) +#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) +#define UNIQUE_SECTION(DECL,RELOC) \ do { \ int len; \ char *name, *string, *prefix; \ \ - DECL_WEAK (DECL) = 1; \ - \ name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ \ - if (TREE_CODE (DECL) == FUNCTION_DECL) \ + if (! DECL_ONE_ONLY (DECL)) \ + prefix = "."; \ + else if (TREE_CODE (DECL) == FUNCTION_DECL) \ prefix = ".gnu.linkonce.t."; \ - else if (TREE_READONLY (DECL)) \ + else if (DECL_READONLY_SECTION (DECL, RELOC)) \ prefix = ".gnu.linkonce.r."; \ else \ prefix = ".gnu.linkonce.d."; \ @@ -711,10 +708,7 @@ do { \ } \ else if (TREE_CODE (DECL) == VAR_DECL) \ { \ - if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ - || !DECL_INITIAL (DECL) \ - || (DECL_INITIAL (DECL) != error_mark_node \ - && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \ + if (! DECL_READONLY_SECTION (DECL, RELOC)) \ data_section (); \ else \ const_section (); \ diff --git a/gcc/output.h b/gcc/output.h index 8722b64..749043b 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -134,8 +134,9 @@ extern int in_text_section PROTO((void)); #ifdef TREE_CODE /* Tell assembler to change to section NAME for DECL. If DECL is NULL, just switch to section NAME. - If NAME is NULL, get the name from DECL. */ -extern void named_section PROTO((tree, char *)); + If NAME is NULL, get the name from DECL. + If RELOC is 1, the initializer for DECL contains relocs. */ +extern void named_section PROTO((tree, char *, int)); /* Tell assembler to switch to the section for function DECL. */ extern void function_section PROTO((tree)); @@ -429,3 +430,14 @@ extern int sdb_begin_function_line; #ifdef BUFSIZ extern FILE *asm_out_file; #endif + +/* Decide whether DECL needs to be in a writable section. RELOC is the same + as for SELECT_SECTION. */ + +#define DECL_READONLY_SECTION(DECL,RELOC) \ + (TREE_READONLY (DECL) \ + && ! TREE_THIS_VOLATILE (DECL) \ + && DECL_INITIAL (DECL) \ + && (DECL_INITIAL (DECL) == error_mark_node \ + || TREE_CONSTANT (DECL_INITIAL (DECL))) \ + && ! (RELOC && (flag_pic || DECL_ONE_ONLY (DECL)))) diff --git a/gcc/varasm.c b/gcc/varasm.c index c422fbc..3d4e87a 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -250,12 +250,14 @@ in_data_section () /* Tell assembler to change to section NAME for DECL. If DECL is NULL, just switch to section NAME. - If NAME is NULL, get the name from DECL. */ + If NAME is NULL, get the name from DECL. + If RELOC is 1, the initializer for DECL contains relocs. */ void -named_section (decl, name) +named_section (decl, name, reloc) tree decl; char *name; + int reloc; { if (decl != NULL_TREE && TREE_CODE_CLASS (TREE_CODE (decl)) != 'd') @@ -270,7 +272,7 @@ named_section (decl, name) in_section = in_named; #ifdef ASM_OUTPUT_SECTION_NAME - ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name); + ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name, reloc); #else /* Section attributes are not supported if this macro isn't provided - some host formats don't support them at all. The front-end should @@ -280,6 +282,29 @@ named_section (decl, name) } } +#ifdef ASM_OUTPUT_SECTION_NAME +#ifndef UNIQUE_SECTION +#define UNIQUE_SECTION(DECL,RELOC) \ +do { \ + int len; \ + char *name, *string; \ + \ + name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ + /* Strip off any encoding in name. */ \ + STRIP_NAME_ENCODING (name, name); \ + \ + len = strlen (name) + 1; \ + string = alloca (len + 1); \ + sprintf (string, ".%s", name); \ + \ + DECL_SECTION_NAME (DECL) = build_string (len, string); \ +} while (0) +#endif +#ifndef UNIQUE_SECTION_P +#define UNIQUE_SECTION_P(DECL) 0 +#endif +#endif + #ifdef BSS_SECTION_ASM_OP /* Tell the assembler to switch to the bss section. */ @@ -376,7 +401,7 @@ function_section (decl) { if (decl != NULL_TREE && DECL_SECTION_NAME (decl) != NULL_TREE) - named_section (decl, (char *) 0); + named_section (decl, (char *) 0, 0); else text_section (); } @@ -391,7 +416,7 @@ variable_section (decl, reloc) int reloc; { if (IN_NAMED_SECTION (decl)) - named_section (decl, NULL); + named_section (decl, NULL, reloc); else { /* C++ can have const variables that get initialized from constructors, @@ -410,12 +435,7 @@ variable_section (decl, reloc) #ifdef SELECT_SECTION SELECT_SECTION (decl, reloc); #else - if (TREE_READONLY (decl) - && ! TREE_THIS_VOLATILE (decl) - && DECL_INITIAL (decl) - && (DECL_INITIAL (decl) == error_mark_node - || TREE_CONSTANT (DECL_INITIAL (decl))) - && ! (flag_pic && reloc)) + if (DECL_READONLY_SECTION (decl, reloc)) readonly_data_section (); else data_section (); @@ -430,7 +450,7 @@ void exception_section () { #ifdef ASM_OUTPUT_SECTION_NAME - named_section (NULL_TREE, ".gcc_except_table"); + named_section (NULL_TREE, ".gcc_except_table", 0); #else if (flag_pic) data_section (); @@ -938,18 +958,10 @@ assemble_start_function (decl, fnname) #ifdef ASM_OUTPUT_SECTION_NAME /* If the function is to be put in its own section and it's not in a section already, indicate so. */ - if (flag_function_sections - && DECL_SECTION_NAME (decl) == NULL_TREE) - { -#ifdef UNIQUE_SECTION - DECL_SECTION_NAME(decl) = UNIQUE_SECTION (decl); -#else - char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - /* Strip off any encoding in name. */ - STRIP_NAME_ENCODING (name, name); - DECL_SECTION_NAME (decl) = build_string (strlen (name), name); -#endif - } + if ((flag_function_sections + && DECL_SECTION_NAME (decl) == NULL_TREE) + || UNIQUE_SECTION_P (decl)) + UNIQUE_SECTION (decl, 0); #endif function_section (decl); @@ -1438,6 +1450,11 @@ assemble_variable (decl, top_level, at_end, dont_output_data) else if (DECL_INITIAL (decl)) reloc = output_addressed_constants (DECL_INITIAL (decl)); +#ifdef ASM_OUTPUT_SECTION_NAME + if (UNIQUE_SECTION_P (decl)) + UNIQUE_SECTION (decl, reloc); +#endif + /* Switch to the appropriate section. */ variable_section (decl, reloc); @@ -3050,7 +3067,7 @@ output_constant_def_contents (exp, reloc, labelno) int align; if (IN_NAMED_SECTION (exp)) - named_section (exp, NULL); + named_section (exp, NULL, reloc); else { /* First switch to text section, except for writable strings. */ |