Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Stefan Vogel
Wed, 03 Jan 1996 00:00
gcc sysv4-2.7.0 __attribute__((section)) bug/patch
Author: Stefan Vogel
Date: Wed, 03 Jan 1996 00:00
Date: Wed, 03 Jan 1996 00:00
150 lines
5262 bytes
5262 bytes
Hello GCC Maintainers,
I had some problems with section definitions for functions and
variables, and would appreciate if you could apply the following
patch ore something equivalent.
Thank you a lot for all the work you are doing.
Stefan
------------------------------------------------------------------
Version:
Reading specs from /usr/local/lib/gcc-lib/i386-univel-sysv4.2MP/2.7.1/specs
gcc version 2.7.1
UnixWare 2.0.3
Synopsis:
Only the first "__attribute__((section(".anything")))" for
a variable or function will be recognized in a source file.
How to reproduce:
Compile the following source file:
int x __attribute__((section(".test"))) = 1;
int y = 2;
int z __attribute__((section(".test"))) = 3;
main() {}
You will get an assember error:
/var/tmp/cca002GP.s:19:warning:section already defined: .test
Only the variable x does appear in section .test.
Reason:
The SYS5R4 assembler does only recognize one directive
.section .test,"rw",@progbits
in a source file. After the first definition of the section, you
may only use:
.section .test
Gcc does generate only the first format of the .section directive,
so any but the first definition will cause a warning from the assembler
and the directive being ignored.
ChangeLog Entry:
Wed Jan 03 15:14:43 1996 Stefan Vogel (sv@ssw.de)
* config/svr4.h (ASM_OUTPUT_SECTION_NAME): define section attributes
only when a section is defined the first time. Attribute definitions
on subsequent .section directives are not recognized by the SVR4
assembler.
Patch:
Fix config/svr4.h:
*** svr4.h.org Sat Nov 4 16:35:33 1995
--- svr4.h Wed Jan 3 15:14:43 1996
*************** dtors_section () \
*** 564,579 ****
} \
}
- /* 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. */
- #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
- fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
- (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
- (DECL) && TREE_READONLY (DECL) ? "a" : "aw")
/* A C statement (sans semicolon) to output an element in the table of
global constructors. */
--- 564,625 ----
} \
}
+ /*
+ * 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) \
+ do { \
+ static struct section_info { \
+ 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
global constructors. */
------------------------------------------------------------------
Stefan Vogel Tel: +49-711-9375900
Sulzgrieser Str. 24 Fax: +49-711-9375902
D-73733 Esslingen Email: stefan@nilpferd.ssw.de
Germany
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads