https://github.com/tenderlove/odinflex
Different utilities that I've written
https://github.com/tenderlove/odinflex
ar macho macho-parser
Last synced: about 1 year ago
JSON representation
Different utilities that I've written
- Host: GitHub
- URL: https://github.com/tenderlove/odinflex
- Owner: tenderlove
- License: apache-2.0
- Created: 2021-07-06T23:32:03.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-02-08T21:16:10.000Z (over 4 years ago)
- Last Synced: 2025-05-07T17:51:42.042Z (about 1 year ago)
- Topics: ar, macho, macho-parser
- Language: Ruby
- Homepage:
- Size: 113 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OdinFlex
This is just a collection of weird tools that I wrote for dealing with some
binary file formats. There is an AR parser and a MachO parser in here.
## Examples
Find debugging information:
```ruby
mach_o = OdinFlex::MachO.new(io)
abbrev = mach_o.find_section "__debug_abbrev"
# Do stuff with the debugging information
```
List all symbols in Ruby:
```ruby
require "odinflex/mach-o"
File.open(RbConfig.ruby) do |f|
my_macho = OdinFlex::MachO.new f
my_macho.each do |section|
if section.symtab?
section.nlist.each { |symbol|
p symbol
}
end
end
end
```
Find Ruby's archive file, then read the archive:
```ruby
require "odinflex/mach-o"
require "odinflex/ar"
archive = nil
File.open(RbConfig.ruby) do |f|
my_macho = OdinFlex::MachO.new f
my_macho.each do |section|
if section.symtab?
archive = section.nlist.find_all(&:archive?).map(&:archive).uniq.first
break
end
end
end
File.open(archive) do |f|
ar = OdinFlex::AR.new f
ar.each do |object_file|
p object_file.identifier
end
end
```