Module: Elf

Defined in:
lib/mithril/elf.rb,
lib/mithril/parser.rb,
lib/mithril/writer.rb,
lib/mithril/writer2.rb,
lib/mithril/policy/dsl.rb,
lib/mithril/policy/inject_policy.rb

Overview

TODO: freeze some things after parse?

Defined Under Namespace

Modules: Parser, Policy, Writer, Writer2 Classes: Dynamic, ElfFile, GnuVersion, NoBits, ProgBits, Relocation, Symbol, SymbolTable, TLS

Constant Summary collapse

DT =
ElfFlags::DynamicType
SHT =
ElfFlags::SectionType
SHF =
ElfFlags::SectionFlags
STB =
ElfFlags::SymbolBinding
SHN =
ElfFlags::SpecialSection
STT =
ElfFlags::SymbolType
STV =
ElfFlags::SymbolVisibility
ET =
ElfFlags::Type
PT =
ElfFlags::PhdrType
PF =
ElfFlags::PhdrFlags
R =
ElfFlags::Relocation
NOTE_ALIGN =
4
NOTE_FLAGS =
SHF::SHF_ALLOC
NOTE_ENTSIZE =
0

Class Method Summary collapse

Class Method Details

.policy(&block) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/mithril/policy/inject_policy.rb', line 10

def self.policy(&block)
  #TODO: optional arg?
  Elf::rewrite(ARGV[0]) do |file|
    file.build_policy do
      instance_exec(file,&block)
    end
  end
end

.rewrite(filename, &block) ⇒ Object



27
28
29
30
31
32
# File 'lib/mithril/elf.rb', line 27

def self.rewrite(filename,&block)    
  FileUtils::cp(filename,filename+".bak")
  file = Elf::Parser::from_file(filename)
  block.call(file)
  Elf::Writer::Writer.to_file(filename,file)
end