Skip to content

Commit

Permalink
Merge branch 'master' into i7113-view-decode-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav92003 authored Jan 30, 2025
2 parents a10d45b + ed508d6 commit 7b2cbf5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions clients/drcachesim/tracer/raw2trace_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ module_mapper_t::read_and_map_modules()
modvec_.push_back(module_t(info.path, info.start, NULL, 0, 0, 0));
} else if (info.containing_index != info.index) {
// For split segments, we assume our mapped layout matches the original.
byte *seg_map_base = modvec_[info.containing_index].map_seg_base +
(info.start - modvec_[info.containing_index].orig_seg_base);
byte *seg_map_base = modvec_[info.containing_index].map_seg_base -
modvec_[info.containing_index].orig_seg_base + info.start;
VPRINT(1, "Secondary segment: module %d seg %p-%p = %s\n",
(int)modvec_.size(), seg_map_base, seg_map_base + info.size,
info.path);
Expand Down
6 changes: 3 additions & 3 deletions clients/drcachesim/tracer/raw2trace_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class module_mapper_t {
reinterpret_cast<app_pc>(entry->start_pc);
} else {
size_t idx = static_cast<size_t>(modidx); // Avoid win32 warnings.
app_pc res = map_pc - modvec_[idx].map_seg_base + modvec_[idx].orig_seg_base;
app_pc res = modvec_[idx].orig_seg_base - modvec_[idx].map_seg_base + map_pc;
#ifdef ARM
// Match Thumb vs Arm mode by setting LSB.
if (TESTANY(1, modoffs))
Expand All @@ -312,8 +312,8 @@ class module_mapper_t {
size_t idx = static_cast<size_t>(modidx); // Avoid win32 warnings.
// Cast to unsigned pointer-sized int first to avoid sign-extending.
return reinterpret_cast<app_pc>(
reinterpret_cast<ptr_uint_t>(modvec_[idx].orig_seg_base)) +
(modoffs - modvec_[idx].seg_offs);
reinterpret_cast<ptr_uint_t>(modvec_[idx].orig_seg_base) +
(modoffs - modvec_[idx].seg_offs));
}
}

Expand Down
6 changes: 3 additions & 3 deletions core/drlibc/drlibc_module_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ module_vaddr_from_prog_header(app_pc prog_header, uint num_segments,
min_vaddr =
MIN(min_vaddr, (app_pc)ALIGN_BACKWARD(prog_hdr->p_vaddr, PAGE_SIZE));
if (min_vaddr == (app_pc)prog_hdr->p_vaddr)
first_end = (app_pc)prog_hdr->p_vaddr + prog_hdr->p_memsz;
first_end = (app_pc)(prog_hdr->p_vaddr + prog_hdr->p_memsz);
max_end = MAX(
max_end,
(app_pc)ALIGN_FORWARD(prog_hdr->p_vaddr + prog_hdr->p_memsz, PAGE_SIZE));
Expand Down Expand Up @@ -456,7 +456,7 @@ elf_loader_map_phdrs(elf_loader_t *elf, bool fixed, map_fn_t map_func,
* (notably some kernels) seem to ignore it. These corner cases are left
* as unsolved for now.
*/
seg_base = (app_pc)ALIGN_BACKWARD(prog_hdr->p_vaddr, PAGE_SIZE) + delta;
seg_base = (app_pc)(ALIGN_BACKWARD(prog_hdr->p_vaddr, PAGE_SIZE) + delta);
seg_end =
(app_pc)ALIGN_FORWARD(prog_hdr->p_vaddr + prog_hdr->p_filesz, PAGE_SIZE) +
delta;
Expand Down Expand Up @@ -522,7 +522,7 @@ elf_loader_map_phdrs(elf_loader_t *elf, bool fixed, map_fn_t map_func,
}
ASSERT(map != NULL);
/* fill zeros at extend size */
file_end = (app_pc)prog_hdr->p_vaddr + prog_hdr->p_filesz;
file_end = (app_pc)(prog_hdr->p_vaddr + prog_hdr->p_filesz);
if (seg_end > file_end + delta) {
/* There is typically one RW PT_LOAD segment for .data and
* .bss. If .data ends and .bss starts before filesz bytes,
Expand Down
4 changes: 2 additions & 2 deletions core/ir/aarch64/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,8 +1081,8 @@ static bool
decode_opnd_adr_page(int scale, uint enc, byte *pc, OUT opnd_t *opnd)
{
uint bits = (enc >> 3 & 0x1ffffc) | (enc >> 29 & 3);
byte *addr = ((byte *)((ptr_uint_t)pc >> scale << scale) +
extract_int(bits, 0, 21) * ((ptr_int_t)1 << scale));
byte *addr = (byte *)(((ptr_uint_t)pc >> scale << scale) +
extract_int(bits, 0, 21) * ((ptr_int_t)1 << scale));
*opnd = opnd_create_rel_addr(addr, OPSZ_0);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion core/ir/instrlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ instrlist_encode_to_copy(void *drcontext, instrlist_t *ilist, byte *copy_pc,
byte *pc = instr_encode_to_copy(dcontext, inst, copy_pc, final_pc);
if (pc == NULL)
return NULL;
final_pc += pc - copy_pc;
final_pc = (byte *)((ptr_uint_t)final_pc + (pc - copy_pc));
copy_pc = pc;
}
return copy_pc;
Expand Down
4 changes: 2 additions & 2 deletions core/ir/x86/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3012,7 +3012,7 @@ encode_cti(instr_t *instr, byte *copy_pc, byte *final_pc,
CLIENT_ASSERT(!instr_is_cti_short_rewrite(instr, NULL),
"encode_cti error: jecxz/loop already mangled");
/* offset is from start of next instr */
offset = target - ((ptr_int_t)(pc + 1 - copy_pc + final_pc));
offset = target - (pc + 1 - copy_pc + (ptr_uint_t)final_pc);
if (check_reachable && !(offset >= INT8_MIN && offset <= INT8_MAX)) {
CLIENT_ASSERT(!assert_reachable,
"encode_cti error: target beyond 8-bit reach");
Expand All @@ -3023,7 +3023,7 @@ encode_cti(instr_t *instr, byte *copy_pc, byte *final_pc,
} else {
/* 32-bit offset */
/* offset is from start of next instr */
ptr_int_t offset = target - ((ptr_int_t)(pc + 4 - copy_pc + final_pc));
ptr_int_t offset = target - (pc + 4 - copy_pc + (ptr_uint_t)final_pc);
#ifdef X64
if (check_reachable && !REL32_REACHABLE_OFFS(offset)) {
CLIENT_ASSERT(!assert_reachable,
Expand Down
3 changes: 2 additions & 1 deletion ext/drcovlib/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ module_read_entry_print(module_read_entry_t *entry, uint idx, char *buf, size_t
len = dr_snprintf(buf, size,
"%3u, %3u, " PFX ", " PFX ", " PFX ", " ZHEX64_FORMAT_STRING
", " PFX ", ",
idx, entry->containing_id, entry->base, entry->base + entry->size,
idx, entry->containing_id, entry->base,
(app_pc)((ptr_uint_t)entry->base + (ptr_uint_t)entry->size),
entry->entry, entry->offset, entry->preferred_base);
if (len == -1)
return -1;
Expand Down

0 comments on commit 7b2cbf5

Please sign in to comment.