2014-04-14 17:09:56 +02:00
|
|
|
if (__FILE__ == $0)
|
2014-04-19 22:25:46 +02:00
|
|
|
obj = Elf::ObjectFile.new Elf::TARGET_ARM
|
2014-04-14 17:09:56 +02:00
|
|
|
|
2014-04-19 22:25:46 +02:00
|
|
|
sym_strtab = Elf::StringTableSection.new(".strtab")
|
2014-04-14 17:09:56 +02:00
|
|
|
obj.add_section sym_strtab
|
2014-04-19 22:25:46 +02:00
|
|
|
symtab = Elf::SymbolTableSection.new(".symtab", sym_strtab)
|
2014-04-14 17:09:56 +02:00
|
|
|
obj.add_section symtab
|
|
|
|
|
2014-04-19 22:25:46 +02:00
|
|
|
text_section = Elf::TextSection.new(".text")
|
2014-04-14 17:09:56 +02:00
|
|
|
obj.add_section text_section
|
|
|
|
|
2014-04-19 22:25:46 +02:00
|
|
|
symtab.add_func_symbol "_start", 0, text_section, Elf::STB_GLOBAL
|
2014-04-14 17:09:56 +02:00
|
|
|
|
|
|
|
fp = File.open("test.o", "wb")
|
|
|
|
obj.write fp
|
|
|
|
|
|
|
|
fp.close
|
|
|
|
end
|
|
|
|
|