-
-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
683fc6c
commit 3497515
Showing
12 changed files
with
116 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
set(PROFILING_FLAGS | ||
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc | ||
-fno-builtin-free -fno-omit-frame-pointer -g) | ||
target_compile_options(LIB_LIEF PUBLIC ${PROFILING_FLAGS}) | ||
|
||
add_executable(elf_profiler elf_profiler.cpp) | ||
|
||
set_target_properties(elf_profiler | ||
PROPERTIES POSITION_INDEPENDENT_CODE ON | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED ON) | ||
|
||
target_compile_options(elf_profiler PUBLIC ${PROFILING_FLAGS}) | ||
target_link_libraries(elf_profiler PRIVATE LIB_LIEF) | ||
|
||
add_executable(macho_profiler macho_profiler.cpp) | ||
target_compile_options(macho_profiler PUBLIC ${PROFILING_FLAGS}) | ||
target_link_libraries(macho_profiler PRIVATE LIB_LIEF) | ||
|
||
set_target_properties(macho_profiler | ||
PROPERTIES POSITION_INDEPENDENT_CODE ON | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED ON) | ||
|
||
add_executable(pe_profilier pe_profilier.cpp) | ||
target_compile_options(pe_profilier PUBLIC ${PROFILING_FLAGS}) | ||
target_link_libraries(pe_profilier PRIVATE LIB_LIEF) | ||
|
||
set_target_properties(pe_profilier | ||
PROPERTIES POSITION_INDEPENDENT_CODE ON | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED ON) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
#include <LIEF/LIEF.hpp> | ||
#include <filesystem> | ||
|
||
void process_file(const std::filesystem::path& target) { | ||
LIEF::ELF::Parser::parse(target); | ||
} | ||
|
||
void process_dir(const std::filesystem::path& target) { | ||
for (const auto& e : std::filesystem::directory_iterator(target)) { | ||
if (e.is_directory()) { | ||
process_dir(e.path()); | ||
} | ||
else if (e.is_regular_file() && LIEF::ELF::is_elf(e.path())) { | ||
process_file(e.path()); | ||
} | ||
} | ||
} | ||
|
||
int main(int argc, const char** argv) { | ||
if (argc < 2) { | ||
std::cerr << "Usage: " << argv[0] << " <binary>" << '\n'; | ||
return EXIT_FAILURE; | ||
const std::filesystem::path target{argv[1]}; | ||
if (std::filesystem::is_directory(target)) { | ||
process_dir(target); | ||
} else { | ||
process_file(target); | ||
} | ||
std::unique_ptr<LIEF::ELF::Binary> binary = LIEF::ELF::Parser::parse(argv[1]); | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
#include <LIEF/LIEF.hpp> | ||
|
||
int main(int argc, const char** argv) { | ||
if (argc < 2) { | ||
std::cerr << "Usage: " << argv[0] << " <binary>" << '\n'; | ||
return EXIT_FAILURE; | ||
} | ||
#include <filesystem> | ||
void process_file(const std::filesystem::path& target) { | ||
LIEF::MachO::ParserConfig config; | ||
config.parse_dyld_rebases = false; | ||
config.parse_dyld_exports = false; | ||
config.parse_dyld_bindings = false; | ||
auto binary = LIEF::MachO::Parser::parse(argv[1], config); | ||
auto binary = LIEF::MachO::Parser::parse(target, config); | ||
|
||
} | ||
|
||
void process_dir(const std::filesystem::path& target) { | ||
for (const auto& e : std::filesystem::directory_iterator(target)) { | ||
if (e.is_directory()) { | ||
process_dir(e.path()); | ||
} | ||
else if (e.is_regular_file() && LIEF::MachO::is_macho(e.path())) { | ||
process_file(e.path()); | ||
} | ||
} | ||
} | ||
|
||
int main(int argc, const char** argv) { | ||
const std::filesystem::path target{argv[1]}; | ||
if (std::filesystem::is_directory(target)) { | ||
process_dir(target); | ||
} else { | ||
process_file(target); | ||
} | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include <LIEF/LIEF.hpp> | ||
#include <iostream> | ||
|
||
int main(int argc, char** argv) { | ||
if (argc != 2) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <LIEF/LIEF.hpp> | ||
#include <filesystem> | ||
#include <iostream> | ||
|
||
void process_file(const std::filesystem::path& target) { | ||
LIEF::PE::Parser::parse(target); | ||
} | ||
|
||
void process_dir(const std::filesystem::path& target) { | ||
for (const auto& e : std::filesystem::directory_iterator(target)) { | ||
if (e.is_directory()) { | ||
process_dir(e.path()); | ||
} | ||
else if (e.is_regular_file() && LIEF::PE::is_pe(e.path())) { | ||
process_file(e.path()); | ||
} | ||
} | ||
} | ||
|
||
int main(int argc, const char** argv) { | ||
const std::filesystem::path target{argv[1]}; | ||
if (std::filesystem::is_directory(target)) { | ||
process_dir(target); | ||
} else { | ||
process_file(target); | ||
} | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.