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]
Other format: [Raw text]

[PATCH] Fix PPC{,64} debug info for __thread variables


Hi!

PPC{,64} is ATM the only port which supports TLS but doesn't generate
DW_OP_GNU_push_tls_address in DWARF2 debug info.
Fixed thusly.  The +0x8000 is there to adjust for the -0x8000 bias
done in the linker.  First __thread variable in a shared library or
executable will use
DW_AT_location    : 6 byte block: 3 0 0 0 0 e0    (DW_OP_addr: 0; DW_OP_GNU_push_tls_address)
instead of DW_OP_addr: -0x8000 which would it use without this adjustement.
Ok to commit?

2004-03-12  Jakub Jelinek  <jakub@redhat.com>

	* config/rs6000/rs6000-protos.h (rs6000_output_dwarf_dtprel): Add
	prototype.
	* config/rs6000/rs6000.c (rs6000_output_dwarf_dtprel): New.
	* config/rs6000/rs6000.h (ASM_OUTPUT_DWARF_DTPREL): Define.

--- gcc/config/rs6000/rs6000.c.jj	2004-03-09 16:09:07.000000000 +0100
+++ gcc/config/rs6000/rs6000.c	2004-03-12 15:31:59.728112966 +0100
@@ -2780,6 +2780,27 @@ rs6000_legitimize_address (rtx x, rtx ol
     return NULL_RTX;
 }
 
+/* This is called from dwarf2out.c via ASM_OUTPUT_DWARF_DTPREL.
+   We need to emit DTP-relative relocations.  */
+
+void
+rs6000_output_dwarf_dtprel (FILE *file, int size, rtx x)
+{
+  switch (size)
+    {
+    case 4:
+      fputs ("\t.long\t", file);
+      break;
+    case 8:
+      fputs ("\t.llong\t", file);
+      break;
+    default:
+      abort ();
+    }
+  output_addr_const (file, x);
+  fputs ("@dtprel+0x8000", file);
+}
+
 /* Construct the SYMBOL_REF for the tls_get_addr function.  */
 
 static GTY(()) rtx rs6000_tls_symbol;
--- gcc/config/rs6000/rs6000-protos.h.jj	2004-02-19 00:04:03.000000000 +0100
+++ gcc/config/rs6000/rs6000-protos.h	2004-03-12 15:29:23.860059258 +0100
@@ -198,6 +198,7 @@ extern int rs6000_register_move_cost (en
 extern int rs6000_memory_move_cost (enum machine_mode, enum reg_class, int);
 extern bool rs6000_tls_referenced_p (rtx);
 extern int rs6000_tls_symbol_ref (rtx, enum machine_mode);
+extern void rs6000_output_dwarf_dtprel (FILE*, int, rtx);
 
 /* Declare functions in rs6000-c.c */
 
--- gcc/config/rs6000/rs6000.h.jj	2004-03-09 16:09:07.000000000 +0100
+++ gcc/config/rs6000/rs6000.h	2004-03-12 15:30:42.229008086 +0100
@@ -232,6 +232,13 @@ extern int target_flags;
 #define TARGET_UPDATE		(! TARGET_NO_UPDATE)
 #define TARGET_FUSED_MADD	(! TARGET_NO_FUSED_MADD)
 
+/* Emit a dtp-relative reference to a TLS variable.  */
+
+#ifdef HAVE_AS_TLS
+#define ASM_OUTPUT_DWARF_DTPREL(FILE, SIZE, X) \
+  rs6000_output_dwarf_dtprel (FILE, SIZE, X)
+#endif
+
 #ifndef HAVE_AS_TLS
 #define HAVE_AS_TLS 0
 #endif

	Jakub


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