Commit 96f158f7 by Richard Kenner

(ASM_OUTPUT_SECTION_NAME): Define section attributes only when a

section is defined the first time.

From-SVN: r11014
parent 5aee39a5
/* Operating system specific defines to be used when targeting GCC for some /* Operating system specific defines to be used when targeting GCC for some
generic System V Release 4 system. generic System V Release 4 system.
Copyright (C) 1991, 1994, 1995 Free Software Foundation, Inc. Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc.
Contributed by Ron Guilmette (rfg@segfault.us.com). Contributed by Ron Guilmette (rfg@segfault.us.com).
This file is part of GNU CC. This file is part of GNU CC.
...@@ -592,16 +592,62 @@ dtors_section () \ ...@@ -592,16 +592,62 @@ dtors_section () \
} \ } \
} }
/* Switch into a generic section.
This is currently only used to support section attributes.
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. */ * 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) \ #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \ do { \
(DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ static struct section_info \
(DECL) && TREE_READONLY (DECL) ? "a" : "aw") { \
struct section_info *next; \
char *name; \
enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
} *sections; \
struct section_info *s; \
char *mode; \
enum sect_enum type; \
\
for (s = sections; s; s = s->next) \
if (!strcmp (NAME, s->name)) \
break; \
\
if (DECL) \
{ \
if (TREE_CODE (DECL) == FUNCTION_DECL) \
type = SECT_EXEC, mode = "ax"; \
else if (TREE_READONLY(DECL)) \
type = SECT_RO, mode = "a"; \
else \
type = SECT_RW, mode = "aw"; \
} \
\
if (s == 0 && DECL) \
{ \
s = (struct section_info *) xmalloc (sizeof (struct section_info)); \
s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \
strcpy (s->name, NAME); \
s->type = type; \
s->next = sections; \
sections = s; \
fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, mode); \
} \
else \
{ \
if (DECL && s->type != type) \
error_with_decl (DECL, "%s causes a section type conflict"); \
\
fprintf (FILE, ".section\t%s\n", NAME); \
} \
} while (0)
/* 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
global constructors. */ global constructors. */
......
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