haproxy/dev
Willy Tarreau 5689605c8e DEV: gdb: add a utility to find the post-mortem address from a core
More and more often, core dumps retrieved on systems that build with
-fPIE by default are becoming unexploitable. Even functions and global
symbols get relocated and gdb cannot figure their final position.
Ironically the post_mortem struct lying in its own section that was
meant to ease its finding is not exempt from this problem.

The only remaining way is to inspect the core to search for the
post-mortem magic, figure its offset from the file and look up the
corresponding virtual address with objdump. This is quite a hassle.

This patch implements a simple utility that opens a 64-bit core dump,
scans the program headers looking for a data segment which contains
the post-mortem magic, and prints it on stdout. It also places the
"pm_init" command alone on its own line to ease copy-pasting into the
gdb console. With this, at least the other commands in this directory
work again and allow to inspect the program's state. E.g:

  $ ./getpm core.57612
  Found post-mortem magic in segment 5:
    Core File Offset: 0xfc600 (0xd5000 + 0x27600)
    Runtime VAddr:    0x5613e52b6600 (0x5613e528f000 + 0x27600)
    Segment Size:     0x28000

  In gdb, copy-paste this line:

     pm_init 0x5613e52b6600

It's worth noting that the program has so few dependencies that it even
builds with nolibc, allowing to upload a static executable into containers
being debugged and lacking development tools and compilers. The build
procedure is indicated inthe source code.
2026-02-14 14:46:33 +01:00
..
base64 CONTRIB: move some dev-specific tools to dev/ 2021-04-02 17:48:42 +02:00
coccinelle DEV: coccinelle: add a test to detect unchecked calloc() 2024-08-24 19:13:56 +02:00
flags DEV: lags/show-sess-to-flags: Properly handle fd state on server side 2024-11-25 21:57:30 +01:00
gdb DEV: gdb: add a utility to find the post-mortem address from a core 2026-02-14 14:46:33 +01:00
h2 DEV: h2: fix h2-tracer.lua nil value index 2025-04-08 17:44:41 +02:00
haring CLEANUP: use the automatic alignment feature 2025-12-09 17:14:58 +01:00
hpack DEV: hpack: fix trash build regression 2023-01-27 10:22:20 +01:00
ncpu DEV: ncpu: also emulate sysconf() for _SC_NPROCESSORS_* 2025-03-14 18:30:30 +01:00
patchbot DEV: patchbot: prepare for new version 3.4-dev 2025-11-26 15:35:22 +01:00
phash BUILD: dev/phash: remove the accidentally committed a.out file 2025-07-02 10:55:13 +02:00
plug_qdisc CONTRIB: move some dev-specific tools to dev/ 2021-04-02 17:48:42 +02:00
poll DEV: poll: add support for epoll 2022-11-25 17:07:22 +01:00
qpack MINOR: qpack: implement standalone decoder tool 2022-06-15 15:42:10 +02:00
sslkeylogger DEV: sslkeylogger: handle file opening error 2023-10-03 15:23:35 +02:00
tcploop DEV: tcploop: add minimal support for unix sockets 2023-01-11 11:27:20 +01:00
term_events MINOR: tevt/dev: Parse tuple of termination events 2025-01-31 10:46:08 +01:00
trace CONTRIB: move some dev-specific tools to dev/ 2021-04-02 17:48:42 +02:00
udp BUILD: address a few remaining calloc(size, n) cases 2024-02-10 11:37:27 +01:00