Commit ad4ff310 by Jason Merrill

x

From-SVN: r13994
parent a4b3b54a
...@@ -1450,7 +1450,7 @@ extern int a29k_debug_reg_map[]; ...@@ -1450,7 +1450,7 @@ extern int a29k_debug_reg_map[];
/* This how to write an assembler directive to FILE to switch to /* This how to write an assembler directive to FILE to switch to
section NAME for DECL. */ 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) 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, /* This is how to output the definition of a user-level label named NAME,
......
...@@ -276,10 +276,10 @@ dtors_section () \ ...@@ -276,10 +276,10 @@ dtors_section () \
We make the section read-only and executable for a function decl, 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. */ 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, \ fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
(DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ (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 /* A C statement (sans semicolon) to output an element in the table of
......
...@@ -87,11 +87,11 @@ do { \ ...@@ -87,11 +87,11 @@ do { \
NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or 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 NULL_TREE. Some target formats do not support arbitrary sections. Do not
define this macro in such cases. */ define this macro in such cases. */
#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME) \ #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
do { \ do { \
if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \ 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)); \ fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
else \ else \
fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \ fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
......
...@@ -1182,7 +1182,7 @@ readonly_data() \ ...@@ -1182,7 +1182,7 @@ readonly_data() \
NULL_TREE. Some target formats do not support arbitrary sections. Do not NULL_TREE. Some target formats do not support arbitrary sections. Do not
define this macro in such cases. */ 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) fprintf (FILE, "\t.section %s\n", NAME)
/* This is how to output the definition of a user-level label named NAME, /* This is how to output the definition of a user-level label named NAME,
......
...@@ -172,27 +172,22 @@ while (0) ...@@ -172,27 +172,22 @@ while (0)
symbols must be explicitly imported from shared libraries (DLLs). */ symbols must be explicitly imported from shared libraries (DLLs). */
#define MULTIPLE_SYMBOL_SPACES #define MULTIPLE_SYMBOL_SPACES
/* For objects going into their own sections, a C expression of name of the #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
section, expressed as a STRING_CST node, to put DECL into. The extern void i386_pe_unique_section ();
STRING_CST node must be allocated in the saveable obstack. Function #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
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 MAKE_DECL_ONE_ONLY(DECL) \ #define SUPPORTS_ONE_ONLY 1
DECL_SECTION_NAME (DECL) = UNIQUE_SECTION (DECL)
/* A C statement to output something to the assembler file to switch to section /* 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 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 NULL_TREE. Some target formats do not support arbitrary sections. Do not
define this macro in such cases. */ define this macro in such cases. */
#undef ASM_OUTPUT_SECTION_NAME #undef ASM_OUTPUT_SECTION_NAME
#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME) \ #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
do { \ do { \
if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \ 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)); \ fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
else \ else \
fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \ fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
......
...@@ -58,7 +58,7 @@ dtor_section () \ ...@@ -58,7 +58,7 @@ dtor_section () \
} while (0) } while (0)
/* Allow (eg) __attribute__((section "locked")) to work */ /* 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 { \ do { \
fprintf (FILE, "\t.section %s\n", NAME); \ fprintf (FILE, "\t.section %s\n", NAME); \
} while (0) } while (0)
...@@ -81,11 +81,6 @@ dtor_section () \ ...@@ -81,11 +81,6 @@ dtor_section () \
output_file_directive (FILE, main_input_filename); \ output_file_directive (FILE, main_input_filename); \
} while (0) } 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 /* This is how to output an assembler line
that says to advance the location counter that says to advance the location counter
to a multiple of 2**LOG bytes. */ to a multiple of 2**LOG bytes. */
......
...@@ -477,18 +477,18 @@ do { \ ...@@ -477,18 +477,18 @@ do { \
#define USER_LABEL_PREFIX "" #define USER_LABEL_PREFIX ""
#undef ASM_OUTPUT_SECTION_NAME #undef ASM_OUTPUT_SECTION_NAME
#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
do { \ do { \
char *snam = NAME ; \ char *snam = NAME ; \
if (strcmp(NAME, ".gcc_except_table") == 0) snam = ".gccexc" ; \ if (strcmp(NAME, ".gcc_except_table") == 0) snam = ".gccexc" ; \
if (TARGET_ELF) \ if (TARGET_ELF) \
fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \ fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
(DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
(DECL) && TREE_READONLY (DECL) ? "a" : "aw"); \ (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw"); \
else \ else \
fprintf (FILE, ".section\t%s,\"%s\"\n", snam, \ fprintf (FILE, ".section\t%s,\"%s\"\n", snam, \
(DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "x" : \ (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "x" : \
(DECL) && TREE_READONLY (DECL) ? "a" : "w"); \ (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "w"); \
} while (0) } while (0)
#undef ASM_OUTPUT_SKIP #undef ASM_OUTPUT_SKIP
......
...@@ -67,8 +67,9 @@ gen_stdcall_suffix (decl) ...@@ -67,8 +67,9 @@ gen_stdcall_suffix (decl)
/* Cover function for UNIQUE_SECTION. */ /* Cover function for UNIQUE_SECTION. */
tree tree
i386_pe_unique_section (decl) i386_pe_unique_section (decl, reloc)
tree decl; tree decl;
int reloc;
{ {
int len; int len;
char *name,*string,*prefix; char *name,*string,*prefix;
...@@ -80,7 +81,7 @@ i386_pe_unique_section (decl) ...@@ -80,7 +81,7 @@ i386_pe_unique_section (decl)
(everything from the $ on is stripped). */ (everything from the $ on is stripped). */
if (TREE_CODE (decl) == FUNCTION_DECL) if (TREE_CODE (decl) == FUNCTION_DECL)
prefix = ".text$"; prefix = ".text$";
else if (TREE_READONLY (decl)) else if (DECL_READONLY_SECTION (decl, reloc))
prefix = ".rdata$"; prefix = ".rdata$";
else else
prefix = ".data$"; prefix = ".data$";
......
...@@ -103,10 +103,10 @@ Boston, MA 02111-1307, USA. */ ...@@ -103,10 +103,10 @@ Boston, MA 02111-1307, USA. */
/* Support generic sections */ /* Support generic sections */
#undef ASM_OUTPUT_SECTION_NAME #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), \ fprintf((FILE), ".section\t%s,\"%c\"\n", (NAME), \
(DECL) && (TREE_CODE (DECL) == FUNCTION_DECL || \ (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++. */ /* Support the ctors and dtors sections for g++. */
......
...@@ -83,12 +83,12 @@ do { \ ...@@ -83,12 +83,12 @@ do { \
NULL_TREE. Some target formats do not support arbitrary sections. Do not NULL_TREE. Some target formats do not support arbitrary sections. Do not
define this macro in such cases. */ define this macro in such cases. */
#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME) \ #define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
do { \ do { \
extern FILE *asm_out_text_file; \ extern FILE *asm_out_text_file; \
if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ 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)); \ fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \
else \ else \
fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \ fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
......
...@@ -338,12 +338,12 @@ dtors_section () \ ...@@ -338,12 +338,12 @@ dtors_section () \
NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
NULL_TREE. */ NULL_TREE. */
#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME) \ #define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
do { \ do { \
extern FILE *asm_out_text_file; \ extern FILE *asm_out_text_file; \
if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
fprintf (asm_out_text_file, "\t.section %s,1,6,4,4\n", (NAME)); \ 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)); \ fprintf (F, "\t.section %s,1,2,0,8\n", (NAME)); \
else \ else \
fprintf (F, "\t.section %s,1,3,0,8\n", (NAME)); \ fprintf (F, "\t.section %s,1,3,0,8\n", (NAME)); \
......
...@@ -211,12 +211,12 @@ do { \ ...@@ -211,12 +211,12 @@ do { \
NULL_TREE. Some target formats do not support arbitrary sections. Do not NULL_TREE. Some target formats do not support arbitrary sections. Do not
define this macro in such cases. define this macro in such cases.
*/ */
#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME) \ #define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
do { \ do { \
extern FILE *asm_out_text_file; \ extern FILE *asm_out_text_file; \
if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ 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)); \ fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \
else \ else \
fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \ fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
......
...@@ -1976,7 +1976,7 @@ do { fputs ("\t.SPACE $PRIVATE$\n\ ...@@ -1976,7 +1976,7 @@ do { fputs ("\t.SPACE $PRIVATE$\n\
We make the section read-only and executable for a function decl, 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. */ 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) \ if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
{ \ { \
fputs ("\t.SPACE $TEXT$\n", FILE); \ fputs ("\t.SPACE $TEXT$\n", FILE); \
...@@ -1984,7 +1984,7 @@ do { fputs ("\t.SPACE $PRIVATE$\n\ ...@@ -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",\ "\t.SUBSPA %s%s%s,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY,SORT=24\n",\
TARGET_GAS ? "" : "$", NAME, TARGET_GAS ? "" : "$"); \ 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); \ fputs ("\t.SPACE $TEXT$\n", FILE); \
fprintf (FILE, \ fprintf (FILE, \
......
...@@ -87,10 +87,10 @@ while (0) ...@@ -87,10 +87,10 @@ while (0)
/* Switch into a generic section. */ /* 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, \ fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
(DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ (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 /* Define the pseudo-ops used to switch to the .ctors and .dtors
......
...@@ -541,10 +541,10 @@ dtors_section () \ ...@@ -541,10 +541,10 @@ dtors_section () \
We make the section read-only and executable for a function decl, 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. */ 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, \ fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
(DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ (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 /* A C statement (sans semicolon) to output an element in the table of
......
...@@ -865,7 +865,7 @@ do { \ ...@@ -865,7 +865,7 @@ do { \
*/ */
#undef ASM_OUTPUT_SECTION_NAME #undef ASM_OUTPUT_SECTION_NAME
#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
do { \ do { \
static struct section_info \ static struct section_info \
{ \ { \
...@@ -883,7 +883,7 @@ do { \ ...@@ -883,7 +883,7 @@ do { \
\ \
if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
type = SECT_EXEC, mode = "ax"; \ 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"; \ type = SECT_RO, mode = "a"; \
else \ else \
type = SECT_RW, mode = "aw"; \ type = SECT_RW, mode = "aw"; \
......
...@@ -1373,7 +1373,7 @@ dtors_section() \ ...@@ -1373,7 +1373,7 @@ dtors_section() \
NULL_TREE. Some target formats do not support arbitrary sections. Do not NULL_TREE. Some target formats do not support arbitrary sections. Do not
define this macro in such cases. */ 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) do { fprintf (FILE, ".section\t%s\n", NAME); } while (0)
#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
......
...@@ -186,12 +186,12 @@ do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3); \ ...@@ -186,12 +186,12 @@ do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3); \
define this macro in such cases. */ define this macro in such cases. */
#undef ASM_OUTPUT_SECTION_NAME /* Override svr4.h's definition. */ #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 { \ do { \
if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
fprintf (FILE, ".section\t\"%s%s\",#alloc,#execinstr\n", \ fprintf (FILE, ".section\t\"%s%s\",#alloc,#execinstr\n", \
flag_function_sections ? ".text%" : "", (NAME)); \ 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)); \ fprintf (FILE, ".section\t\"%s\",#alloc\n", (NAME)); \
else \ else \
fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME)); \ fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME)); \
......
...@@ -593,19 +593,17 @@ dtors_section () \ ...@@ -593,19 +593,17 @@ dtors_section () \
} \ } \
} }
/* Switch into a generic 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.
* 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
* If the section has already been defined, we must not recognize section redefinitions.
* emit the attributes here. The SVR4 assembler does not If DECL is NULL, no attributes are emitted. */
* recognize section redefinitions.
* If DECL is NULL, no attributes are emitted. #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
*/
#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
do { \ do { \
static struct section_info \ static struct section_info \
{ \ { \
...@@ -623,7 +621,7 @@ do { \ ...@@ -623,7 +621,7 @@ do { \
\ \
if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
type = SECT_EXEC, mode = "ax"; \ type = SECT_EXEC, mode = "ax"; \
else if (DECL && TREE_READONLY (DECL)) \ else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
type = SECT_RO, mode = "a"; \ type = SECT_RO, mode = "a"; \
else \ else \
type = SECT_RW, mode = "aw"; \ type = SECT_RW, mode = "aw"; \
...@@ -647,21 +645,20 @@ do { \ ...@@ -647,21 +645,20 @@ do { \
} \ } \
} while (0) } while (0)
/* A C statement (sans semicolon) to mark DECL to be emitted as a #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
public symbol such that extra copies in multiple translation units will #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
be discarded by the linker. */ #define UNIQUE_SECTION(DECL,RELOC) \
#define MAKE_DECL_ONE_ONLY(DECL) \
do { \ do { \
int len; \ int len; \
char *name, *string, *prefix; \ char *name, *string, *prefix; \
\ \
DECL_WEAK (DECL) = 1; \
\
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ 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."; \ prefix = ".gnu.linkonce.t."; \
else if (TREE_READONLY (DECL)) \ else if (DECL_READONLY_SECTION (DECL, RELOC)) \
prefix = ".gnu.linkonce.r."; \ prefix = ".gnu.linkonce.r."; \
else \ else \
prefix = ".gnu.linkonce.d."; \ prefix = ".gnu.linkonce.d."; \
...@@ -711,10 +708,7 @@ do { \ ...@@ -711,10 +708,7 @@ do { \
} \ } \
else if (TREE_CODE (DECL) == VAR_DECL) \ else if (TREE_CODE (DECL) == VAR_DECL) \
{ \ { \
if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ if (! DECL_READONLY_SECTION (DECL, RELOC)) \
|| !DECL_INITIAL (DECL) \
|| (DECL_INITIAL (DECL) != error_mark_node \
&& !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
data_section (); \ data_section (); \
else \ else \
const_section (); \ const_section (); \
......
...@@ -134,8 +134,9 @@ extern int in_text_section PROTO((void)); ...@@ -134,8 +134,9 @@ extern int in_text_section PROTO((void));
#ifdef TREE_CODE #ifdef TREE_CODE
/* Tell assembler to change to section NAME for DECL. /* Tell assembler to change to section NAME for DECL.
If DECL is NULL, just switch to section NAME. 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.
extern void named_section PROTO((tree, char *)); 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. */ /* Tell assembler to switch to the section for function DECL. */
extern void function_section PROTO((tree)); extern void function_section PROTO((tree));
...@@ -429,3 +430,14 @@ extern int sdb_begin_function_line; ...@@ -429,3 +430,14 @@ extern int sdb_begin_function_line;
#ifdef BUFSIZ #ifdef BUFSIZ
extern FILE *asm_out_file; extern FILE *asm_out_file;
#endif #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))))
...@@ -250,12 +250,14 @@ in_data_section () ...@@ -250,12 +250,14 @@ in_data_section ()
/* Tell assembler to change to section NAME for DECL. /* Tell assembler to change to section NAME for DECL.
If DECL is NULL, just switch to section NAME. 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 void
named_section (decl, name) named_section (decl, name, reloc)
tree decl; tree decl;
char *name; char *name;
int reloc;
{ {
if (decl != NULL_TREE if (decl != NULL_TREE
&& TREE_CODE_CLASS (TREE_CODE (decl)) != 'd') && TREE_CODE_CLASS (TREE_CODE (decl)) != 'd')
...@@ -270,7 +272,7 @@ named_section (decl, name) ...@@ -270,7 +272,7 @@ named_section (decl, name)
in_section = in_named; in_section = in_named;
#ifdef ASM_OUTPUT_SECTION_NAME #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 #else
/* Section attributes are not supported if this macro isn't provided - /* Section attributes are not supported if this macro isn't provided -
some host formats don't support them at all. The front-end should some host formats don't support them at all. The front-end should
...@@ -280,6 +282,29 @@ named_section (decl, name) ...@@ -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 #ifdef BSS_SECTION_ASM_OP
/* Tell the assembler to switch to the bss section. */ /* Tell the assembler to switch to the bss section. */
...@@ -376,7 +401,7 @@ function_section (decl) ...@@ -376,7 +401,7 @@ function_section (decl)
{ {
if (decl != NULL_TREE if (decl != NULL_TREE
&& DECL_SECTION_NAME (decl) != NULL_TREE) && DECL_SECTION_NAME (decl) != NULL_TREE)
named_section (decl, (char *) 0); named_section (decl, (char *) 0, 0);
else else
text_section (); text_section ();
} }
...@@ -391,7 +416,7 @@ variable_section (decl, reloc) ...@@ -391,7 +416,7 @@ variable_section (decl, reloc)
int reloc; int reloc;
{ {
if (IN_NAMED_SECTION (decl)) if (IN_NAMED_SECTION (decl))
named_section (decl, NULL); named_section (decl, NULL, reloc);
else else
{ {
/* C++ can have const variables that get initialized from constructors, /* C++ can have const variables that get initialized from constructors,
...@@ -410,12 +435,7 @@ variable_section (decl, reloc) ...@@ -410,12 +435,7 @@ variable_section (decl, reloc)
#ifdef SELECT_SECTION #ifdef SELECT_SECTION
SELECT_SECTION (decl, reloc); SELECT_SECTION (decl, reloc);
#else #else
if (TREE_READONLY (decl) if (DECL_READONLY_SECTION (decl, reloc))
&& ! TREE_THIS_VOLATILE (decl)
&& DECL_INITIAL (decl)
&& (DECL_INITIAL (decl) == error_mark_node
|| TREE_CONSTANT (DECL_INITIAL (decl)))
&& ! (flag_pic && reloc))
readonly_data_section (); readonly_data_section ();
else else
data_section (); data_section ();
...@@ -430,7 +450,7 @@ void ...@@ -430,7 +450,7 @@ void
exception_section () exception_section ()
{ {
#ifdef ASM_OUTPUT_SECTION_NAME #ifdef ASM_OUTPUT_SECTION_NAME
named_section (NULL_TREE, ".gcc_except_table"); named_section (NULL_TREE, ".gcc_except_table", 0);
#else #else
if (flag_pic) if (flag_pic)
data_section (); data_section ();
...@@ -938,18 +958,10 @@ assemble_start_function (decl, fnname) ...@@ -938,18 +958,10 @@ assemble_start_function (decl, fnname)
#ifdef ASM_OUTPUT_SECTION_NAME #ifdef ASM_OUTPUT_SECTION_NAME
/* If the function is to be put in its own section and it's not in a section /* If the function is to be put in its own section and it's not in a section
already, indicate so. */ already, indicate so. */
if (flag_function_sections if ((flag_function_sections
&& DECL_SECTION_NAME (decl) == NULL_TREE) && DECL_SECTION_NAME (decl) == NULL_TREE)
{ || UNIQUE_SECTION_P (decl))
#ifdef UNIQUE_SECTION UNIQUE_SECTION (decl, 0);
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
}
#endif #endif
function_section (decl); function_section (decl);
...@@ -1438,6 +1450,11 @@ assemble_variable (decl, top_level, at_end, dont_output_data) ...@@ -1438,6 +1450,11 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
else if (DECL_INITIAL (decl)) else if (DECL_INITIAL (decl))
reloc = output_addressed_constants (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. */ /* Switch to the appropriate section. */
variable_section (decl, reloc); variable_section (decl, reloc);
...@@ -3050,7 +3067,7 @@ output_constant_def_contents (exp, reloc, labelno) ...@@ -3050,7 +3067,7 @@ output_constant_def_contents (exp, reloc, labelno)
int align; int align;
if (IN_NAMED_SECTION (exp)) if (IN_NAMED_SECTION (exp))
named_section (exp, NULL); named_section (exp, NULL, reloc);
else else
{ {
/* First switch to text section, except for writable strings. */ /* First switch to text section, except for writable strings. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment