diff --git a/Userland/Utilities/disasm.cpp b/Userland/Utilities/disasm.cpp index 02ccda6089..93ecd74845 100644 --- a/Userland/Utilities/disasm.cpp +++ b/Userland/Utilities/disasm.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -27,7 +28,14 @@ ErrorOr serenity_main(Main::Arguments args) args_parser.add_positional_argument(path, "Path to i386 binary file", "path"); args_parser.parse(args); - auto file = TRY(Core::MappedFile::map(path)); + RefPtr file; + u8 const* asm_data = nullptr; + size_t asm_size = 0; + if ((TRY(Core::System::stat(path))).st_size > 0) { + file = TRY(Core::MappedFile::map(path)); + asm_data = static_cast(file->data()); + asm_size = file->size(); + } struct Symbol { size_t value; @@ -41,8 +49,6 @@ ErrorOr serenity_main(Main::Arguments args) }; Vector symbols; - u8 const* asm_data = static_cast(file->data()); - size_t asm_size = file->size(); size_t file_offset = 0; Vector::Iterator current_symbol = symbols.begin(); OwnPtr symbol_provider; // nullptr for non-ELF disassembly.