public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
* Re: pei symbols
@ 1998-06-02 17:15 Christopher Faylor
  1998-06-02 19:39 ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Faylor @ 1998-06-02 17:15 UTC (permalink / raw)
  To: ian, jeffdb; +Cc: bfd, cygwin32-developers, gas2

>From: Ian Lance Taylor <ian@cygnus.com>
>Date: Tue, 2 Jun 1998 19:49:15 -0400
>
>   From: jeffdbREMOVETHIS@goodnet.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.

What does adding this do?

cgf

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: pei symbols
  1998-06-02 17:15 pei symbols Christopher Faylor
@ 1998-06-02 19:39 ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 1998-06-02 19:39 UTC (permalink / raw)
  To: cgf; +Cc: jeffdb, bfd, cygwin32-developers, gas2

   Date: Tue, 2 Jun 1998 20:15:08 -0400
   From: Christopher Faylor <cgf@cygnus.com>

   >   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.

   What does adding this do?

It sets the n_type field of all function symbols to DT_FCN << N_BTSHFT
(e.g., 0x20).  The Microsoft PE documentation says that this is
required for all function symbols, for some reason involving
incremental linking.

I doubt it matters for cygwin32.  It's just a minor cleanup of the
Win32 toolchain.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: pei symbols
  1998-05-11  3:07 Mikey
@ 1998-06-02 16:49 ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 1998-06-02 16:49 UTC (permalink / raw)
  To: jeffdb; +Cc: bfd, gas2, cygwin32-developers

   From: jeffdbREMOVETHIS@goodnet.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 " #"
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* pei symbols
@ 1998-05-11  3:07 Mikey
  1998-06-02 16:49 ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Mikey @ 1998-05-11  3:07 UTC (permalink / raw)
  To: bfd, gas2, cygwin32-developers

Hi all

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?

Or is this done in gas/bfd?

=====================================================
Linux a platform built by, and for users, standing on
the firm legs of reliability, and speed.

Microsoft Windows, a platform without a leg to stand on.

(jeffdbREMOVETHIS@goodnet.com)
delete REMOVETHIS from the above to reply
         Mikey

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-06-02 19:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-02 17:15 pei symbols Christopher Faylor
1998-06-02 19:39 ` Ian Lance Taylor
  -- strict thread matches above, loose matches on Subject: below --
1998-05-11  3:07 Mikey
1998-06-02 16:49 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).