diff --git a/CMakeLists.txt b/CMakeLists.txt index ac7390a..8e80383 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,6 @@ set(fxos_core_SOURCES lib/passes/syscall.cpp lib/project.cpp lib/semantics.cpp - lib/symbols.cpp lib/view/assembly.cpp lib/vspace.cpp @@ -79,7 +78,6 @@ set(fxos_shell_SOURCES shell/e.cpp shell/h.cpp shell/i.cpp - shell/m.cpp shell/p.cpp shell/s.cpp ${FLEX_Lexer_OUTPUTS} diff --git a/include/fxos/symbols.h b/include/fxos/symbols.h deleted file mode 100644 index 2d7b7f3..0000000 --- a/include/fxos/symbols.h +++ /dev/null @@ -1,96 +0,0 @@ -//---------------------------------------------------------------------------// -// 1100101 |_ mov #0, r4 __ // -// 11 |_ <0xb380 %5c4> / _|_ _____ ___ // -// 0110 |_ 3.50 -> 3.60 | _\ \ / _ (_-< // -// |_ base# + offset |_| /_\_\___/__/ // -//---------------------------------------------------------------------------// -// fxos/symbols: User-extensible naming scheme for OS objects -// -// This header provides tools to define symbols, ie. names attached to fixed or -// symbolic addresses. Currently supported: -// - Address: the name maps to a fixed 32-bit virtual address. -// - Syscall: the name maps to a syscall number resolved by OS analysis. -// -// The SymbolTable structure manages a set of symbols, usually all the symbols -// in a given virtual space. -//--- - -#ifndef FXOS_SYMBOLS_H -#define FXOS_SYMBOLS_H - -#include -#include -#include -#include - -namespace FxOS { - -/* A named symbol that can be substituted to literal values in the code. */ -struct Symbol -{ - enum Type { Syscall = 1, Address = 2 }; - - enum Type type; - uint32_t value; - - /* Symbol name, no particular conventions */ - std::string name; - - bool operator<(const FxOS::Symbol &right) const - { - return (type < right.type) - || (value < right.value && type == right.type); - } - - bool operator>(const FxOS::Symbol &right) const - { - return (type > right.type) - || (value > right.value && type == right.type); - } - - bool operator==(const FxOS::Symbol &right) const - { - return value == right.value && type == right.type; - } - - bool operator!=(const FxOS::Symbol &right) const - { - return value != right.value || type != right.type; - } - - bool operator>=(const FxOS::Symbol &right) const - { - return (type > right.type) - || (value >= right.value && type == right.type); - } - - bool operator<=(const FxOS::Symbol &right) const - { - return (type < right.type) - || (value <= right.value && type == right.type); - } -}; - -/* A symbol table, usually the set of symbols of a virtual space */ -struct SymbolTable -{ - SymbolTable(); - - /* Allow move but disable copy */ - SymbolTable(SymbolTable const &other) = delete; - SymbolTable(SymbolTable &&other) = default; - - std::string table_name; - std::vector symbols; - - /* Add a symbol to the table */ - void add(Symbol s); - /* Query a value for a certain type of symbol */ - std::optional query(Symbol::Type type, uint32_t value) const; - /* Lookup the symbol behind a given name */ - std::optional lookup(std::string name) const; -}; - -} /* namespace FxOS */ - -#endif /* FXOS_SYMBOLS_H */ diff --git a/include/fxos/vspace.h b/include/fxos/vspace.h index facd1a0..91e7207 100644 --- a/include/fxos/vspace.h +++ b/include/fxos/vspace.h @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -127,7 +126,6 @@ public: char const *translate_dynamic(uint32_t addr, int *size) override; // TODO: Remove these - SymbolTable symbols; Disassembly disasm; private: std::unique_ptr m_os; diff --git a/lib/symbols.cpp b/lib/symbols.cpp deleted file mode 100644 index c8f3802..0000000 --- a/lib/symbols.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//---------------------------------------------------------------------------// -// 1100101 |_ mov #0, r4 __ // -// 11 |_ <0xb380 %5c4> / _|_ _____ ___ // -// 0110 |_ 3.50 -> 3.60 | _\ \ / _ (_-< // -// |_ base# + offset |_| /_\_\___/__/ // -//---------------------------------------------------------------------------// - -#include -#include - -namespace FxOS { - -SymbolTable::SymbolTable() -{ -} - -void SymbolTable::add(Symbol s) -{ - symbols.push_back(s); -} - -std::optional SymbolTable::query( - Symbol::Type type, uint32_t value) const -{ - for(auto &sym: symbols) { - if(sym.type == type && sym.value == value) - return sym.name; - } - - return std::nullopt; -} - -std::optional SymbolTable::lookup(std::string name) const -{ - for(auto &sym: symbols) { - if(sym.name == name) - return sym; - } - - return std::nullopt; -} - -} /* namespace FxOS */ diff --git a/shell/m.cpp b/shell/m.cpp deleted file mode 100644 index 0beadaa..0000000 --- a/shell/m.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "parser.h" -#include "shell.h" -#include - -//--- -// ms -//--- - -static FxOS::Symbol parse_ms(Session &session, Parser &parser) -{ - FxOS::Symbol s; - - if(parser.lookahead().type == T::SYSCALL) { - s.type = FxOS::Symbol::Syscall; - s.value = parser.expect(T::SYSCALL).value.NUM; - } - else { - s.type = FxOS::Symbol::Address; - s.value = parser.expr(session.currentBinary()); - } - - s.name = parser.symbol(); - parser.end(); - - return s; -} - -void _ms(Session &session, Symbol s) -{ - if(!session.currentBinary()) - return; - FxOS_log(ERR, "Creating new objects is a TODO o(x_x)o\n"); - // session.current_space->symbols.add(s); -} - -static ShellCommand _ms_cmd( - "ms", [](Session &s, Parser &p) { _ms(s, parse_ms(s, p)); }, - [](Session &s, Parser &p) { parse_ms(s, p); }, "Metadata Symbol", R"( -ms - -Defines a new symbol at the specified address or syscall number in the current -virtual space. If a syscall number is provided, the address is not resolved; -the same syscall symbol can be used across multiple OS versions regardless of -where the functions are actually located. -)"); diff --git a/shell/parser.h b/shell/parser.h index f8ae5ea..3c2a513 100644 --- a/shell/parser.h +++ b/shell/parser.h @@ -145,9 +145,9 @@ public: to query symbol values */ long num(); long expr(Binary *b); - /* Read a range; again $ and symbols are interpreted. If (before) and - (after) are both specified, a single value will also be accepted, and - the range [value-before, value+after) will be returned. */ + /* Read a range; again symbols are interpreted. If (before) and (after) are + both specified, a single value will also be accepted, and the range + [value-before, value+after) will be returned. */ Range range(Binary *b, long before=-1, long after=-1); /* Read an expression or a range */ std::variant expr_or_range(Binary *b); diff --git a/shell/s.cpp b/shell/s.cpp index 622b448..7ef587b 100644 --- a/shell/s.cpp +++ b/shell/s.cpp @@ -4,7 +4,6 @@ #include "errors.h" #include "theme.h" -#include #include #include