Skip to content

Commit

Permalink
ldelf: Fix dumping physical address of ELF segment
Browse files Browse the repository at this point in the history
Fix the strange values of "pa" when TA ELF mappings is dumped. The
function argument of print_seg() should be explicit physical address of
mapping rather than offset of the segment.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Tested-by: Yu Chien Peter Lin <peterlin@andestech.com>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_armv8a)
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
  • Loading branch information
gagachang authored and jforissier committed Apr 18, 2024
1 parent 6376023 commit 2567597
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ldelf/ta_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,9 +1476,9 @@ void ta_elf_print_mappings(void *pctx, print_func_t print_func,
get_next_in_order(elf_queue, &elf, &seg, &elf_idx);
while (true) {
vaddr_t va = -1;
paddr_t pa = -1;
size_t sz = 0;
uint32_t flags = DUMP_MAP_SECURE;
size_t offs = 0;

if (seg) {
va = rounddown(seg->vaddr + elf->load_addr);
Expand All @@ -1491,6 +1491,7 @@ void ta_elf_print_mappings(void *pctx, print_func_t print_func,

/* If there's a match, it should be the same map */
if (maps[map_idx].va == va) {
pa = maps[map_idx].pa;
/*
* In shared libraries the first page is
* mapped separately with the rest of that
Expand Down Expand Up @@ -1529,15 +1530,14 @@ void ta_elf_print_mappings(void *pctx, print_func_t print_func,
if (!seg)
break;

offs = rounddown(seg->offset);
if (seg->flags & PF_R)
flags |= DUMP_MAP_READ;
if (seg->flags & PF_W)
flags |= DUMP_MAP_WRITE;
if (seg->flags & PF_X)
flags |= DUMP_MAP_EXEC;

print_seg(pctx, print_func, idx, elf_idx, va, offs, sz, flags);
print_seg(pctx, print_func, idx, elf_idx, va, pa, sz, flags);
idx++;

if (!get_next_in_order(elf_queue, &elf, &seg, &elf_idx))
Expand Down

0 comments on commit 2567597

Please sign in to comment.