This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: Don't generate .IMPORT after .EXPORT for external libcalls on PA


Function symbols are exported with type "ENTRY" on the PA when using SOM.
They are imported with type "CODE".  If a source module contains the
implementation of a libcall along with a subsequent call to it, a 
.IMPORT statement will be generated after the .EXPORT statement.  The
HP assembler blindly changes the symbol type to CODE.  As a result,
the linker can't find the symbol to resolve references in other modules.

The particular circumstances where a problem was noted was with the libcall
__gxx_personality_sj0 implemented in eh_personality.cc.  

This patch adds a check to ASM_OUTPUT_EXTERNAL_LIBCALL to see if a
referenced identifier for the symbol already exists.  There is also
a small formatting fix to ASM_OUTPUT_EXTERNAL.

Bootstrap checked with no regressions on hppa1.1-hp-hpux10.20.

OK?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2001-09-18  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* som.h (ASM_OUTPUT_EXTERNAL): Improve formatting.
	(ASM_OUTPUT_EXTERNAL_LIBCALL): Only generate a .IMPORT statement for
	the libcall if there isn't a referenced identifier for the symbol.

--- som.h.orig	Wed Sep  5 10:54:01 2001
+++ som.h	Mon Sep 17 22:59:09 2001
@@ -312,8 +312,8 @@
 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)	\
   do { int save_referenced;					\
        save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)); \
-       fputs ("\t.IMPORT ", FILE);					\
-	 assemble_name (FILE, NAME);				\
+       fputs ("\t.IMPORT ", FILE);				\
+       assemble_name (FILE, NAME);				\
        if (FUNCTION_NAME_P (NAME))     				\
 	 fputs (",CODE\n", FILE);				\
        else							\
@@ -327,14 +327,25 @@
 
    Also note not all libcall names are passed to ENCODE_SECTION_INFO
    (__main for example).  To make sure all libcall names have section
-   info recorded in them, we do it here.  */
+   info recorded in them, we do it here.  We must also ensure that
+   we don't import a libcall that has been previously exported since
+   the HP assembler may change an ENTRY symbol to a CODE symbol.  */
 
 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
-  do { fputs ("\t.IMPORT ", FILE);					\
+  do { const char *name;						\
+       tree id;								\
+									\
        if (!function_label_operand (RTL, VOIDmode))			\
 	 hppa_encode_label (RTL);					\
-       assemble_name (FILE, XSTR ((RTL), 0));		       		\
-       fputs (",CODE\n", FILE);						\
+									\
+       STRIP_NAME_ENCODING (name, XSTR ((RTL), 0));			\
+       id = maybe_get_identifier (name);				\
+       if (! id || ! TREE_SYMBOL_REFERENCED (id))			\
+	 {								\
+	   fputs ("\t.IMPORT ", FILE);					\
+	   assemble_name (FILE, XSTR ((RTL), 0));		       	\
+	   fputs (",CODE\n", FILE);					\
+	 }								\
      } while (0)
 
 #define ASM_FILE_END(FILE) output_deferred_plabels (FILE)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]