Skip to content

[Bug] GEF cannot find stack mapping when using info sections #915

@Grazfather

Description

@Grazfather

GEF+GDB version

dev 9edd73e1

Operating System

N/A

Describe the issue you encountered

When debugging a remote target whose maps I can't read from e.g. procfs, I elected to load the elf directly. This makes gef.mapping.maps use __parse_gdb_info_sections instead of __parse_procfs_maps. This is fine for most sections, but it leaves the stack unmapped since the stack is not specified in the ELF header.

This breaks the stack view of context.

────────────────────────────────────────────────────────────────────── stack ────│       0000000000000094  0000000000000002   A       5     0     2
[!] Unmapped target address: '0x20041fd8'
gef➤  x/20wx $sp
0x20041fd8:     0x00000005      0xd0000000      0x02000000      0x02000000
0x20041fe8:     0x00000000      0x1000039f      0x10000194      0x20041f01
0x20041ff8:     0x18000000      0x1000013f      0x00000000      0x00000000
0x20042008:     0x00000000      0x00000000      0x00000000      0x00000000
0x20042018:     0x00000000      0x00000000      0x00000000      0x00000000

We could maybe add a way to manually add sections?

gef➤  pi s = Section(page_start=0x20041800, page_end=0x20042000, offset=0, permission=Permission(0))
gef➤  pi gef.memory._GefMemoryManager__maps.append(s)
────────────────────────────────────────────────────────────────────── stack ────
0x20041fd8│+0x0000:              ← $sp
0x20041fdc│+0x0004: 0xd0000000
0x20041fe0│+0x0008: 0x02000000
0x20041fe4│+0x000c: 0x02000000
0x20041fe8│+0x0010: 0x00000000  →  0x20041f00
0x20041fec│+0x0014: 0x1000039f  →  <main+47> b.n 0x1000038e <main+30>
0x20041ff0│+0x0018: 0x10000194  →  <wait_for_vector+6> bx r0
0x20041ff4│+0x001c: 0x20041f01  →  0x214b2fb5

Do you read the docs and look at previously closed issues/PRs for similar cases?

Yes

Architecture impacted

  • X86
  • X64
  • ARM
  • ARM64
  • MIPS
  • MIPS64
  • PPC
  • PPC64
  • RISCV

Describe your issue. Without a proper reproduction step-by-step, your issue will be ignored.

Provide a step-by-step to reproduce your issue.

Minimalist test case

Use this field for a minimal code to compile and spot the issue:

// compile with gcc -fPIE -pic -o my_issue.out my_issue.c
int main(){ return 0; }

You can also provide a Dockerfile if you prefer

Additional context?

  • Screenshots
  • Callstack
  • Coredumps
  • If possible and useful, please upload the binary

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions