aboutsummaryrefslogtreecommitdiff
path: root/acid/elflink
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-04-19 18:18:37 +0000
committerrsc <devnull@localhost>2004-04-19 18:18:37 +0000
commit0a61c07d591273b76da21fb8386b669989da3707 (patch)
tree1dd9832f7d646f12c0ff5cf7ff64d1fddc6bd361 /acid/elflink
parentc8af1ab17b72f500c27688598dbb893f09f62c53 (diff)
downloadplan9port-0a61c07d591273b76da21fb8386b669989da3707.tar.gz
plan9port-0a61c07d591273b76da21fb8386b669989da3707.tar.bz2
plan9port-0a61c07d591273b76da21fb8386b669989da3707.zip
acid files
Diffstat (limited to 'acid/elflink')
-rw-r--r--acid/elflink54
1 files changed, 54 insertions, 0 deletions
diff --git a/acid/elflink b/acid/elflink
new file mode 100644
index 00000000..8e9f2e76
--- /dev/null
+++ b/acid/elflink
@@ -0,0 +1,54 @@
+aggr Rdebug
+{
+ 'X' 0 version;
+ 'X' 4 map;
+};
+
+aggr Rmap
+{
+ 'X' 0 addr;
+ 'X' 4 name;
+ 'X' 8 dynsect;
+ 'X' 12 next;
+ 'X' 16 prev;
+};
+
+defn
+rdebug()
+{
+ local a;
+
+ a = _DYNAMIC;
+ while *a != 0 do {
+ if *a == 21 then // 21 == DT_DEBUG
+ return *(a+4);
+ a = a+8;
+ }
+ return 0;
+}
+
+defn
+rlink()
+{
+ local r, m, n;
+
+ r = rdebug();
+ if r == 0 then
+ return {};
+ complex Rdebug r;
+ print("version ", r.version, "\n");
+
+ m = r.map;
+ n = 0;
+ while m != 0 && n < 100 do {
+ complex Rmap m;
+ print("map ", m\X, " base ", m.addr\X, " next ", m.next\X, " name ");
+ if m.name then
+ print(*(m.name\s));
+ else
+ print("''");
+ print("\n");
+ m = m.next;
+ n = n+1;
+ }
+}