Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--agent/tcf/services/dwarf.h1
-rw-r--r--agent/tcf/services/dwarfexpr.c14
-rw-r--r--agent/tcf/services/elf-loader.c9
-rw-r--r--agent/tcf/services/tcf_elf.c1
-rw-r--r--tests/test-dwarf/tcf/backend/backend.c1
5 files changed, 24 insertions, 2 deletions
diff --git a/agent/tcf/services/dwarf.h b/agent/tcf/services/dwarf.h
index 677a2377..7df3f5c5 100644
--- a/agent/tcf/services/dwarf.h
+++ b/agent/tcf/services/dwarf.h
@@ -377,6 +377,7 @@
#define OP_calli 0x9a /* typo? */
#define OP_ref 0x9a
#define OP_call_ref 0x9a
+#define OP_form_tls_address 0x9b
#define OP_call_frame_cfa 0x9c
#define OP_bit_piece 0x9d
#define OP_implicit_value 0x9e /* v4 */
diff --git a/agent/tcf/services/dwarfexpr.c b/agent/tcf/services/dwarfexpr.c
index a6c161e9..badea24d 100644
--- a/agent/tcf/services/dwarfexpr.c
+++ b/agent/tcf/services/dwarfexpr.c
@@ -184,7 +184,19 @@ static void client_op(uint8_t op) {
if (sState->stack_frame == STACK_NO_FRAME) str_exception(ERR_INV_CONTEXT, "Invalid stack frame");
sState->stk[sState->stk_pos++] = get_fbreg();
break;
+ case OP_form_tls_address:
+ if (sState->stk_pos == 0) str_exception(ERR_INV_DWARF, "Invalid DWARF expression stack");
+ sState->stk[sState->stk_pos - 1] = evaluate_tls_address(sState->stk[sState->stk_pos - 1]);
+ break;
case OP_GNU_push_tls_address:
+ if (sState->stk_pos == 0 && sState->code_pos < sState->code_len) {
+ /* This looks like a bug in GCC: offset sometimes is emitted after OP_GNU_push_tls_address */
+ switch (dio_ReadU1()) {
+ case OP_const4u: sState->stk[sState->stk_pos++] = dio_ReadU4(); break;
+ case OP_const8u: sState->stk[sState->stk_pos++] = dio_ReadU8(); break;
+ case OP_constu: sState->stk[sState->stk_pos++] = dio_ReadU8LEB128(); break;
+ }
+ }
if (sState->stk_pos == 0) str_exception(ERR_INV_DWARF, "Invalid DWARF expression stack");
sState->stk[sState->stk_pos - 1] = evaluate_tls_address(sState->stk[sState->stk_pos - 1]);
break;
@@ -370,4 +382,4 @@ void dwarf_evaluate_expression(U8_T BaseAddress, PropertyValue * v) {
sValuePiecesMax = OrgValuePiecesMax;
}
-#endif /* ENABLE_ELF && ENABLE_DebugContext */
+#endif /* ENABLE_ELF && ENABLE_DebugContext */ \ No newline at end of file
diff --git a/agent/tcf/services/elf-loader.c b/agent/tcf/services/elf-loader.c
index 9af34145..e71e241c 100644
--- a/agent/tcf/services/elf-loader.c
+++ b/agent/tcf/services/elf-loader.c
@@ -245,7 +245,14 @@ static ContextAddress get_module_id(Context * ctx, ELF_File * module) {
ContextAddress get_tls_address(Context * ctx, ELF_File * file) {
ContextAddress mod_tls_addr = 0;
- RegisterIdScope reg_id_scope = { file->machine, file->os_abi, file->big_endian, REGNUM_DWARF };
+ RegisterIdScope reg_id_scope;
+
+ memset(&reg_id_scope, 0, sizeof(reg_id_scope));
+ reg_id_scope.machine = file->machine;
+ reg_id_scope.os_abi = file->os_abi;
+ reg_id_scope.big_endian = file->big_endian;
+ reg_id_scope.id_type = REGNUM_DWARF;
+
switch (file->machine) {
case EM_X86_64:
{
diff --git a/agent/tcf/services/tcf_elf.c b/agent/tcf/services/tcf_elf.c
index 04b51655..da2e10ec 100644
--- a/agent/tcf/services/tcf_elf.c
+++ b/agent/tcf/services/tcf_elf.c
@@ -42,6 +42,7 @@
#include <tcf/services/pathmap.h>
#if defined(_WRS_KERNEL)
+#elif defined(__CYGWIN__)
#elif defined(WIN32)
# define USE_MMAP
#else
diff --git a/tests/test-dwarf/tcf/backend/backend.c b/tests/test-dwarf/tcf/backend/backend.c
index 6094a3fc..cf6eda1c 100644
--- a/tests/test-dwarf/tcf/backend/backend.c
+++ b/tests/test-dwarf/tcf/backend/backend.c
@@ -216,6 +216,7 @@ static void loc_var_func(void * args, Symbol * sym) {
if (strncmp(errno_to_str(err), "Object is not available", 23) == 0) return;
if (strncmp(errno_to_str(err), "Object has no RT address", 24) == 0) return;
if (strncmp(errno_to_str(err), "Division by zero in DWARF", 25) == 0) return;
+ if (strncmp(errno_to_str(err), "Cannot find loader debug", 24) == 0) return;
errno = err;
error("get_symbol_address");
}

Back to the top