MCPcopy Create free account
hub / github.com/lief-project/LIEF / main

Function main

examples/cpp/dwarf_editor.cpp:11–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9using namespace LIEF::logging;
10
11int 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}

Callers

nothing calls this directly

Calls 12

is_extendedFunction · 0.50
parseFunction · 0.50
set_producerMethod · 0.45
create_functionMethod · 0.45
set_addressMethod · 0.45
set_return_typeMethod · 0.45
pointer_toMethod · 0.45
create_structureMethod · 0.45
create_stack_variableMethod · 0.45
set_stack_offsetMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected