mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 23:13:34 +00:00
I wanted a tiny scriptable meltdown proof way to run userspace programs and visualize how program execution impacts memory. It helps to explain how things like Actually Portable Executable works. It can show you how the GCC generated code is going about manipulating matrices and more. I didn't feel fully comfortable with Qemu and Bochs because I'm not smart enough to understand them. I wanted something like gVisor but with much stronger levels of assurances. I wanted a single binary that'll run, on all major operating systems with an embedded GPL barrier ZIP filesystem that is tiny enough to transpile to JavaScript and run in browsers too. https://justine.storage.googleapis.com/emulator625.mp4
86 lines
1.9 KiB
C
86 lines
1.9 KiB
C
#ifndef COSMOPOLITAN_TOOL_BUILD_LIB_DIS_H_
|
|
#define COSMOPOLITAN_TOOL_BUILD_LIB_DIS_H_
|
|
#include "third_party/xed/x86.h"
|
|
#include "tool/build/lib/loader.h"
|
|
#include "tool/build/lib/machine.h"
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
COSMOPOLITAN_C_START_
|
|
|
|
struct Dis {
|
|
struct DisOps {
|
|
size_t i, n;
|
|
struct DisOp {
|
|
int64_t addr;
|
|
int unique;
|
|
int size;
|
|
bool active;
|
|
char *s;
|
|
} * p;
|
|
} ops;
|
|
struct DisLoads {
|
|
size_t i, n;
|
|
struct DisLoad {
|
|
int64_t addr;
|
|
uint64_t size;
|
|
bool istext;
|
|
} * p;
|
|
} loads;
|
|
struct DisSyms {
|
|
size_t i, n;
|
|
struct DisSym {
|
|
int64_t addr;
|
|
int rank;
|
|
int unique;
|
|
int size;
|
|
int name;
|
|
bool iscode;
|
|
bool isabs;
|
|
} * p;
|
|
const char *stab;
|
|
} syms;
|
|
struct DisEdges {
|
|
size_t i, n;
|
|
struct DisEdge {
|
|
int64_t src;
|
|
int64_t dst;
|
|
} * p;
|
|
} edges;
|
|
struct XedDecodedInst xedd[1];
|
|
uint8_t raw[512];
|
|
char buf[512];
|
|
};
|
|
|
|
struct DisBuilder {
|
|
struct Dis *dis;
|
|
struct XedDecodedInst *xedd;
|
|
int64_t addr;
|
|
};
|
|
|
|
struct DisHigh {
|
|
uint8_t keyword;
|
|
uint8_t reg;
|
|
uint8_t literal;
|
|
uint8_t label;
|
|
uint8_t comment;
|
|
};
|
|
|
|
extern struct DisHigh *g_dis_high;
|
|
|
|
long DisFind(struct Dis *, int64_t);
|
|
void Dis(struct Dis *, struct Machine *, int64_t);
|
|
void DisFree(struct Dis *);
|
|
void DisFreeOp(struct DisOp *);
|
|
void DisFreeOps(struct DisOps *);
|
|
void DisLoadElf(struct Dis *, struct Elf *);
|
|
long DisFindSym(struct Dis *, int64_t);
|
|
long DisFindSymByName(struct Dis *, const char *);
|
|
bool DisIsText(struct Dis *, int64_t);
|
|
bool DisIsProg(struct Dis *, int64_t);
|
|
const char *DisSpec(struct XedDecodedInst *, char *);
|
|
char *DisInst(struct DisBuilder, char *, const char *);
|
|
char *DisArg(struct DisBuilder, char *, const char *);
|
|
char *DisHigh(char *, int);
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_TOOL_BUILD_LIB_DIS_H_ */
|