This is the mail archive of the 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]

Add DW_OP_GNU_encoded_addr

This is a new dwarf unwind expression opcode that allows an absolute
address to be put into the .eh_frame section without having to resort
to DW_OP_addr, which would result in runtime relocations in shared

This opcode will be generated by a new gas .cfi_val_encoded_addr
directive.  This directive is intended to be used with inline assembly
which actually contains out-of-line code (i.e. in another section).

  asm(	"test something
	jnz 1f
	.section text2,\"ax\"
1:	.cfi_startproc simple
	.cfi_def_cfa %%esp, 0
	.cfi_val_encoded_addr %%eip, 0x1b, 11f
	jmp 11f

This is an idiom that shows up several places in glibc and in the
kernel.  In glibc, Jakub currently goes to heroic efforts to
generate the unwind information by hand, but this code is what you
might call write-only i.e. intensely difficult to modify.

        * dwarf2.h (DW_OP_GNU_encoded_addr): New.
	* unwind-dw2.c (execute_stack_op): Handle it.

--- gcc/dwarf2.h	(revision 140643)
+++ gcc/dwarf2.h	(local)
@@ -543,6 +543,7 @@ enum dwarf_location_atom
     DW_OP_GNU_push_tls_address = 0xe0,
     /* The following is for marking variables that are uninitialized.  */
     DW_OP_GNU_uninit     = 0xf0,
+    DW_OP_GNU_encoded_addr = 0xf1,
     /* HP extensions.  */
     DW_OP_HP_unknown     = 0xe0, /* Ouch, the same as GNU_push_tls_address.  */
     DW_OP_HP_is_value    = 0xe1,
--- gcc/unwind-dw2.c	(revision 140643)
+++ gcc/unwind-dw2.c	(local)
@@ -494,6 +494,14 @@ execute_stack_op (const unsigned char *o
 	  op_ptr += sizeof (void *);
+	case DW_OP_GNU_encoded_addr:
+	  {
+	    _Unwind_Ptr presult;
+	    op_ptr = read_encoded_value (context, *op_ptr, op_ptr+1, &presult);
+	    result = presult;
+	  }
+	  break;
 	case DW_OP_const1u:
 	  result = read_1u (op_ptr);
 	  op_ptr += 1;

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