feat(gotter)!: add DT_HASH fallback, relocation type guard, and hook_symbol - #2297
feat(gotter)!: add DT_HASH fallback, relocation type guard, and hook_symbol#2297gyuheon0h wants to merge 14 commits into
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 0fd2fba | Docs | Datadog PR Page | Give us feedback! |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
BenchmarksComparisonBenchmark execution time: 2026-08-07 19:39:42 Comparing candidate commit 0fd2fba in PR branch Found 0 performance improvements and 5 performance regressions! Performance is the same for 135 metrics, 0 unstable metrics.
|
1c3157f to
5f00ce2
Compare
e9b992a to
18d4e84
Compare
1c3157f to
5f00ce2
Compare
18d4e84 to
00baa22
Compare
5f00ce2 to
4618f83
Compare
00baa22 to
d4b9d82
Compare
4618f83 to
8713e2e
Compare
d4b9d82 to
560d0a6
Compare
0f700c2 to
934d93c
Compare
560d0a6 to
45c074d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 934d93c530
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| matches!( | ||
| r_type, | ||
| R_X86_64_GLOB_DAT | R_X86_64_JUMP_SLOT | R_AARCH64_GLOB_DAT | R_AARCH64_JUMP_SLOT |
There was a problem hiding this comment.
Gate the relocation filter to supported architectures
On 64-bit Linux targets other than x86_64/aarch64, this crate still compiles and the GOT-patching APIs are active, but this shared predicate now admits only the x86_64/aarch64 relocation numbers. Architectures such as s390x, ppc64, or riscv64 use different GLOB_DAT/JUMP_SLOT values, so their import relocations are all skipped and installation can report success after resolving originals without actually patching any GOT entries. Either gate the Linux implementation to the supported architectures or add the architecture-specific constants.
Useful? React with 👍 / 👎.
934d93c to
5e08f80
Compare
45c074d to
11a3920
Compare
5e08f80 to
e2110f9
Compare
e2110f9 to
cad573a
Compare
a4a6346 to
9d4d601
Compare
9d4d601 to
f19c984
Compare
No. Unfortunately, its hard to see what customers are running for their elf hashing :( but as part of just making this library more robust, I thought it was worth to do haha |
| (sym_count_fallback(symtab, strtab, sysv_hash), 0) | ||
| }; | ||
|
|
||
| // SAFETY (applies to all `slice::from_raw_parts` calls below): |
There was a problem hiding this comment.
These safety points come from from_raw_parts contract
2d9bca3 to
e9568ee
Compare
| break; | ||
| } | ||
| if let Some(sname) = info.sym_name(idx) { | ||
| let sym = &info.symtab[idx as usize]; |
There was a problem hiding this comment.
I think we could use get here to avoid the indexing, or, restructure to avoid double indexing - sym_name indexes into symtab anyway but then discards it; we could add a sym_entry accessor that returns the tuple (Elf64_Sym, &Cstr) and then use it to get both here
There was a problem hiding this comment.
Ah, good idea. Will help with possibility of diverging also
66e3a50 to
740e1b9
Compare

Stacked above refactor(got-patching): extract shared GOT-patching primitives into libdd-got-hook
Stacked under feat(crashtracking): retrieve c assert message for linux when __assert_fail is dynamically loaded
PROF-15629
What does this PR do?
Adds three general improvements to
libdd-got-hookfor crash tracking (and beneficial to heap profiling):DT_HASH(SysV) fallback:DynamicInfo::from_phdrno longer requiresDT_GNU_HASH. Objects linked with--hash-style=sysvare now parsed by readingnchainfrom the SysV hash header. We jjust skipped these objects previously.elf64_r_type+is_got_pointer_relocnow only patchesGLOB_DATandJUMP_SLOTrelocations (pointer-sized GOT slots) on bothx86_64andaarch64. Non-pointer relocation types are now skipped, preventing potential corruption of adjacent code/data from writing 8 bytes into a 4-byte relocation field. Applied to bothlibdd-got-hook'spatch_got_entriesandlibdd-profiling-heap-gotter'sprocess_relocation. (this was a codex recommendation)hook_symbol: Single-symbol convenience wrapper that combinesdlsym+iterate_libraries+patch_got_entriesinto one call.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.