public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Make debug info section relative on IA64
@ 2003-02-27 21:11 Steve Ellcey
  2003-02-27 21:33 ` Daniel Jacobowitz
  2003-02-28  1:33 ` Richard Henderson
  0 siblings, 2 replies; 8+ messages in thread
From: Steve Ellcey @ 2003-02-27 21:11 UTC (permalink / raw)
  To: binutils; +Cc: davidm

This is a change to make debug sections relative on IA64.  The person
who made this change isn't around anymore but here is her description of
the problem that this patch fixes, if this looks good could someone
check it in for me?

Steve Ellcey
sje@cup.hp.com

>     We are having a problem where GAS is putting in incorrect
> relocations for .debug_abbrev, .debug_info, and .debug_line
> when they are referenced as offsets.  This problem only happens
> with assembly files that contain no debug information and
> the file is assembled with GAS with the option --gdwarf2.
> In the object file, there will be debug information but the
> offsets which correspond to .debug_abbrev, .debug_info, and
> .debug_line will have relocations of DIR32MSB on HP-UX (and
> DIR64LSB on Linux).
> 
>     This severly confuses the HP linker when performing relocations
> and the result is an executable with cannot be debugged.   I spoke
> with someone on our Linker team and it looks like .debug_abbrev,
> .debug_info, and .debug_line should be section relative offsets
> (i.e. SECREL32MSB).   We fixed this once for 'C' files by forcing
> GCC to put out correct assembler directives to make these section
> relative offsets.  However, an assembly file with no debug information
> in it will not have these directives.  I made a code change in
> ia64_cons_fix_new()
> in tc-ia64.c which fixes this problem.


2003-02-27  Steve Ellcey  <sje@cup.hp.com>

	* config/tc-ia64.c: Make debug sections relative.


*** src.orig/gas/config/tc-ia64.c	Thu Feb 27 12:56:58 2003
--- src/gas/config/tc-ia64.c	Thu Feb 27 12:57:42 2003
*************** ia64_cons_fix_new (f, where, nbytes, exp
*** 10055,10063 ****
      case 2: code = BFD_RELOC_16; break;
      case 4:
        if (target_big_endian)
! 	code = BFD_RELOC_IA64_DIR32MSB;
        else
! 	code = BFD_RELOC_IA64_DIR32LSB;
        break;
  
      case 8:
--- 10055,10081 ----
      case 2: code = BFD_RELOC_16; break;
      case 4:
        if (target_big_endian)
! 	{
! 	  if (exp->X_op == O_symbol &&
! 	      exp->X_add_symbol &&
! 	      (!strcmp(S_GET_NAME(exp->X_add_symbol),".debug_abbrev") ||
! 	       !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_line") ||
! 	       !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_info")))
! 	    code = BFD_RELOC_IA64_SECREL32MSB;
! 	  else	
! 	    code = BFD_RELOC_IA64_DIR32MSB;
! 	}
        else
! 	{
! 	  if (exp->X_op == O_symbol &&
! 	      exp->X_add_symbol &&
! 	      (!strcmp(S_GET_NAME(exp->X_add_symbol),".debug_abbrev") ||
! 	       !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_line") ||
! 	       !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_info")))
! 	    code = BFD_RELOC_IA64_SECREL32LSB;
! 	  else	
! 	    code = BFD_RELOC_IA64_DIR32LSB;
! 	}
        break;
  
      case 8:
*************** ia64_cons_fix_new (f, where, nbytes, exp
*** 10086,10095 ****
  	}
        else
  	{
! 	  if (target_big_endian)
! 	    code = BFD_RELOC_IA64_DIR64MSB;
  	  else
! 	    code = BFD_RELOC_IA64_DIR64LSB;
  	  break;
  	}
  
--- 10104,10131 ----
  	}
        else
  	{
! 	  if (target_big_endian) 
! 	    {
! 	      if (exp->X_op == O_symbol &&
! 		  exp->X_add_symbol &&
! 		  (!strcmp(S_GET_NAME(exp->X_add_symbol),".debug_abbrev") ||
! 		   !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_line") ||
! 		   !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_info")))
! 		code = BFD_RELOC_IA64_SECREL64MSB;
! 	      else
! 		code = BFD_RELOC_IA64_DIR64MSB;
! 	    }
  	  else
! 	    {
! 	      if (exp->X_op == O_symbol &&
! 		  exp->X_add_symbol &&
! 		  (!strcmp(S_GET_NAME(exp->X_add_symbol),".debug_abbrev") ||
! 		   !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_line") ||
! 		   !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_info")))
! 		code = BFD_RELOC_IA64_SECREL64LSB;
! 	      else
! 		code = BFD_RELOC_IA64_DIR64LSB;
! 	    }
  	  break;
  	}
  

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

* Re: [PATCH] Make debug info section relative on IA64
  2003-02-27 21:11 [PATCH] Make debug info section relative on IA64 Steve Ellcey
@ 2003-02-27 21:33 ` Daniel Jacobowitz
  2003-02-28  1:33 ` Richard Henderson
  1 sibling, 0 replies; 8+ messages in thread
From: Daniel Jacobowitz @ 2003-02-27 21:33 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: binutils, davidm

On Thu, Feb 27, 2003 at 01:11:06PM -0800, Steve Ellcey wrote:
> This is a change to make debug sections relative on IA64.  The person
> who made this change isn't around anymore but here is her description of
> the problem that this patch fixes, if this looks good could someone
> check it in for me?


> ! 	      (!strcmp(S_GET_NAME(exp->X_add_symbol),".debug_abbrev") ||
> ! 	       !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_line") ||
> ! 	       !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_info")))

Just one comment: it should probably be strncmp against ".debug_",
given that I believe the ELF specs say something similar.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

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

* Re: [PATCH] Make debug info section relative on IA64
  2003-02-27 21:11 [PATCH] Make debug info section relative on IA64 Steve Ellcey
  2003-02-27 21:33 ` Daniel Jacobowitz
@ 2003-02-28  1:33 ` Richard Henderson
  2003-02-28 18:46   ` Steve Ellcey
  1 sibling, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2003-02-28  1:33 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: binutils, davidm

On Thu, Feb 27, 2003 at 01:11:06PM -0800, Steve Ellcey wrote:
> ! 	      if (exp->X_op == O_symbol &&
> ! 		  exp->X_add_symbol &&
> ! 		  (!strcmp(S_GET_NAME(exp->X_add_symbol),".debug_abbrev") ||
> ! 		   !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_line") ||
> ! 		   !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_info")))
> ! 		code = BFD_RELOC_IA64_SECREL64LSB;

Ug.  No, please.  I'd rather we fiddled something in the
dwarf2 bit of the assembler to dtrt.


r~

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

* Re: [PATCH] Make debug info section relative on IA64
  2003-02-28  1:33 ` Richard Henderson
@ 2003-02-28 18:46   ` Steve Ellcey
  2003-02-28 19:34     ` Richard Henderson
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Ellcey @ 2003-02-28 18:46 UTC (permalink / raw)
  To: rth; +Cc: binutils, davidm, drow

> On Thu, Feb 27, 2003 at 01:11:06PM -0800, Steve Ellcey wrote:
> > ! 	      if (exp->X_op == O_symbol &&
> > ! 		  exp->X_add_symbol &&
> > ! 		  (!strcmp(S_GET_NAME(exp->X_add_symbol),".debug_abbrev") ||
> > ! 		   !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_line") ||
> > ! 		   !strcmp(S_GET_NAME(exp->X_add_symbol),".debug_info")))
> > ! 		code = BFD_RELOC_IA64_SECREL64LSB;
> 
> Ug.  No, please.  I'd rather we fiddled something in the
> dwarf2 bit of the assembler to dtrt.
> 
> r~

Hmm, any chance of some more help on this?  I haven't done a lot of work
in gas/binutils so I am not sure what the dwarf2 bit is or where I would
set it or what I would set it to.

Steve Ellcey
sje@cup.hp.com

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

* Re: [PATCH] Make debug info section relative on IA64
  2003-02-28 18:46   ` Steve Ellcey
@ 2003-02-28 19:34     ` Richard Henderson
  2003-03-07  1:16       ` Steve Ellcey
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2003-02-28 19:34 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: binutils, davidm, drow

On Fri, Feb 28, 2003 at 10:46:51AM -0800, Steve Ellcey wrote:
> Hmm, any chance of some more help on this?  I haven't done a lot of work
> in gas/binutils so I am not sure what the dwarf2 bit is or where I would
> set it or what I would set it to.

In gas/dwarf2dbg.c there are bits like this:

  /* Offset to .debug_info.  */
  expr.X_op = O_symbol;
  expr.X_add_symbol = section_symbol (info_seg);
  expr.X_add_number = 0;
  emit_expr (&expr, 4);

This pattern would need to be replaced by a target hook, e.g.
TC_DWARF2_EMIT_OFFSET (symbol, size).  For non-ia64, just pull
the above out into a small function in dwarf2dbg.c.  For ia64,
you'd use

      expr.X_op = O_pseudo_fixup;
      expr.X_op_symbol = pseudo_func[FUNC_SEG_RELATIVE].u.sym;
      expr.X_add_number = 0;
      expr.X_add_symbol = symbol;

Also worth fixing here is the mish-mash of the use of "4" 
and "sizeof_offset".


r~

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

* Re: [PATCH] Make debug info section relative on IA64
  2003-02-28 19:34     ` Richard Henderson
@ 2003-03-07  1:16       ` Steve Ellcey
  2003-03-11 21:54         ` Richard Henderson
  2003-03-11 22:02         ` Richard Henderson
  0 siblings, 2 replies; 8+ messages in thread
From: Steve Ellcey @ 2003-03-07  1:16 UTC (permalink / raw)
  To: rth, binutils; +Cc: davidm, drow

Richard (or anyone on binutils),

I tried to make a patch like you suggested to fix the debug RELOC
problem I am having but I can't seem to get it right.  Can you (or
someone else on the binutils list) look at the following patch and see
if anything looks wrong?  I think it should do what my original patch
does but it just doesn't work.

Originally (no patch) I would start the HP gdb on a C program containing
a floating point divide (causing it to include __divdf3, which is
written in ASM) and get:

	Dwarf Error: bad offset (0xd6) in compilation unit header (offset 0x68 + 6).

Now with this patch I can start gdb fine but if I set a breakpoint on
main, I get:

	warning: (Internal error: pc 0x4000720 in read in psymtab, but not in symtab.)

0x4000720 is the start of main in my 32 bit program, a 64 bit version of
the program has the same problem.

With my original patch, I could start gdb fine and got no warnings when
I set a breakpoint on main and things seemed to work just fine.

Attached is my current attempt to fix this "the right way" and which
gives me the warnings.

Steve Ellcey
sje@cup.hp.com


*** src.orig/gas/dwarf2dbg.c	Thu Mar  6 16:19:02 2003
--- src/gas/dwarf2dbg.c	Thu Mar  6 17:02:52 2003
***************
*** 44,49 ****
--- 44,54 ----
  #include "dwarf2dbg.h"
  #include <filenames.h>
  
+ #ifndef TC_DWARF2_EMIT_OFFSET
+ # define TC_DWARF2_EMIT_OFFSET(SYMBOL,SIZE) \
+    (generic_dwarf2_emit_offset (SYMBOL, SIZE))
+ #endif
+ 
  #ifndef DWARF2_FORMAT
  # define DWARF2_FORMAT() dwarf2_format_32bit
  #endif
*************** static char const fake_label_name[] = ".
*** 160,165 ****
--- 165,171 ----
  /* The size of an address on the target.  */
  static unsigned int sizeof_address;
  \f
+ static void generic_dwarf2_emit_offset PARAMS((symbolS *, unsigned int));
  static struct line_subseg *get_line_subseg PARAMS ((segT, subsegT));
  static unsigned int get_filenum PARAMS ((const char *, unsigned int));
  static struct frag *first_frag_for_seg PARAMS ((segT));
*************** static void out_debug_aranges PARAMS ((s
*** 186,191 ****
--- 192,212 ----
  static void out_debug_abbrev PARAMS ((segT));
  static void out_debug_info PARAMS ((segT, segT, segT));
  \f
+ /* Create an offset to .dwarf2_*.  */
+ 
+ static void
+ generic_dwarf2_emit_offset (symbol, size)
+      symbolS *symbol;
+      unsigned int size;
+ {
+   expressionS expr;
+ 
+   expr.X_op = O_symbol;
+   expr.X_add_symbol = symbol;
+   expr.X_add_number = 0;
+   emit_expr (&expr, size);
+ }
+ 
  /* Find or create an entry for SEG+SUBSEG in ALL_SEGS.  */
  
  static struct line_subseg *
*************** out_debug_aranges (aranges_seg, info_seg
*** 1209,1218 ****
    out_two (2);
  
    /* Offset to .debug_info.  */
!   expr.X_op = O_symbol;
!   expr.X_add_symbol = section_symbol (info_seg);
!   expr.X_add_number = 0;
!   emit_expr (&expr, 4);
  
    /* Size of an address (offset portion).  */
    out_byte (addr_size);
--- 1230,1236 ----
    out_two (2);
  
    /* Offset to .debug_info.  */
!   TC_DWARF2_EMIT_OFFSET (section_symbol (info_seg), 4);
  
    /* Size of an address (offset portion).  */
    out_byte (addr_size);
*************** out_debug_info (info_seg, abbrev_seg, li
*** 1339,1348 ****
    out_two (2);
  
    /* .debug_abbrev offset */
!   expr.X_op = O_symbol;
!   expr.X_add_symbol = section_symbol (abbrev_seg);
!   expr.X_add_number = 0;
!   emit_expr (&expr, sizeof_offset);
  
    /* Target address size.  */
    out_byte (sizeof_address);
--- 1357,1363 ----
    out_two (2);
  
    /* .debug_abbrev offset */
!   TC_DWARF2_EMIT_OFFSET (section_symbol (abbrev_seg), sizeof_offset);
  
    /* Target address size.  */
    out_byte (sizeof_address);
*************** out_debug_info (info_seg, abbrev_seg, li
*** 1351,1360 ****
    out_uleb128 (1);
  
    /* DW_AT_stmt_list */
!   expr.X_op = O_symbol;
!   expr.X_add_symbol = section_symbol (line_seg);
!   expr.X_add_number = 0;
!   emit_expr (&expr, 4);
  
    /* These two attributes may only be emitted if all of the code is
       contiguous.  Multiple sections are not that.  */
--- 1366,1372 ----
    out_uleb128 (1);
  
    /* DW_AT_stmt_list */
!   TC_DWARF2_EMIT_OFFSET (section_symbol (line_seg), 4);
  
    /* These two attributes may only be emitted if all of the code is
       contiguous.  Multiple sections are not that.  */
*** src.orig/gas/config/tc-ia64.h	Thu Mar  6 16:17:21 2003
--- src/gas/config/tc-ia64.h	Thu Mar  6 16:17:11 2003
*************** extern long ia64_pcrel_from_section PARA
*** 89,94 ****
--- 89,95 ----
  extern void ia64_md_do_align PARAMS ((int, const char *, int, int));
  extern void ia64_handle_align PARAMS ((fragS *f));
  extern void ia64_after_parse_args PARAMS ((void));
+ extern void ia64_dwarf2_emit_offset PARAMS ((symbolS *, unsigned int));
  
  #define md_end()       			ia64_end_of_source ()
  #define md_start_line_hook()		ia64_start_line ()
*************** extern void ia64_after_parse_args PARAMS
*** 119,124 ****
--- 120,127 ----
  #define HANDLE_ALIGN(f)			ia64_handle_align (f)
  #define md_elf_section_type(str,len)	ia64_elf_section_type (str, len)
  #define md_after_parse_args()		ia64_after_parse_args ()
+ #define TC_DWARF2_EMIT_OFFSET(symbol,size) \
+ 					ia64_dwarf2_emit_offset (symbol, size)
  
  #define MAX_MEM_FOR_RS_ALIGN_CODE  (15 + 16)
  
*** src.orig/gas/config/tc-ia64.c	Thu Feb 27 12:56:58 2003
--- src/gas/config/tc-ia64.c	Thu Mar  6 16:17:01 2003
*************** ia64_after_parse_args ()
*** 6472,6477 ****
--- 6472,6489 ----
      as_fatal (_("--gstabs is not supported for ia64"));
  }
  
+ void
+ ia64_dwarf2_emit_offset (symbolS *symbol, unsigned int size)
+ {
+   expressionS expr;
+ 
+   expr.X_op = O_pseudo_fixup;
+   expr.X_op_symbol = pseudo_func[FUNC_SEC_RELATIVE].u.sym;
+   expr.X_add_number = 0;
+   expr.X_add_symbol = symbol;
+   emit_expr (&expr, size);
+ }
+ 
  /* Return true if TYPE fits in TEMPL at SLOT.  */
  
  static int
*************** ia64_cons_fix_new (f, where, nbytes, exp
*** 10054,10064 ****
      case 1: code = BFD_RELOC_8; break;
      case 2: code = BFD_RELOC_16; break;
      case 4:
!       if (target_big_endian)
! 	code = BFD_RELOC_IA64_DIR32MSB;
        else
! 	code = BFD_RELOC_IA64_DIR32LSB;
!       break;
  
      case 8:
        /* In 32-bit mode, data8 could mean function descriptors too.  */
--- 10066,10090 ----
      case 1: code = BFD_RELOC_8; break;
      case 2: code = BFD_RELOC_16; break;
      case 4:
!       if (exp->X_op == O_pseudo_fixup
! 	  && exp->X_op_symbol
! 	  && S_GET_VALUE (exp->X_op_symbol) == FUNC_SEC_RELATIVE)
!         {
! 	  if (target_big_endian)
! 	    code = BFD_RELOC_IA64_SECREL32MSB;
! 	  else
! 	    code = BFD_RELOC_IA64_SECREL32LSB;
! 	  exp->X_op = O_symbol;
! 	  break;
! 	}
        else
! 	{
! 	  if (target_big_endian)
! 	    code = BFD_RELOC_IA64_DIR32MSB;
! 	  else
! 	    code = BFD_RELOC_IA64_DIR32LSB;
! 	  break;
! 	}
  
      case 8:
        /* In 32-bit mode, data8 could mean function descriptors too.  */
*************** ia64_cons_fix_new (f, where, nbytes, exp
*** 10082,10087 ****
--- 10108,10124 ----
  	    code = BFD_RELOC_IA64_DTPREL64MSB;
  	  else
  	    code = BFD_RELOC_IA64_DTPREL64LSB;
+ 	  break;
+ 	}
+       else if (exp->X_op == O_pseudo_fixup
+ 	       && exp->X_op_symbol
+ 	       && S_GET_VALUE (exp->X_op_symbol) == FUNC_SEC_RELATIVE)
+ 	{
+ 	  if (target_big_endian)
+ 	    code = BFD_RELOC_IA64_SECREL64MSB;
+ 	  else
+ 	    code = BFD_RELOC_IA64_SECREL64LSB;
+ 	  exp->X_op = O_symbol;
  	  break;
  	}
        else

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

* Re: [PATCH] Make debug info section relative on IA64
  2003-03-07  1:16       ` Steve Ellcey
@ 2003-03-11 21:54         ` Richard Henderson
  2003-03-11 22:02         ` Richard Henderson
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2003-03-11 21:54 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: binutils, davidm, drow

On Thu, Mar 06, 2003 at 05:16:38PM -0800, Steve Ellcey wrote:
> Attached is my current attempt to fix this "the right way" and which
> gives me the warnings.

You'll have to give me more information than that.  The output
looks correct.


r~

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

* Re: [PATCH] Make debug info section relative on IA64
  2003-03-07  1:16       ` Steve Ellcey
  2003-03-11 21:54         ` Richard Henderson
@ 2003-03-11 22:02         ` Richard Henderson
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2003-03-11 22:02 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: binutils, davidm, drow

I committed this modified version of your patch, so that
anything else that needs doing can be relative to this.



r~


        * dwarf2dbg.c (generic_dwarf2_emit_offset): New.
        (TC_DWARF2_EMIT_OFFSET): Provide default.
        (out_debug_aranges, out_debug_info): Use it.
        * config/tc-ia64.c (ia64_dwarf2_emit_offset): New.
        (ia64_cons_fix_new): Move FUNC_DTP_RELATIVE handling ...
        (ia64_gen_real_reloc_type): ... here.
        * config/tc-ia64.h (TC_DWARF2_EMIT_OFFSET): New.

Index: dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.60
diff -u -p -r1.60 dwarf2dbg.c
--- dwarf2dbg.c	28 Jan 2003 11:20:36 -0000	1.60
+++ dwarf2dbg.c	11 Mar 2003 21:56:06 -0000
@@ -52,6 +52,9 @@
 # define DWARF2_ADDR_SIZE(bfd) (bfd_arch_bits_per_address (bfd) / 8);
 #endif
 
+#ifndef TC_DWARF2_EMIT_OFFSET
+# define TC_DWARF2_EMIT_OFFSET  generic_dwarf2_emit_offset
+#endif
 
 #ifdef BFD_ASSEMBLER
 
@@ -160,6 +163,7 @@ static char const fake_label_name[] = ".
 /* The size of an address on the target.  */
 static unsigned int sizeof_address;
 \f
+static void generic_dwarf2_emit_offset PARAMS((symbolS *, unsigned int));
 static struct line_subseg *get_line_subseg PARAMS ((segT, subsegT));
 static unsigned int get_filenum PARAMS ((const char *, unsigned int));
 static struct frag *first_frag_for_seg PARAMS ((segT));
@@ -186,6 +190,21 @@ static void out_debug_aranges PARAMS ((s
 static void out_debug_abbrev PARAMS ((segT));
 static void out_debug_info PARAMS ((segT, segT, segT));
 \f
+/* Create an offset to .dwarf2_*.  */
+
+static void
+generic_dwarf2_emit_offset (symbol, size)
+     symbolS *symbol;
+     unsigned int size;
+{
+  expressionS expr;
+
+  expr.X_op = O_symbol;
+  expr.X_add_symbol = symbol;
+  expr.X_add_number = 0;
+  emit_expr (&expr, size);
+}
+
 /* Find or create an entry for SEG+SUBSEG in ALL_SEGS.  */
 
 static struct line_subseg *
@@ -1209,10 +1228,8 @@ out_debug_aranges (aranges_seg, info_seg
   out_two (2);
 
   /* Offset to .debug_info.  */
-  expr.X_op = O_symbol;
-  expr.X_add_symbol = section_symbol (info_seg);
-  expr.X_add_number = 0;
-  emit_expr (&expr, 4);
+  /* ??? sizeof_offset */
+  TC_DWARF2_EMIT_OFFSET (section_symbol (info_seg), 4);
 
   /* Size of an address (offset portion).  */
   out_byte (addr_size);
@@ -1339,10 +1356,7 @@ out_debug_info (info_seg, abbrev_seg, li
   out_two (2);
 
   /* .debug_abbrev offset */
-  expr.X_op = O_symbol;
-  expr.X_add_symbol = section_symbol (abbrev_seg);
-  expr.X_add_number = 0;
-  emit_expr (&expr, sizeof_offset);
+  TC_DWARF2_EMIT_OFFSET (section_symbol (abbrev_seg), sizeof_offset);
 
   /* Target address size.  */
   out_byte (sizeof_address);
@@ -1351,10 +1365,8 @@ out_debug_info (info_seg, abbrev_seg, li
   out_uleb128 (1);
 
   /* DW_AT_stmt_list */
-  expr.X_op = O_symbol;
-  expr.X_add_symbol = section_symbol (line_seg);
-  expr.X_add_number = 0;
-  emit_expr (&expr, 4);
+  /* ??? sizeof_offset */
+  TC_DWARF2_EMIT_OFFSET (section_symbol (line_seg), 4);
 
   /* These two attributes may only be emitted if all of the code is
      contiguous.  Multiple sections are not that.  */
Index: config/tc-ia64.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ia64.c,v
retrieving revision 1.80
diff -u -p -r1.80 tc-ia64.c
--- config/tc-ia64.c	28 Jan 2003 03:24:12 -0000	1.80
+++ config/tc-ia64.c	11 Mar 2003 21:56:06 -0000
@@ -10033,6 +10033,20 @@ ia64_pcrel_from_section (fix, sec)
   return off;
 }
 
+
+/* Used to emit section-relative relocs for the dwarf2 debug data.  */
+void
+ia64_dwarf2_emit_offset (symbolS *symbol, unsigned int size)
+{
+  expressionS expr;
+
+  expr.X_op = O_pseudo_fixup;
+  expr.X_op_symbol = pseudo_func[FUNC_SEC_RELATIVE].u.sym;
+  expr.X_add_number = 0;
+  expr.X_add_symbol = symbol;
+  emit_expr (&expr, size);
+}
+
 /* This is called whenever some data item (not an instruction) needs a
    fixup.  We pick the right reloc code depending on the byteorder
    currently in effect.  */
@@ -10074,16 +10088,6 @@ ia64_cons_fix_new (f, where, nbytes, exp
 	  exp->X_op = O_symbol;
 	  break;
 	}
-      else if (exp->X_op == O_pseudo_fixup
-	       && exp->X_op_symbol
-	       && S_GET_VALUE (exp->X_op_symbol) == FUNC_DTP_RELATIVE)
-	{
-	  if (target_big_endian)
-	    code = BFD_RELOC_IA64_DTPREL64MSB;
-	  else
-	    code = BFD_RELOC_IA64_DTPREL64LSB;
-	  break;
-	}
       else
 	{
 	  if (target_big_endian)
@@ -10102,7 +10106,6 @@ ia64_cons_fix_new (f, where, nbytes, exp
 	    code = BFD_RELOC_IA64_IPLTMSB;
 	  else
 	    code = BFD_RELOC_IA64_IPLTLSB;
-
 	  exp->X_op = O_symbol;
 	  break;
 	}
@@ -10113,11 +10116,12 @@ ia64_cons_fix_new (f, where, nbytes, exp
       ignore_rest_of_line ();
       return;
     }
+
   if (exp->X_op == O_pseudo_fixup)
     {
-      /* ??? */
       exp->X_op = O_symbol;
       code = ia64_gen_real_reloc_type (exp->X_op_symbol, code);
+      /* ??? If code unchanged, unsupported.  */
     }
 
   fix = fix_new_exp (f, where, nbytes, exp, 0, code);
@@ -10293,6 +10297,10 @@ ia64_gen_real_reloc_type (sym, r_type)
     case FUNC_DTP_RELATIVE:
       switch (r_type)
 	{
+	case BFD_RELOC_IA64_DIR64MSB:
+	  new = BFD_RELOC_IA64_DTPREL64MSB; break;
+	case BFD_RELOC_IA64_DIR64LSB:
+	  new = BFD_RELOC_IA64_DTPREL64LSB; break;
 	case BFD_RELOC_IA64_IMM14:
 	  new = BFD_RELOC_IA64_DTPREL14; break;
 	case BFD_RELOC_IA64_IMM22:
@@ -10320,6 +10328,7 @@ ia64_gen_real_reloc_type (sym, r_type)
     default:
       abort ();
     }
+
   /* Hmmmm.  Should this ever occur?  */
   if (new)
     return new;
Index: config/tc-ia64.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ia64.h,v
retrieving revision 1.21
diff -u -p -r1.21 tc-ia64.h
--- config/tc-ia64.h	5 Sep 2002 00:01:18 -0000	1.21
+++ config/tc-ia64.h	11 Mar 2003 21:56:06 -0000
@@ -89,6 +89,7 @@ extern long ia64_pcrel_from_section PARA
 extern void ia64_md_do_align PARAMS ((int, const char *, int, int));
 extern void ia64_handle_align PARAMS ((fragS *f));
 extern void ia64_after_parse_args PARAMS ((void));
+extern void ia64_dwarf2_emit_offset PARAMS ((symbolS *, unsigned int));
 
 #define md_end()       			ia64_end_of_source ()
 #define md_start_line_hook()		ia64_start_line ()
@@ -119,6 +120,7 @@ extern void ia64_after_parse_args PARAMS
 #define HANDLE_ALIGN(f)			ia64_handle_align (f)
 #define md_elf_section_type(str,len)	ia64_elf_section_type (str, len)
 #define md_after_parse_args()		ia64_after_parse_args ()
+#define TC_DWARF2_EMIT_OFFSET		ia64_dwarf2_emit_offset
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE  (15 + 16)
 

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

end of thread, other threads:[~2003-03-11 22:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-27 21:11 [PATCH] Make debug info section relative on IA64 Steve Ellcey
2003-02-27 21:33 ` Daniel Jacobowitz
2003-02-28  1:33 ` Richard Henderson
2003-02-28 18:46   ` Steve Ellcey
2003-02-28 19:34     ` Richard Henderson
2003-03-07  1:16       ` Steve Ellcey
2003-03-11 21:54         ` Richard Henderson
2003-03-11 22:02         ` Richard Henderson

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