Commit 3d34a52
committed
tools/bashreadline: auto-detect libreadline.so for dynamically linked bash
On systems where /bin/bash dynamically links libreadline (which is the
common case on modern distros), the `readline` symbol in the bash ELF
is merely an undefined import (SHN_UNDEF, st_value=0). BCC's
attach_uretprobe then fails with:
Exception: could not determine address of symbol readline in /bin/bash
The tool already provides a `-s` flag for users to manually specify the
libreadline.so path, but this is inconvenient and breaks automated
smoke tests.
This patch adds automatic detection: after resolving the symbol name,
it checks whether the symbol is actually defined (not just imported) in
the target binary. If not, it uses `ldd /bin/bash` to find the real
libreadline.so path and redirects the uprobe there.
The logic is backward-compatible:
- If bash statically links readline -> symbol is defined, no change
- If user passes `-s` -> manual path used, no auto-detection
- If bash dynamically links readline -> auto-fallback to .so1 parent a3dcb9a commit 3d34a52
1 file changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
47 | 78 | | |
48 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
49 | 88 | | |
50 | 89 | | |
51 | 90 | | |
| |||
0 commit comments