2005-05-09 21:54:29 +00:00
|
|
|
#!/usr/local/bin/ruby
|
|
|
|
|
|
|
|
if ARGV.empty?
|
2005-05-09 22:01:28 +00:00
|
|
|
puts "usage: <delta value | t> <files ...>"
|
2005-05-09 21:54:29 +00:00
|
|
|
exit(1)
|
|
|
|
end
|
|
|
|
|
2005-05-09 22:01:28 +00:00
|
|
|
textmode = false
|
|
|
|
|
|
|
|
if ARGV[0] == 't'
|
|
|
|
ARGV.shift
|
|
|
|
textmode = true
|
|
|
|
else
|
|
|
|
delta = ARGV.shift.to_i
|
|
|
|
end
|
2005-05-09 21:54:29 +00:00
|
|
|
|
|
|
|
first = TRUE
|
|
|
|
last = [ ]
|
|
|
|
|
|
|
|
# simple algorithm, build up a list of all the possible addresses
|
|
|
|
# calculating the delta range for each address in the file... then
|
|
|
|
# just do a set intersection across these all and you have your results
|
|
|
|
|
|
|
|
ARGV.each do |file|
|
|
|
|
cur = [ ]
|
|
|
|
IO.foreach(file) do |line|
|
2005-05-09 22:01:28 +00:00
|
|
|
if textmode
|
|
|
|
cur << line
|
|
|
|
else
|
|
|
|
addr = line.hex
|
|
|
|
(-delta .. delta).each do |d|
|
|
|
|
cur << addr + d
|
|
|
|
end
|
2005-05-09 21:54:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if first
|
|
|
|
first = FALSE
|
|
|
|
last = cur
|
|
|
|
else
|
|
|
|
last = last & cur
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
# print da results
|
|
|
|
|
|
|
|
last.each { |l|
|
2005-05-09 22:36:33 +00:00
|
|
|
if textmode
|
|
|
|
puts l
|
|
|
|
else
|
|
|
|
puts "0x%08x" % l
|
|
|
|
end
|
2005-05-09 21:54:29 +00:00
|
|
|
}
|
|
|
|
|