*** empty log message ***
[binutils-gdb.git] / gdb / dwarf2expr.c
index c11c4105fca7d08aa8715e2e333c1c75cc2c17bb..b9ae108c5ffecd3a943711d5a52d1de66363e433 100644 (file)
@@ -335,7 +335,7 @@ static void
 execute_stack_op (struct dwarf_expr_context *ctx,
                  const gdb_byte *op_ptr, const gdb_byte *op_end)
 {
-  #define sign_ext(x) ((LONGEST) (((x) ^ sign_bit) - sign_bit))
+#define sign_ext(x) ((LONGEST) (((x) ^ sign_bit) - sign_bit))
   ULONGEST sign_bit = (ctx->addr_size >= sizeof (ULONGEST) ? 0
                       : ((ULONGEST) 1) << (ctx->addr_size * 8 - 1));
   enum bfd_endian byte_order = gdbarch_byte_order (ctx->gdbarch);
@@ -403,6 +403,12 @@ execute_stack_op (struct dwarf_expr_context *ctx,
          result = extract_unsigned_integer (op_ptr,
                                             ctx->addr_size, byte_order);
          op_ptr += ctx->addr_size;
+         /* Some versions of GCC emit DW_OP_addr before
+            DW_OP_GNU_push_tls_address.  In this case the value is an
+            index, not an address.  We don't support things like
+            branching between the address and the TLS op.  */
+         if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address)
+           result += ctx->offset;
          break;
 
        case DW_OP_const1u:
@@ -880,5 +886,5 @@ execute_stack_op (struct dwarf_expr_context *ctx,
 
   ctx->recursion_depth--;
   gdb_assert (ctx->recursion_depth >= 0);
-  #undef sign_ext
+#undef sign_ext
 }