Commit 94f123f
authored
refactor(got-patching): extract shared GOT-patching primitives into libdd-got-hook (#2282)
Stacked under [feat(got-hook): add DT_HASH fallback, relocation type
guard, and hook_symbol](#2297)
# What does this PR do?
Moves the ELF GOT-patching infrastructure out of
libdd-profiling-heap-gotter into a new shared crate libdd-got-hook, so
multiple crates can reuse the same machinery for runtime function
interposition.
This is a pure code move. I tried to have no behavioral changes here.
What moves to `libdd-got-hook`
- `DynamicInfo::from_phdr`: parse PT_DYNAMIC from a loaded ELF object
- `gnu_hash` / `gnu_hash_symbol_count` / `gnu_hash_lookup` /
`check_sym`: GNU hash table utilities
- `iterate_libraries`: this is a `dl_iterate_phdr` wrapper with
panic-safe trampoline
- `PageProtGuard` / `read_proc_maps` / `MapEntry`: RELRO-aware page
protection management
- `lookup_symbol` / `LookupResult`: used for resolving a symbol across
all loaded objects
- `elf64_r_sym`: relocation info helper
- ELF types and constants
What stays in `libdd-profiling-heap-gotter`
- `SymbolOverrides`: multi-symbol registry
- `hooks.rs`: the actual `malloc`/`free`/`calloc`/`realloc` hook
functions
- lib.rs: `install_heap_overrides` / `update_heap_overrides` public API
# Motivation
What inspired you to submit this pull request?
# Additional Notes
Gated on @scottgerring's approval
# How to test the change?
Describe here in detail how the change can be validated.1 parent 38a1987 commit 94f123f
11 files changed
Lines changed: 787 additions & 573 deletions
File tree
- .github
- libdd-gotter
- src
- libdd-profiling-heap-gotter
- src
- tools/docker
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
| 54 | + | |
54 | 55 | | |
55 | | - | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
0 commit comments