diff options
author | Eugene Tarassov | 2019-12-24 00:00:12 +0000 |
---|---|---|
committer | Eugene Tarassov | 2019-12-24 00:00:12 +0000 |
commit | ff1efcf9c84532ef2323a90141c893159d6e2bf1 (patch) | |
tree | f00e00b56d2bed481643b9af15d028deef97b0b7 /agent/tcf | |
parent | 854f28a09e371a901a5f9907ee9fcdbf11208ba5 (diff) | |
download | org.eclipse.tcf.agent-ff1efcf9c84532ef2323a90141c893159d6e2bf1.tar.gz org.eclipse.tcf.agent-ff1efcf9c84532ef2323a90141c893159d6e2bf1.tar.xz org.eclipse.tcf.agent-ff1efcf9c84532ef2323a90141c893159d6e2bf1.zip |
Bug 558576 - More relocation type for RISC-V need to support
Diffstat (limited to 'agent/tcf')
-rw-r--r-- | agent/tcf/services/dwarfcache.c | 2 | ||||
-rw-r--r-- | agent/tcf/services/dwarfreloc.c | 77 | ||||
-rw-r--r-- | agent/tcf/services/expressions.c | 4 |
3 files changed, 69 insertions, 14 deletions
diff --git a/agent/tcf/services/dwarfcache.c b/agent/tcf/services/dwarfcache.c index 7daf3973..b9c615db 100644 --- a/agent/tcf/services/dwarfcache.c +++ b/agent/tcf/services/dwarfcache.c @@ -2369,7 +2369,7 @@ static void load_line_numbers_v2(CompUnit * Unit, U8_T unit_size, int dwarf64) { state.mAddress += (255 - opcode_base) / line_range * min_instruction_length; break; case DW_LNS_fixed_advance_pc: - state.mAddress += dio_ReadU2(); + state.mAddress += dio_ReadAddressX(NULL, 2); break; case DW_LNS_set_prologue_end: state.mFlags |= LINE_PrologueEnd; diff --git a/agent/tcf/services/dwarfreloc.c b/agent/tcf/services/dwarfreloc.c index 47af0673..134fc6e2 100644 --- a/agent/tcf/services/dwarfreloc.c +++ b/agent/tcf/services/dwarfreloc.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 Wind River Systems, Inc. and others. + * Copyright (c) 2010-2019 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -149,12 +149,24 @@ static void relocate(void * r) { func->func(); } +static U4_T get_offs4(uint8_t * x) { + U4_T offs = *(U4_T *)x; + if (relocs->file->byte_swap) SWAP(offs); + if (section->file->type != ET_REL) offs -= (U4_T)section->addr; + return offs; +} + +static U8_T get_offs8(uint8_t * x) { + U8_T offs = *(U8_T *)x; + if (relocs->file->byte_swap) SWAP(offs); + if (section->file->type != ET_REL) offs -= section->addr; + return offs; +} + void drl_relocate_in_context(Context * c, ELF_Section * s, U8_T offset, void * buf, size_t size, ELF_Section ** dst, int * rt_addr) { ELF_Section * r = s->relocate; ELF_Section * d = NULL; - uint8_t * p; - uint8_t * q; unsigned ix; if (rt_addr) *rt_addr = 0; @@ -223,18 +235,15 @@ void drl_relocate_in_context(Context * c, ELF_Section * s, U8_T offset, } /* Perform a dichotomic look up for each ordered area */ - for (ix = 0; ix < r->reloc_num_zones; ix++) { - p = (uint8_t *)r->data + r->reloc_zones_bondaries[ix] * r->entsize; - q = (uint8_t *)r->data + r->reloc_zones_bondaries[ix + 1] * r->entsize; + uint8_t * p = (uint8_t *)r->data + r->reloc_zones_bondaries[ix] * r->entsize; + uint8_t * q = (uint8_t *)r->data + r->reloc_zones_bondaries[ix + 1] * r->entsize; while (p < q) { unsigned n = (q - p) / r->entsize / 2; uint8_t * x = p + n * r->entsize; assert(x < q); if (r->file->elf64) { - U8_T offs = *(U8_T *)x; - if (r->file->byte_swap) SWAP(offs); - if (s->file->type != ET_REL) offs -= s->addr; + U8_T offs = get_offs8(x); if (offset > offs) { p = x + r->entsize; continue; @@ -243,6 +252,30 @@ void drl_relocate_in_context(Context * c, ELF_Section * s, U8_T offset, q = x; continue; } + { + /* ELF can have multiple relocations at same offset */ + uint8_t * x0 = x; + uint8_t * x1 = x; + while (x0 > p) { + uint8_t * y = x0 - r->entsize; + U8_T z = get_offs8(y); + assert(z <= offs); + if (z != offs) break; + x0 = y; + } + while (x1 + r->entsize < q) { + uint8_t * y = x1 + r->entsize; + U8_T z = get_offs8(y); + assert(z >= offs); + if (z != offs) break; + x1 = y; + } + while (x0 <= x1) { + relocate(x0); + x0 += r->entsize; + } + } + return; } else { U4_T offs = *(U4_T *)x; @@ -256,9 +289,31 @@ void drl_relocate_in_context(Context * c, ELF_Section * s, U8_T offset, q = x; continue; } + { + /* ELF can have multiple relocations at same offset */ + uint8_t * x0 = x; + uint8_t * x1 = x; + while (x0 > p) { + uint8_t * y = x0 - r->entsize; + U4_T z = get_offs4(y); + assert(z <= offs); + if (z != offs) break; + x0 = y; + } + while (x1 + r->entsize < q) { + uint8_t * y = x1 + r->entsize; + U4_T z = get_offs4(y); + assert(z >= offs); + if (z != offs) break; + x1 = y; + } + while (x0 <= x1) { + relocate(x0); + x0 += r->entsize; + } + } + return; } - relocate(x); - return; } } } diff --git a/agent/tcf/services/expressions.c b/agent/tcf/services/expressions.c index 67968556..5f6b9a3a 100644 --- a/agent/tcf/services/expressions.c +++ b/agent/tcf/services/expressions.c @@ -1214,12 +1214,12 @@ static int builtin_identifier(int mode, char * name, Value * v) { case 1: expression(mode, v); load_value(v); - file_name = tmp_strndup((char *)v->value, v->size); + file_name = tmp_strndup((char *)v->value, (size_t)v->size); break; case 2: expression(mode, v); load_value(v); - sect_name = tmp_strndup((char *)v->value, v->size); + sect_name = tmp_strndup((char *)v->value, (size_t)v->size); break; default: error(ERR_INV_EXPRESSION, "Too many arguments"); |