Skip to content

Instantly share code, notes, and snippets.

@johnl
Created January 5, 2018 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnl/834c715d296b13758ef52973977d19e1 to your computer and use it in GitHub Desktop.
Save johnl/834c715d296b13758ef52973977d19e1 to your computer and use it in GitHub Desktop.
Script to resolve segfault symbol addresses in shared libs
#!/usr/bin/ruby
# use this like: dmesg | grep segfault | segfault-shared-lib-symbol-resolver.rb | addr2line -e /usr/lib/debug/usr/lib/i386-linux-gnu/libruby-2.1.so.2.1.0
# kernel: [352246.560406] ruby[1178]: segfault at bf6630d0 ip b75f6fa3 sp bf6630c0 error 6 in libruby-2.1.so.2.1.0[b7469000+254000]
STDIN.each_line do |l|
r = /ip ([^ ]+).*\[([^+]+)/
m = r.match l
ip = m[1].to_i(16)
offs = m[2].to_i(16)
addr = ip - offs
puts addr.to_s(16)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment