| 9 | using namespace LIEF::logging; |
| 10 | |
| 11 | int main(int argc, const char** argv) { |
| 12 | if (!LIEF::is_extended()) { |
| 13 | std::cerr << "This example requires the extended version of LIEF\n"; |
| 14 | return EXIT_FAILURE; |
| 15 | } |
| 16 | |
| 17 | if (argc != 2) { |
| 18 | std::cerr << "Usage: " << argv[0] << " <pe>\n"; |
| 19 | return EXIT_FAILURE; |
| 20 | } |
| 21 | |
| 22 | std::unique_ptr<LIEF::PE::Binary> pe = LIEF::PE::Parser::parse(argv[1]); |
| 23 | std::unique_ptr<LIEF::dwarf::Editor> editor = LIEF::dwarf::Editor::from_binary(*pe); |
| 24 | |
| 25 | std::unique_ptr<LIEF::dwarf::editor::CompilationUnit> unit = editor->create_compilation_unit(); |
| 26 | unit->set_producer("LIEF"); |
| 27 | |
| 28 | std::unique_ptr<LIEF::dwarf::editor::Function> func = unit->create_function("hello"); |
| 29 | func->set_address(0x123); |
| 30 | |
| 31 | func->set_return_type( |
| 32 | *unit->create_structure("my_struct_t")->pointer_to() |
| 33 | ); |
| 34 | |
| 35 | std::unique_ptr<LIEF::dwarf::editor::Variable> var = |
| 36 | func->create_stack_variable("local_var"); |
| 37 | |
| 38 | var->set_stack_offset(8); |
| 39 | editor->write("/tmp/out.debug"); |
| 40 | return EXIT_SUCCESS; |
| 41 | } |
nothing calls this directly
no test coverage detected