Mail Archives: cygwin-developers/1998/06/02/17:03:15
From: jeffdbREMOVETHIS AT goodnet DOT com (Mikey)
Date: Mon, 11 May 1998 10:04:12 GMT
Pei function symbols need to have a 20 in
internal_syment->n_type
similar to ecoff, anyone know how to get gcc to
generate the appropriate .def/.endef?
This patch seems to do it in gcc. I might try to clean it up and get
it into egcs.
Ian
Index: cygwin32.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/config/i386/cygwin32.h,v
retrieving revision 1.22
diff -u -r1.22 cygwin32.h
--- cygwin32.h 1998/05/08 20:36:53 1.22
+++ cygwin32.h 1998/06/02 23:48:17
@@ -224,6 +224,80 @@
? "discard" : "same_size"); \
} while (0)
+/* The Microsoft incremental linker requires all functions to be
+ correctly marked with a type of DT_FCN << N_TSHIFT (i.e., 0x20).
+ This macro will emit code to tell the assembler to mark the symbol
+ NAME with the correct type. */
+#define DECLARE_FUNCTION_TYPE(FILE, NAME, PUBLIC) \
+ do \
+ { \
+ fprintf (FILE, "\t.def\t"); \
+ assemble_name (FILE, NAME); \
+ fprintf (FILE, ";\t.scl\t%d;\t.type\t0x20;\t.endef\n", \
+ (PUBLIC \
+ ? 2 /* C_EXT */ \
+ : 3)); /* C_STAT */ \
+ } \
+ while (0)
+
+/* Write the extra assembler code needed to declare a function
+ properly. If we are generating SDB debugging information, this
+ will happen automatically, so we only need to handle other cases. */
+#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
+ do \
+ { \
+ if (write_symbols != SDB_DEBUG) \
+ DECLARE_FUNCTION_TYPE (FILE, NAME, TREE_PUBLIC (DECL)); \
+ ASM_OUTPUT_LABEL (FILE, NAME); \
+ } \
+ while (0)
+
+/* We also need to declare the type properly for any external
+ function. We have to save a list of these functions, and run over
+ them at the end of the assembly. Otherwise, if the function is
+ defined later in the file, we might emit the wrong type when
+ generating SDB debugging information. */
+
+struct extern_list
+{
+ struct extern_list *next;
+ union tree_node *decl;
+ char *name;
+};
+
+struct extern_list *extern_head;
+
+#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
+ do \
+ { \
+ if (TREE_CODE(DECL) == FUNCTION_DECL) \
+ { \
+ struct extern_list *p; \
+ \
+ p = (struct extern_list *) permalloc (sizeof *p); \
+ p->next = extern_head; \
+ p->decl = DECL; \
+ p->name = NAME; \
+ extern_head = p; \
+ } \
+ } \
+ while (0)
+
+#define ASM_FILE_END(FILE) \
+ do \
+ { \
+ struct extern_list *p; \
+ \
+ for (p = extern_head; p != NULL; p = p->next) \
+ if (! TREE_ASM_WRITTEN (p->decl)) \
+ DECLARE_FUNCTION_TYPE (FILE, p->name, 1); \
+ } \
+ while (0)
+
+/* Also declare the type properly for any external libcall. */
+#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
+ DECLARE_FUNCTION_TYPE (FILE, XSTR (FUN, 0), 1)
+
#undef ASM_COMMENT_START
#define ASM_COMMENT_START " #"
- Raw text -