mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
readelf: Port to LibMain
This commit is contained in:
parent
575fcc42c3
commit
0a9e84aff0
Notes:
sideshowbarker
2024-07-17 16:57:14 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/0a9e84aff0 Pull-request: https://github.com/SerenityOS/serenity/pull/13172 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/ldm5180
2 changed files with 10 additions and 15 deletions
|
@ -168,6 +168,7 @@ target_link_libraries(profile LibMain)
|
|||
target_link_libraries(ps LibMain)
|
||||
target_link_libraries(purge LibMain)
|
||||
target_link_libraries(pwd LibMain)
|
||||
target_link_libraries(readelf LibMain)
|
||||
target_link_libraries(realpath LibMain)
|
||||
target_link_libraries(reboot LibMain)
|
||||
target_link_libraries(rev LibMain)
|
||||
|
|
|
@ -10,10 +10,12 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibELF/DynamicLoader.h>
|
||||
#include <LibELF/DynamicObject.h>
|
||||
#include <LibELF/Image.h>
|
||||
#include <LibELF/Validation.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
@ -224,12 +226,9 @@ static const char* object_relocation_type_to_string(ElfW(Word) type)
|
|||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
if (pledge("stdio rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio rpath"));
|
||||
|
||||
const char* path;
|
||||
static bool display_all = false;
|
||||
|
@ -261,11 +260,11 @@ int main(int argc, char** argv)
|
|||
args_parser.add_option(display_hardening, "Display security hardening info", "checksec", 'c');
|
||||
args_parser.add_option(string_dump_section, "Display the contents of a section as strings", "string-dump", 'p', "section-name");
|
||||
args_parser.add_positional_argument(path, "ELF path", "path");
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
if (argc < 3) {
|
||||
args_parser.print_usage(stderr, argv[0]);
|
||||
return -1;
|
||||
if (arguments.argc < 3) {
|
||||
args_parser.print_usage(stderr, arguments.argv[0]);
|
||||
return Error::from_errno(EINVAL);
|
||||
}
|
||||
|
||||
if (display_headers) {
|
||||
|
@ -336,12 +335,7 @@ int main(int argc, char** argv)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
outln("Unable to open file {}", path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fd = TRY(Core::System::open(path, O_RDONLY));
|
||||
auto result = ELF::DynamicLoader::try_create(fd, path);
|
||||
if (result.is_error()) {
|
||||
outln("{}", result.error().text);
|
||||
|
|
Loading…
Add table
Reference in a new issue