Commit 35b361b1 by Mark Wielaard Committed by Mark Wielaard

DWARF: Use DW_OP_addrx and DW_OP_constx for DWARF5.

For older DWARF and -gsplit-dwarf we want to emit DW_OP_GNU_addr_index
and DW_OP_GNU_const_index, but for DWARF5 we should use DW_OP_addrx
and DW_OP_constx.

gcc/ChangeLog:

	* dwarf2out.c (dwarf_OP): Handle DW_OP_addrx and DW_OP_constx.
	(size_of_loc_descr): Likewise.
	(output_loc_operands): Likewise.
	(output_loc_operands_raw): Likewise.
	(dw_addr_op): Use dwarf_OP () for DW_OP_constx and DW_OP_addrx.
	(resolve_addr_in_expr): Handle DW_OP_addrx and DW_OP_constx.
	(hash_loc_operands): Likewise.
	(compare_loc_operands): Likewise.

From-SVN: r260252
parent 01ec978c
2018-05-13 Mark Wielaard <mark@klomp.org>
* dwarf2out.c (dwarf_OP): Handle DW_OP_addrx and DW_OP_constx.
(size_of_loc_descr): Likewise.
(output_loc_operands): Likewise.
(output_loc_operands_raw): Likewise.
(dw_addr_op): Use dwarf_OP () for DW_OP_constx and DW_OP_addrx.
(resolve_addr_in_expr): Handle DW_OP_addrx and DW_OP_constx.
(hash_loc_operands): Likewise.
(compare_loc_operands): Likewise.
2018-05-14 Mark Wielaard <mark@klomp.org> 2018-05-14 Mark Wielaard <mark@klomp.org>
* dwarf2out.c (count_index_addrs): New function. * dwarf2out.c (count_index_addrs): New function.
......
...@@ -1657,6 +1657,16 @@ dwarf_OP (enum dwarf_location_atom op) ...@@ -1657,6 +1657,16 @@ dwarf_OP (enum dwarf_location_atom op)
return DW_OP_GNU_reinterpret; return DW_OP_GNU_reinterpret;
break; break;
case DW_OP_addrx:
if (dwarf_version < 5)
return DW_OP_GNU_addr_index;
break;
case DW_OP_constx:
if (dwarf_version < 5)
return DW_OP_GNU_const_index;
break;
default: default:
break; break;
} }
...@@ -1772,7 +1782,9 @@ size_of_loc_descr (dw_loc_descr_ref loc) ...@@ -1772,7 +1782,9 @@ size_of_loc_descr (dw_loc_descr_ref loc)
size += DWARF2_ADDR_SIZE; size += DWARF2_ADDR_SIZE;
break; break;
case DW_OP_GNU_addr_index: case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index: case DW_OP_GNU_const_index:
case DW_OP_constx:
gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED); gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED);
size += size_of_uleb128 (loc->dw_loc_oprnd1.val_entry->index); size += size_of_uleb128 (loc->dw_loc_oprnd1.val_entry->index);
break; break;
...@@ -2272,7 +2284,9 @@ output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip) ...@@ -2272,7 +2284,9 @@ output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip)
break; break;
case DW_OP_GNU_addr_index: case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index: case DW_OP_GNU_const_index:
case DW_OP_constx:
gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED); gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED);
dw2_asm_output_data_uleb128 (loc->dw_loc_oprnd1.val_entry->index, dw2_asm_output_data_uleb128 (loc->dw_loc_oprnd1.val_entry->index,
"(index into .debug_addr)"); "(index into .debug_addr)");
...@@ -2503,7 +2517,9 @@ output_loc_operands_raw (dw_loc_descr_ref loc) ...@@ -2503,7 +2517,9 @@ output_loc_operands_raw (dw_loc_descr_ref loc)
{ {
case DW_OP_addr: case DW_OP_addr:
case DW_OP_GNU_addr_index: case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index: case DW_OP_GNU_const_index:
case DW_OP_constx:
case DW_OP_implicit_value: case DW_OP_implicit_value:
/* We cannot output addresses in .cfi_escape, only bytes. */ /* We cannot output addresses in .cfi_escape, only bytes. */
gcc_unreachable (); gcc_unreachable ();
...@@ -3903,10 +3919,10 @@ static inline enum dwarf_location_atom ...@@ -3903,10 +3919,10 @@ static inline enum dwarf_location_atom
dw_addr_op (enum dtprel_bool dtprel) dw_addr_op (enum dtprel_bool dtprel)
{ {
if (dtprel == dtprel_true) if (dtprel == dtprel_true)
return (dwarf_split_debug_info ? DW_OP_GNU_const_index return (dwarf_split_debug_info ? dwarf_OP (DW_OP_constx)
: (DWARF2_ADDR_SIZE == 4 ? DW_OP_const4u : DW_OP_const8u)); : (DWARF2_ADDR_SIZE == 4 ? DW_OP_const4u : DW_OP_const8u));
else else
return dwarf_split_debug_info ? DW_OP_GNU_addr_index : DW_OP_addr; return dwarf_split_debug_info ? dwarf_OP (DW_OP_addrx) : DW_OP_addr;
} }
/* Return a pointer to a newly allocated address location description. If /* Return a pointer to a newly allocated address location description. If
...@@ -29697,9 +29713,14 @@ resolve_addr_in_expr (dw_attr_node *a, dw_loc_descr_ref loc) ...@@ -29697,9 +29713,14 @@ resolve_addr_in_expr (dw_attr_node *a, dw_loc_descr_ref loc)
} }
break; break;
case DW_OP_GNU_addr_index: case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index: case DW_OP_GNU_const_index:
if (loc->dw_loc_opc == DW_OP_GNU_addr_index case DW_OP_constx:
|| (loc->dw_loc_opc == DW_OP_GNU_const_index && loc->dtprel)) if ((loc->dw_loc_opc == DW_OP_GNU_addr_index
|| loc->dw_loc_opc == DW_OP_addrx)
|| ((loc->dw_loc_opc == DW_OP_GNU_const_index
|| loc->dw_loc_opc == DW_OP_constx)
&& loc->dtprel))
{ {
rtx rtl = loc->dw_loc_oprnd1.val_entry->addr.rtl; rtx rtl = loc->dw_loc_oprnd1.val_entry->addr.rtl;
if (!resolve_one_addr (&rtl)) if (!resolve_one_addr (&rtl))
...@@ -30485,7 +30506,9 @@ hash_loc_operands (dw_loc_descr_ref loc, inchash::hash &hstate) ...@@ -30485,7 +30506,9 @@ hash_loc_operands (dw_loc_descr_ref loc, inchash::hash &hstate)
inchash::add_rtx (val1->v.val_addr, hstate); inchash::add_rtx (val1->v.val_addr, hstate);
break; break;
case DW_OP_GNU_addr_index: case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index: case DW_OP_GNU_const_index:
case DW_OP_constx:
{ {
if (loc->dtprel) if (loc->dtprel)
{ {
...@@ -30726,7 +30749,9 @@ compare_loc_operands (dw_loc_descr_ref x, dw_loc_descr_ref y) ...@@ -30726,7 +30749,9 @@ compare_loc_operands (dw_loc_descr_ref x, dw_loc_descr_ref y)
hash_addr: hash_addr:
return rtx_equal_p (valx1->v.val_addr, valy1->v.val_addr); return rtx_equal_p (valx1->v.val_addr, valy1->v.val_addr);
case DW_OP_GNU_addr_index: case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index: case DW_OP_GNU_const_index:
case DW_OP_constx:
{ {
rtx ax1 = valx1->val_entry->addr.rtl; rtx ax1 = valx1->val_entry->addr.rtl;
rtx ay1 = valy1->val_entry->addr.rtl; rtx ay1 = valy1->val_entry->addr.rtl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment