fix my damn protocol for testing builds
I consistently checked that commits built by stashing all other changes... but forgot to stash untracked files.
This commit is contained in:
parent
12d41ac823
commit
e52b8411b3
|
@ -0,0 +1,178 @@
|
|||
//---------------------------------------------------------------------------//
|
||||
// 1100101 |_ mov #0, r4 __ //
|
||||
// 11 |_ <0xb380 %5c4> / _|_ _____ ___ //
|
||||
// 0110 |_ 3.50 -> 3.60 | _\ \ / _ (_-< //
|
||||
// |_ base# + offset |_| /_\_\___/__/ //
|
||||
//---------------------------------------------------------------------------//
|
||||
// fxos/binary: Main object for working with programs
|
||||
//
|
||||
// This header defines the main structures that combine to form the Binary
|
||||
// object, which is the main access point for analyzing a program. The Binary
|
||||
// structure references a VirtualSpace which emulates memory and can be used to
|
||||
// read raw data. It then lists every Variable and Function that has been
|
||||
// marked out in the program, either manually or by an analysis.
|
||||
//---
|
||||
|
||||
#ifndef FXOS_BINARY_H
|
||||
#define FXOS_BINARY_H
|
||||
|
||||
#include <fxos/util/types.h>
|
||||
#include <fxos/util/bson.h>
|
||||
// #include <fxos/vspace.h>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace FxOS {
|
||||
|
||||
class VirtualSpace;
|
||||
struct Mark;
|
||||
struct Variable;
|
||||
struct Function;
|
||||
|
||||
struct Binary
|
||||
{
|
||||
Binary(VirtualSpace &vpsace);
|
||||
|
||||
// TODO: Constructors to load project files into a binary
|
||||
|
||||
VirtualSpace &vspace()
|
||||
{
|
||||
return m_vspace;
|
||||
}
|
||||
VirtualSpace const &vspace() const
|
||||
{
|
||||
return m_vspace;
|
||||
}
|
||||
|
||||
// TODO: OS analysis in a binary
|
||||
// TODO: Platform information in a binary
|
||||
|
||||
private:
|
||||
VirtualSpace &m_vspace;
|
||||
};
|
||||
|
||||
/* Base structure for all /binary objets/, ie. program objects that can be
|
||||
declared in the program space. */
|
||||
struct BinaryObject
|
||||
{
|
||||
enum Type : u8 { Mark, Variable, Function };
|
||||
|
||||
BinaryObject(Binary &binary, Type type, u32 address, u32 size):
|
||||
m_binary {binary}, m_address {address}, m_size {size}, m_type {type}
|
||||
{
|
||||
}
|
||||
|
||||
/* Location and size in the address space. */
|
||||
u32 address() const
|
||||
{
|
||||
return m_address;
|
||||
}
|
||||
u32 size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
void setSize(u32 size)
|
||||
{
|
||||
m_size = size;
|
||||
}
|
||||
|
||||
/* Binary that owns the object. */
|
||||
Binary &parentBinary()
|
||||
{
|
||||
return m_binary;
|
||||
}
|
||||
Binary const &parentBinary() const
|
||||
{
|
||||
return m_binary;
|
||||
}
|
||||
|
||||
/* Symbol name, no requirements on uniqueness or character set. */
|
||||
std::string const &name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
void setName(std::string const &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
/* User comment. */
|
||||
std::string const &comment() const
|
||||
{
|
||||
return m_comment;
|
||||
}
|
||||
void setComment(std::string const &comment)
|
||||
{
|
||||
m_comment = comment;
|
||||
}
|
||||
|
||||
/* Check for a non-empty intersection between two objects. */
|
||||
bool intersects(BinaryObject const &other) const;
|
||||
|
||||
/* Check whether this object contains another object. */
|
||||
bool contains(BinaryObject const &other) const;
|
||||
|
||||
/* User-readable string representation: "object <name> at <addr>" */
|
||||
std::string str() const;
|
||||
|
||||
// TODO: BinaryObject serialization
|
||||
|
||||
/* Polymorphic accessors */
|
||||
bool isMark() const
|
||||
{
|
||||
return m_type == Type::Mark;
|
||||
}
|
||||
bool isVariable() const
|
||||
{
|
||||
return m_type == Type::Variable;
|
||||
}
|
||||
bool isFunction() const
|
||||
{
|
||||
return m_type == Type::Function;
|
||||
}
|
||||
FxOS::Mark &getMark() const
|
||||
{
|
||||
assert(isMark() && "wrong BinaryObject accessor: not a Mark");
|
||||
return *(FxOS::Mark *)this;
|
||||
}
|
||||
FxOS::Variable &getVariable() const
|
||||
{
|
||||
assert(isVariable() && "wrong BinaryObject accessor: not a Variable");
|
||||
return *(FxOS::Variable *)this;
|
||||
}
|
||||
FxOS::Function &getFunction() const
|
||||
{
|
||||
assert(isFunction() && "wrong BinaryObject accessor: not a Function");
|
||||
return *(FxOS::Function *)this;
|
||||
}
|
||||
|
||||
private:
|
||||
Binary &m_binary;
|
||||
u32 m_address;
|
||||
u32 m_size;
|
||||
Type const m_type;
|
||||
|
||||
std::string m_name;
|
||||
/* TODO: BinaryObject: don't reserve 32 bytes for empty comments */
|
||||
std::string m_comment;
|
||||
};
|
||||
|
||||
/* Basic, unattributed binary object used to mark out regions of code (eg.
|
||||
"kernel", "timer driver", "LINK app", "zero", "interrupt handlers"...). May
|
||||
alias with other binary objects. */
|
||||
struct Mark: public BinaryObject
|
||||
{
|
||||
// TODO: Tags/colors in marks
|
||||
|
||||
// TODO: BinaryObject serialization
|
||||
};
|
||||
|
||||
/* Binary object representing a non-empty piece of data. */
|
||||
struct Variable: public BinaryObject
|
||||
{
|
||||
// TODO: Variable types
|
||||
};
|
||||
|
||||
} /* namespace FxOS */
|
||||
|
||||
#endif /* FXOS_BINARY_H */
|
|
@ -0,0 +1,26 @@
|
|||
//---------------------------------------------------------------------------//
|
||||
// 1100101 |_ mov #0, r4 __ //
|
||||
// 11 |_ <0xb380 %5c4> / _|_ _____ ___ //
|
||||
// 0110 |_ 3.50 -> 3.60 | _\ \ / _ (_-< //
|
||||
// |_ base# + offset |_| /_\_\___/__/ //
|
||||
//---------------------------------------------------------------------------//
|
||||
// fxos/util/types: Common type definitions
|
||||
|
||||
#ifndef FXOS_UTIL_TYPES_H
|
||||
#define FXOS_UTIL_TYPES_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
/* Fixed-width integer types */
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
typedef int8_t i8;
|
||||
typedef int16_t i16;
|
||||
typedef int32_t i32;
|
||||
typedef int64_t i64;
|
||||
|
||||
#endif /* FXOS_UTIL_TYPES_H */
|
Loading…
Reference in New Issue