Proc.new {|file,filename|
tag('program') do
section('.init')
section('.fini')
section('.text')
section('.data')
section('.bss')
section('.rodata')
section('.got')
end
tag('libraries') do
section('.plt')
end
state('main') do
exec 'program'
readwrite 'libraries'
readwrite 'program'
readwrite :default
to('libs') do
plt = file.progbits.select{|x|x.name==".plt"}.first
(plt.addr .. (plt.addr + plt.size)).step(8).each do |plt_addr| call plt_addr
end
end
to('libs') do
call '_dl_runtime_resolve'
end
end
state('libs') do
exec 'libraries'
readwrite 'libraries'
readwrite 'program'
readwrite :default
exec :default to 'main' do
call file.entry.to_i
H::initializer_functions(filename).each {|initializer|
call initializer
}
call section_start('.init')
call '_fini'
end
end
start 'libs'
}