This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

Re: update dwarf2 asm unwind info [hppa64-*-* failures]


Here's everything I have for hppa binutils so far.  Fixes the readelf
problem you mentioned, marks .eh_frame as writable, and changes hppa64
to use 64-bit pc-relative relocations.  I don't know if that last is
really required, but at this point I just want to match gcc's output
as close as I can.



r~
? bfd/doc/bfd.info
? binutils/doc/binutils.info
? gas/doc/as.info
? gprof/gprof.info
? ld/ld.info
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.423
diff -u -r1.423 readelf.c
--- binutils/readelf.c	8 Aug 2008 19:24:48 -0000	1.423
+++ binutils/readelf.c	13 Aug 2008 16:31:42 -0000
@@ -8156,7 +8156,7 @@
     case EM_ARM:
       return reloc_type == 3;  /* R_ARM_REL32 */
     case EM_PARISC:
-      return reloc_type == 0;  /* R_PARISC_NONE.  *//* FIXME: This reloc is generated, but it may be a bug.  */
+      return reloc_type == 9;  /* R_PARISC_PCREL32.  */
     case EM_PPC:
       return reloc_type == 26; /* R_PPC_REL32.  */
     case EM_PPC64:
@@ -8219,6 +8219,36 @@
     }
 }
 
+/* Like is_32bit_pcrel_reloc except that it returns TRUE iff RELOC_TYPE is
+   a 64-bit pc-relative RELA relocation used in DWARF debug sections.  */
+
+static bfd_boolean
+is_64bit_pcrel_reloc (unsigned int reloc_type)
+{
+  switch (elf_header.e_machine)
+    {
+    case EM_ALPHA:
+      return reloc_type == 11; /* R_ALPHA_SREL64 */
+    case EM_IA_64:
+      return reloc_type == 0x4f; /* R_IA64_PCREL64LSB */
+    case EM_PARISC:
+      return reloc_type == 72; /* R_PARISC_PCREL64 */
+    case EM_PPC64:
+      return reloc_type == 44; /* R_PPC64_REL64 */
+    case EM_SPARC32PLUS:
+    case EM_SPARCV9:
+    case EM_SPARC:
+      return reloc_type == 46; /* R_SPARC_DISP64 */
+    case EM_X86_64:
+      return reloc_type == 24; /* R_X86_64_PC64 */
+    case EM_S390_OLD:
+    case EM_S390:
+      return reloc_type == 23;	/* R_S390_PC64 */
+    default:
+      return FALSE;
+    }
+}
+
 /* Like is_32bit_abs_reloc except that it returns TRUE iff RELOC_TYPE is
    a 16-bit absolute RELA relocation used in DWARF debug sections.  */
 
@@ -8392,7 +8422,8 @@
 	  if (is_32bit_abs_reloc (reloc_type)
 	      || is_32bit_pcrel_reloc (reloc_type))
 	    reloc_size = 4;
-	  else if (is_64bit_abs_reloc (reloc_type))
+	  else if (is_64bit_abs_reloc (reloc_type)
+		   || is_64bit_pcrel_reloc (reloc_type))
 	    reloc_size = 8;
 	  else if (is_16bit_abs_reloc (reloc_type))
 	    reloc_size = 2;
@@ -8436,7 +8467,8 @@
 
 	  addend = is_rela ? rp->r_addend : byte_get (loc, reloc_size);
 	  
-	  if (is_32bit_pcrel_reloc (reloc_type))
+	  if (is_32bit_pcrel_reloc (reloc_type)
+	      || is_64bit_pcrel_reloc (reloc_type))
 	    byte_put (loc, (addend + sym->st_value) - rp->r_offset,
 		      reloc_size);
 	  else
Index: gas/dw2gencfi.c
===================================================================
RCS file: /cvs/src/src/gas/dw2gencfi.c,v
retrieving revision 1.34
diff -u -r1.34 dw2gencfi.c
--- gas/dw2gencfi.c	13 Feb 2008 10:14:37 -0000	1.34
+++ gas/dw2gencfi.c	13 Aug 2008 16:31:42 -0000
@@ -31,6 +31,16 @@
 # define DWARF2_LINE_MIN_INSN_LENGTH 1
 #endif
 
+/* By default, use 32-bit relocations from .eh_frame into .text.  */
+#ifndef DWARF2_FDE_RELOC_SIZE
+# define DWARF2_FDE_RELOC_SIZE 4
+#endif
+
+/* By default, use a read-only .eh_frame section.  */
+#ifndef DWARF2_EH_FRAME_READ_ONLY
+# define DWARF2_EH_FRAME_READ_ONLY SEC_READONLY
+#endif
+
 #ifndef EH_FRAME_ALIGNMENT
 # define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2)
 #endif
@@ -1041,6 +1051,7 @@
   expressionS exp;
   struct cfi_insn_data *i;
   offsetT augmentation_size;
+  int enc;
 
   cie->start_address = symbol_temp_new_now ();
   after_size_address = symbol_temp_make ();
@@ -1096,11 +1107,22 @@
     }
   if (cie->lsda_encoding != DW_EH_PE_omit)
     out_one (cie->lsda_encoding);
+
+  switch (DWARF2_FDE_RELOC_SIZE)
+    {
+    case 4:
+      enc = DW_EH_PE_sdata4;
+      break;
+    case 8:
+      enc = DW_EH_PE_sdata8;
+      break;
+    default:
+      abort ();
+    }
 #if defined DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
-  out_one (DW_EH_PE_pcrel | DW_EH_PE_sdata4);
-#else
-  out_one (DW_EH_PE_sdata4);
+  enc |= DW_EH_PE_pcrel;
 #endif
+  out_one (enc);
 
   if (cie->first)
     for (i = cie->first; i != cie->last; i = i->next)
@@ -1135,22 +1157,22 @@
 #ifdef DIFF_EXPR_OK
   exp.X_add_symbol = fde->start_address;
   exp.X_op_symbol = symbol_temp_new_now ();
-  emit_expr (&exp, 4);				/* Code offset.  */
+  emit_expr (&exp, DWARF2_FDE_RELOC_SIZE);	/* Code offset.  */
 #else
   exp.X_op = O_symbol;
   exp.X_add_symbol = fde->start_address;
   exp.X_op_symbol = NULL;
 #ifdef tc_cfi_emit_pcrel_expr
-  tc_cfi_emit_pcrel_expr (&exp, 4);		/* Code offset.  */
+  tc_cfi_emit_pcrel_expr (&exp, DWARF2_FDE_RELOC_SIZE);	 /* Code offset.  */
 #else
-  emit_expr (&exp, 4);				/* Code offset.  */
+  emit_expr (&exp, DWARF2_FDE_RELOC_SIZE);	/* Code offset.  */
 #endif
   exp.X_op = O_subtract;
 #endif
 
   exp.X_add_symbol = fde->end_address;
   exp.X_op_symbol = fde->start_address;		/* Code length.  */
-  emit_expr (&exp, 4);
+  emit_expr (&exp, DWARF2_FDE_RELOC_SIZE);
 
   augmentation_size = encoding_size (fde->lsda_encoding);
   out_uleb128 (augmentation_size);		/* Augmentation size.  */
@@ -1319,7 +1341,8 @@
   /* Open .eh_frame section.  */
   cfi_seg = subseg_new (".eh_frame", 0);
   bfd_set_section_flags (stdoutput, cfi_seg,
-			 SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY);
+			 SEC_ALLOC | SEC_LOAD | SEC_DATA
+			 | DWARF2_EH_FRAME_READ_ONLY);
   subseg_set (cfi_seg, 0);
   record_alignment (cfi_seg, EH_FRAME_ALIGNMENT);
 
Index: gas/config/tc-hppa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.c,v
retrieving revision 1.138
diff -u -r1.138 tc-hppa.c
--- gas/config/tc-hppa.c	16 Mar 2008 23:16:03 -0000	1.138
+++ gas/config/tc-hppa.c	13 Aug 2008 16:31:43 -0000
@@ -1375,6 +1375,13 @@
 
   reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
+
+  /* Allow fixup_segment to recognize hand-written pc-relative
+     relocations.  When we went through cons_fix_new_hppa, we
+     classified them as complex.  Simplify that now.  */
+  if (fixp->fx_r_type == R_HPPA_COMPLEX && fixp->fx_pcrel)
+    fixp->fx_r_type = R_HPPA_PCREL_CALL;
+
   codes = hppa_gen_reloc_type (stdoutput,
 			       fixp->fx_r_type,
 			       hppa_fixp->fx_r_format,
Index: gas/config/tc-hppa.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.h,v
retrieving revision 1.34
diff -u -r1.34 tc-hppa.h
--- gas/config/tc-hppa.h	27 Dec 2007 15:35:53 -0000	1.34
+++ gas/config/tc-hppa.h	13 Aug 2008 16:31:43 -0000
@@ -186,8 +186,6 @@
 
 #define elf_tc_final_processing	elf_hppa_final_processing
 void elf_hppa_final_processing (void);
-
-#define DWARF2_LINE_MIN_INSN_LENGTH 4
 #endif /* OBJ_ELF */
 
 #define md_operand(x)
@@ -213,10 +211,16 @@
 #define DWARF2_LINE_MIN_INSN_LENGTH 4
 #define DWARF2_DEFAULT_RETURN_COLUMN 2
 #if TARGET_ARCH_SIZE == 64
-#define DWARF2_CIE_DATA_ALIGNMENT (-8)
+#define DWARF2_CIE_DATA_ALIGNMENT 8
+#define DWARF2_FDE_RELOC_SIZE 8
 #else
-#define DWARF2_CIE_DATA_ALIGNMENT (-4)
+#define DWARF2_CIE_DATA_ALIGNMENT 4
 #endif
+
+/* Due to the way dynamic linking to personality functions is handled,
+   we need to have a read-write .eh_frame section.  */
+#define DWARF2_EH_FRAME_READ_ONLY 0
+
 #endif
 
 #endif /* _TC_HPPA_H */
Index: gas/testsuite/gas/cfi/cfi-common-1.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi-common-1.d,v
retrieving revision 1.5
diff -u -r1.5 cfi-common-1.d
--- gas/testsuite/gas/cfi/cfi-common-1.d	28 Jan 2008 15:15:31 -0000	1.5
+++ gas/testsuite/gas/cfi/cfi-common-1.d	13 Aug 2008 16:31:43 -0000
@@ -14,10 +14,11 @@
   DW_CFA_nop
   DW_CFA_nop
 
-00000014 00000018 00000018 FDE cie=00000000 pc=.*
+00000014 000000(18|1c|20) 00000018 FDE cie=00000000 pc=.*
   DW_CFA_advance_loc: 4 to .*
   DW_CFA_def_cfa: r0( \([er]ax\)|) ofs 16
-  DW_CFA_offset: r1( \((rdx|ecx)\)|) at cfa-8
+  DW_CFA_offset(_extended_sf|): r1( \((rdx|ecx)\)|) at cfa-8
   DW_CFA_advance_loc: 4 to .*
   DW_CFA_def_cfa_offset: 32
-  DW_CFA_offset: r2( \((rcx|edx)\)|) at cfa-24
+  DW_CFA_offset(_extended_sf|): r2( \((rcx|edx)\)|) at cfa-24
+#...
Index: gas/testsuite/gas/cfi/cfi-hppa-1.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi-hppa-1.d,v
retrieving revision 1.2
diff -u -r1.2 cfi-hppa-1.d
--- gas/testsuite/gas/cfi/cfi-hppa-1.d	28 Jan 2008 15:15:31 -0000	1.2
+++ gas/testsuite/gas/cfi/cfi-hppa-1.d	13 Aug 2008 16:31:43 -0000
@@ -6,13 +6,13 @@
   Version:               1
   Augmentation:          "zR"
   Code alignment factor: 4
-  Data alignment factor: -[48]
+  Data alignment factor: [48]
   Return address column: 2
-  Augmentation data:     1b
+  Augmentation data:     1[bc]
 
   DW_CFA_def_cfa: r30 ofs 0
 
-00000014 00000018 00000018 FDE cie=00000000 pc=00000000..00000018
+00000014 000000(18|20) 00000018 FDE cie=00000000 pc=00000000..00000018
   DW_CFA_advance_loc: 8 to 00000008
   DW_CFA_def_cfa_register: r3
   DW_CFA_advance_loc: 4 to 0000000c
@@ -21,17 +21,16 @@
   DW_CFA_def_cfa_register: r30
   DW_CFA_nop
 
-00000030 00000018 00000034 FDE cie=00000000 pc=00000018..00000040
+0000003[08] 000000(18|20) 0000003[4c] FDE cie=00000000 pc=00000018..00000040
   DW_CFA_advance_loc: 12 to 00000024
   DW_CFA_def_cfa_register: r3
-  DW_CFA_offset: r2 at cfa-24
+  DW_CFA_offset_extended_sf: r2 at cfa-24
   DW_CFA_advance_loc: 24 to 0000003c
   DW_CFA_def_cfa_register: r30
   DW_CFA_nop
   DW_CFA_nop
-  DW_CFA_nop
 
-0000004c 00000010 00000050 FDE cie=00000000 pc=00000040..00000048
+000000[45]c 0000001[08] 000000[56]0 FDE cie=00000000 pc=00000040..00000048
   DW_CFA_nop
   DW_CFA_nop
   DW_CFA_nop
Index: gas/testsuite/gas/cfi/cfi.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi.exp,v
retrieving revision 1.21
diff -u -r1.21 cfi.exp
--- gas/testsuite/gas/cfi/cfi.exp	18 Feb 2008 21:05:07 -0000	1.21
+++ gas/testsuite/gas/cfi/cfi.exp	13 Aug 2008 16:31:43 -0000
@@ -80,13 +80,18 @@
 }
 
 run_list_test "cfi-diag-1" ""
-run_dump_test "cfi-common-1"
-run_dump_test "cfi-common-2"
-run_dump_test "cfi-common-3"
-run_dump_test "cfi-common-4"
-run_dump_test "cfi-common-5"
 
-# MIPS doesn't support PC relative cfi directives
+# HPPA64 uses 64-bit relocations, which results in all of the dump
+# offset numbers not matching up.
+if { ![istarget "hppa64*-*"] } then {
+  run_dump_test "cfi-common-1"
+  run_dump_test "cfi-common-2"
+  run_dump_test "cfi-common-3"
+  run_dump_test "cfi-common-4"
+  run_dump_test "cfi-common-5"
+}
+
+# MIPS doesn't support PC relative cfi directives.
 if { ![istarget "mips*-*"] } then {
     run_dump_test "cfi-common-6"
 }

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