mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Initial import
This commit is contained in:
commit
c91b3c5006
14915 changed files with 590219 additions and 0 deletions
57
tool/decode/lib/asmcodegen.c
Normal file
57
tool/decode/lib/asmcodegen.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "tool/decode/lib/asmcodegen.h"
|
||||
|
||||
char b1[BUFSIZ];
|
||||
char b2[BUFSIZ];
|
||||
|
||||
char *format(char *buf, const char *fmt, ...) {
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
vsnprintf(buf, BUFSIZ, fmt, va);
|
||||
va_end(va);
|
||||
return buf;
|
||||
}
|
||||
|
||||
nodiscard char *tabpad(const char *s, unsigned width) {
|
||||
char *p;
|
||||
size_t i, l, need;
|
||||
l = strlen(s);
|
||||
need = width > l ? (roundup(width, 8) - l - 1) / 8 + 1 : 0;
|
||||
p = memcpy(malloc(l + need + 1), s, l);
|
||||
for (i = 0; i < need; ++i) p[l + i] = '\t';
|
||||
p[l + need] = '\0';
|
||||
return p;
|
||||
}
|
||||
|
||||
void show(const char *directive, const char *value, const char *comment) {
|
||||
if (comment) {
|
||||
printf("\t%s\t%s# %s\n", directive, gc(tabpad(value, COLUMN_WIDTH)),
|
||||
comment);
|
||||
} else {
|
||||
printf("\t%s\t%s\n", directive, gc(tabpad(value, COLUMN_WIDTH)));
|
||||
}
|
||||
}
|
27
tool/decode/lib/asmcodegen.h
Normal file
27
tool/decode/lib/asmcodegen.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_ASMCODEGEN_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_ASMCODEGEN_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define COLUMN_WIDTH 24
|
||||
|
||||
#define showint(x) show(".long", format(b1, "%d", x), #x)
|
||||
#define showint64(x) show(".quad", format(b1, "%ld", x), #x)
|
||||
#define showbyte(x) show(".byte", format(b1, "%hhn", x), #x)
|
||||
#define showshort(x) show(".short", format(b1, "%hn", x), #x)
|
||||
#define showshorthex(x) show(".short", format(b1, "%#-6hX", x), #x)
|
||||
#define showinthex(x) show(".long", format(b1, "%#X", x), #x)
|
||||
#define showint64hex(x) show(".quad", format(b1, "%#lX", x), #x)
|
||||
#define showorg(x) show(".org", format(b1, "%#lX", x), #x)
|
||||
|
||||
extern char b1[BUFSIZ];
|
||||
extern char b2[BUFSIZ];
|
||||
|
||||
char *format(char *buf, const char *fmt, ...);
|
||||
nodiscard char *tabpad(const char *s, unsigned width);
|
||||
void show(const char *directive, const char *value, const char *comment);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_ASMCODEGEN_H_ */
|
76
tool/decode/lib/bitabuilder.c
Normal file
76
tool/decode/lib/bitabuilder.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "tool/decode/lib/bitabuilder.h"
|
||||
|
||||
/**
|
||||
* @fileoverview Sparse bit array builder.
|
||||
*/
|
||||
|
||||
struct BitaBuilder {
|
||||
size_t i, n;
|
||||
unsigned *p;
|
||||
};
|
||||
|
||||
struct BitaBuilder *bitabuilder_new(void) {
|
||||
return calloc(1, sizeof(struct BitaBuilder));
|
||||
}
|
||||
|
||||
void bitabuilder_free(struct BitaBuilder **bbpp) {
|
||||
if (*bbpp) {
|
||||
free_s(&(*bbpp)->p);
|
||||
free_s(bbpp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets bit.
|
||||
*
|
||||
* @return false if out of memory
|
||||
*/
|
||||
bool bitabuilder_setbit(struct BitaBuilder *bb, size_t bit) {
|
||||
void *p2;
|
||||
size_t i, n;
|
||||
i = MAX(bb->i, ROUNDUP(bit / CHAR_BIT + 1, __BIGGEST_ALIGNMENT__));
|
||||
if (i > bb->n) {
|
||||
n = i + (i >> 2);
|
||||
if ((p2 = realloc(bb->p, n))) {
|
||||
memset((char *)p2 + bb->n, 0, n - bb->n);
|
||||
bb->n = n;
|
||||
bb->p = p2;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bb->i = i;
|
||||
bts(bb->p, bit);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bitabuilder_fwrite(const struct BitaBuilder *bb, FILE *f) {
|
||||
return fwrite(bb->p, bb->i, 1, f);
|
||||
}
|
15
tool/decode/lib/bitabuilder.h
Normal file
15
tool/decode/lib/bitabuilder.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_BITABUILDER_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_BITABUILDER_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct FILE;
|
||||
struct BitaBuilder;
|
||||
struct BitaBuilder *bitabuilder_new(void);
|
||||
bool bitabuilder_setbit(struct BitaBuilder *, size_t);
|
||||
bool bitabuilder_fwrite(const struct BitaBuilder *, struct FILE *);
|
||||
void bitabuilder_free(struct BitaBuilder **);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_BITABUILDER_H_ */
|
62
tool/decode/lib/decodelib.mk
Normal file
62
tool/decode/lib/decodelib.mk
Normal file
|
@ -0,0 +1,62 @@
|
|||
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
|
||||
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
|
||||
|
||||
PKGS += TOOL_DECODE_LIB
|
||||
|
||||
TOOL_DECODE_LIB_ARTIFACTS += TOOL_DECODE_LIB_A
|
||||
TOOL_DECODE_LIB = $(TOOL_DECODE_LIB_A_DEPS) $(TOOL_DECODE_LIB_A)
|
||||
TOOL_DECODE_LIB_A = o/$(MODE)/tool/decode/lib/decodelib.a
|
||||
TOOL_DECODE_LIB_A_FILES := $(wildcard tool/decode/lib/*)
|
||||
TOOL_DECODE_LIB_A_HDRS = $(filter %.h,$(TOOL_DECODE_LIB_A_FILES))
|
||||
TOOL_DECODE_LIB_A_SRCS_S = $(filter %.S,$(TOOL_DECODE_LIB_A_FILES))
|
||||
TOOL_DECODE_LIB_A_SRCS_C = $(filter %.c,$(TOOL_DECODE_LIB_A_FILES))
|
||||
TOOL_DECODE_LIB_A_CHECKS = $(TOOL_DECODE_LIB_A).pkg
|
||||
|
||||
TOOL_DECODE_LIB_A_SRCS = \
|
||||
$(TOOL_DECODE_LIB_A_SRCS_S) \
|
||||
$(TOOL_DECODE_LIB_A_SRCS_C)
|
||||
|
||||
TOOL_DECODE_LIB_A_OBJS = \
|
||||
$(TOOL_DECODE_LIB_A_SRCS:%=o/$(MODE)/%.zip.o) \
|
||||
$(TOOL_DECODE_LIB_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
||||
$(TOOL_DECODE_LIB_A_SRCS_C:%.c=o/$(MODE)/%.o)
|
||||
|
||||
TOOL_DECODE_LIB_A_DIRECTDEPS = \
|
||||
LIBC_FMT \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_STUBS \
|
||||
LIBC_STR \
|
||||
LIBC_STDIO \
|
||||
LIBC_SYSV \
|
||||
LIBC_UNICODE
|
||||
|
||||
TOOL_DECODE_LIB_A_DEPS := \
|
||||
$(call uniq,$(foreach x,$(TOOL_DECODE_LIB_A_DIRECTDEPS),$($(x))))
|
||||
|
||||
$(TOOL_DECODE_LIB_A): \
|
||||
tool/decode/lib/ \
|
||||
$(TOOL_DECODE_LIB_A).pkg \
|
||||
$(TOOL_DECODE_LIB_A_OBJS)
|
||||
|
||||
$(TOOL_DECODE_LIB_A).pkg: \
|
||||
$(TOOL_DECODE_LIB_A_OBJS) \
|
||||
$(foreach x,$(TOOL_DECODE_LIB_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
TOOL_DECODE_LIB_LIBS = $(foreach x,$(TOOL_DECODE_LIB_ARTIFACTS),$($(x)))
|
||||
TOOL_DECODE_LIB_SRCS = $(foreach x,$(TOOL_DECODE_LIB_ARTIFACTS),$($(x)_SRCS))
|
||||
TOOL_DECODE_LIB_HDRS = $(foreach x,$(TOOL_DECODE_LIB_ARTIFACTS),$($(x)_HDRS))
|
||||
TOOL_DECODE_LIB_BINS = $(foreach x,$(TOOL_DECODE_LIB_ARTIFACTS),$($(x)_BINS))
|
||||
TOOL_DECODE_LIB_CHECKS = $(foreach x,$(TOOL_DECODE_LIB_ARTIFACTS),$($(x)_CHECKS))
|
||||
TOOL_DECODE_LIB_OBJS = $(foreach x,$(TOOL_DECODE_LIB_ARTIFACTS),$($(x)_OBJS))
|
||||
TOOL_DECODE_LIB_TESTS = $(foreach x,$(TOOL_DECODE_LIB_ARTIFACTS),$($(x)_TESTS))
|
||||
|
||||
o/$(MODE)/tool/decode/lib/elfidnames.o \
|
||||
o/$(MODE)/tool/decode/lib/machoidnames.o \
|
||||
o/$(MODE)/tool/decode/lib/peidnames.o: \
|
||||
DEFAULT_CFLAGS += \
|
||||
-fdata-sections
|
||||
|
||||
.PHONY: o/$(MODE)/tool/decode/lib
|
||||
o/$(MODE)/tool/decode/lib: $(TOOL_DECODE_LIB_CHECKS)
|
60
tool/decode/lib/disassemblehex.c
Normal file
60
tool/decode/lib/disassemblehex.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "tool/decode/lib/disassemblehex.h"
|
||||
|
||||
static size_t countzeroes(const uint8_t *data, size_t size) {
|
||||
size_t i;
|
||||
for (i = 0; i < size; ++i) {
|
||||
if (data[i] != '\0') break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void disassemblehex(uint8_t *data, size_t size, FILE *f) {
|
||||
int col;
|
||||
uint8_t ch;
|
||||
size_t i, z;
|
||||
char16_t glyphs[kDisassembleHexColumns + 1];
|
||||
col = 0;
|
||||
for (i = 0; i < size; ++i) {
|
||||
ch = data[i];
|
||||
if (!col) {
|
||||
z = countzeroes(&data[i], size - i) / kDisassembleHexColumns;
|
||||
if (z > 2) {
|
||||
fprintf(f, "\t.%s\t%zu*%d\n", "zero", z, kDisassembleHexColumns);
|
||||
i += z * kDisassembleHexColumns;
|
||||
if (i == size) break;
|
||||
}
|
||||
fprintf(f, "\t.%s\t", "byte");
|
||||
memset(glyphs, 0, sizeof(glyphs));
|
||||
}
|
||||
/* TODO(jart): Fix Emacs */
|
||||
glyphs[col] = kCp437[ch == '"' || ch == '\\' || ch == '#' ? '.' : ch];
|
||||
if (col) fputc(',', f);
|
||||
fprintf(f, "0x%02x", ch);
|
||||
if (++col == kDisassembleHexColumns) {
|
||||
col = 0;
|
||||
fprintf(f, "\t#%hs\n", glyphs);
|
||||
}
|
||||
}
|
||||
if (col) fputc('\n', f);
|
||||
}
|
13
tool/decode/lib/disassemblehex.h
Normal file
13
tool/decode/lib/disassemblehex.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_DISASSEMBLEHEX_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_DISASSEMBLEHEX_H_
|
||||
|
||||
#define kDisassembleHexColumns 8
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void disassemblehex(uint8_t *data, size_t size, FILE *f);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_DISASSEMBLEHEX_H_ */
|
264
tool/decode/lib/elfidnames.c
Normal file
264
tool/decode/lib/elfidnames.c
Normal file
|
@ -0,0 +1,264 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/elf/elf.h"
|
||||
#include "tool/decode/lib/elfidnames.h"
|
||||
|
||||
const struct IdName kElfTypeNames[] = {
|
||||
{ET_NONE, "ET_NONE"},
|
||||
{ET_REL, "ET_REL"},
|
||||
{ET_EXEC, "ET_EXEC"},
|
||||
{ET_DYN, "ET_DYN"},
|
||||
{ET_CORE, "ET_CORE"},
|
||||
{ET_NUM, "ET_NUM"},
|
||||
{ET_LOOS, "ET_LOOS"},
|
||||
{ET_HIOS, "ET_HIOS"},
|
||||
{ET_LOPROC, "ET_LOPROC"},
|
||||
{ET_HIPROC, "ET_HIPROC"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfOsabiNames[] = {
|
||||
{ELFOSABI_NONE, "ELFOSABI_NONE"},
|
||||
{ELFOSABI_SYSV, "ELFOSABI_SYSV"},
|
||||
{ELFOSABI_HPUX, "ELFOSABI_HPUX"},
|
||||
{ELFOSABI_NETBSD, "ELFOSABI_NETBSD"},
|
||||
{ELFOSABI_GNU, "ELFOSABI_GNU"},
|
||||
{ELFOSABI_LINUX, "ELFOSABI_LINUX"},
|
||||
{ELFOSABI_SOLARIS, "ELFOSABI_SOLARIS"},
|
||||
{ELFOSABI_AIX, "ELFOSABI_AIX"},
|
||||
{ELFOSABI_IRIX, "ELFOSABI_IRIX"},
|
||||
{ELFOSABI_FREEBSD, "ELFOSABI_FREEBSD"},
|
||||
{ELFOSABI_TRU64, "ELFOSABI_TRU64"},
|
||||
{ELFOSABI_MODESTO, "ELFOSABI_MODESTO"},
|
||||
{ELFOSABI_OPENBSD, "ELFOSABI_OPENBSD"},
|
||||
{ELFOSABI_ARM, "ELFOSABI_ARM"},
|
||||
{ELFOSABI_STANDALONE, "ELFOSABI_STANDALONE"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfClassNames[] = {
|
||||
{ELFCLASSNONE, "ELFCLASSNONE"},
|
||||
{ELFCLASS32, "ELFCLASS32"},
|
||||
{ELFCLASS64, "ELFCLASS64"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfDataNames[] = {
|
||||
{ELFDATANONE, "ELFDATANONE"},
|
||||
{ELFDATA2LSB, "ELFDATA2LSB"},
|
||||
{ELFDATA2MSB, "ELFDATA2MSB"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfMachineNames[] = {
|
||||
{EM_M32, "EM_M32"},
|
||||
{EM_386, "EM_386"},
|
||||
{EM_S390, "EM_S390"},
|
||||
{EM_ARM, "EM_ARM"},
|
||||
{EM_NEXGEN32E, "EM_NEXGEN32E"},
|
||||
{EM_PDP11, "EM_PDP11"},
|
||||
{EM_CRAYNV2, "EM_CRAYNV2"},
|
||||
{EM_L10M, "EM_L10M"},
|
||||
{EM_K10M, "EM_K10M"},
|
||||
{EM_AARCH64, "EM_AARCH64"},
|
||||
{EM_CUDA, "EM_CUDA"},
|
||||
{EM_Z80, "EM_Z80"},
|
||||
{EM_RISCV, "EM_RISCV"},
|
||||
{EM_BPF, "EM_BPF"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfSegmentTypeNames[] = {
|
||||
{PT_NULL, "PT_NULL"}, /* Program header table entry unused */
|
||||
{PT_LOAD, "PT_LOAD"}, /* Loadable program segment */
|
||||
{PT_DYNAMIC, "PT_DYNAMIC"}, /* Dynamic linking information */
|
||||
{PT_INTERP, "PT_INTERP"}, /* Program interpreter */
|
||||
{PT_NOTE, "PT_NOTE"}, /* Auxiliary information */
|
||||
{PT_SHLIB, "PT_SHLIB"}, /* Reserved */
|
||||
{PT_PHDR, "PT_PHDR"}, /* Entry for header table itself */
|
||||
{PT_TLS, "PT_TLS"}, /* Thread-local storage segment */
|
||||
{PT_NUM, "PT_NUM"}, /* Number of defined types */
|
||||
{PT_LOOS, "PT_LOOS"}, /* Start of OS-specific */
|
||||
{PT_GNU_EH_FRAME, "PT_GNU_EH_FRAME"}, /* GCC .eh_frame_hdr segment */
|
||||
{PT_GNU_STACK, "PT_GNU_STACK"}, /* Indicates stack executability */
|
||||
{PT_GNU_RELRO, "PT_GNU_RELRO"}, /* Read-only after relocation */
|
||||
{PT_LOSUNW, "PT_LOSUNW"}, /* <Reserved for Sun Micrososystems> */
|
||||
{PT_SUNWBSS, "PT_SUNWBSS"}, /* Sun Specific segment */
|
||||
{PT_SUNWSTACK, "PT_SUNWSTACK"}, /* Stack segment */
|
||||
{PT_HISUNW, "PT_HISUNW"}, /* </Reserved for Sun Micrososystems> */
|
||||
{PT_HIOS, "PT_HIOS"}, /* End of OS-specific */
|
||||
{PT_LOPROC, "PT_LOPROC"}, /* Start of processor-specific */
|
||||
{PT_HIPROC, "PT_HIPROC"}, /* End of processor-specific */
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfSectionTypeNames[] = {
|
||||
{SHT_NULL, "SHT_NULL"},
|
||||
{SHT_PROGBITS, "SHT_PROGBITS"},
|
||||
{SHT_SYMTAB, "SHT_SYMTAB"},
|
||||
{SHT_STRTAB, "SHT_STRTAB"},
|
||||
{SHT_RELA, "SHT_RELA"},
|
||||
{SHT_HASH, "SHT_HASH"},
|
||||
{SHT_DYNAMIC, "SHT_DYNAMIC"},
|
||||
{SHT_NOTE, "SHT_NOTE"},
|
||||
{SHT_NOBITS, "SHT_NOBITS"},
|
||||
{SHT_REL, "SHT_REL"},
|
||||
{SHT_SHLIB, "SHT_SHLIB"},
|
||||
{SHT_DYNSYM, "SHT_DYNSYM"},
|
||||
{SHT_INIT_ARRAY, "SHT_INIT_ARRAY"},
|
||||
{SHT_FINI_ARRAY, "SHT_FINI_ARRAY"},
|
||||
{SHT_PREINIT_ARRAY, "SHT_PREINIT_ARRAY"},
|
||||
{SHT_GROUP, "SHT_GROUP"},
|
||||
{SHT_SYMTAB_SHNDX, "SHT_SYMTAB_SHNDX"},
|
||||
{SHT_NUM, "SHT_NUM"},
|
||||
{SHT_LOOS, "SHT_LOOS"},
|
||||
{SHT_GNU_ATTRIBUTES, "SHT_GNU_ATTRIBUTES"},
|
||||
{SHT_GNU_HASH, "SHT_GNU_HASH"},
|
||||
{SHT_GNU_LIBLIST, "SHT_GNU_LIBLIST"},
|
||||
{SHT_CHECKSUM, "SHT_CHECKSUM"},
|
||||
{SHT_LOSUNW, "SHT_LOSUNW"},
|
||||
{SHT_SUNW_move, "SHT_SUNW_move"},
|
||||
{SHT_SUNW_COMDAT, "SHT_SUNW_COMDAT"},
|
||||
{SHT_SUNW_syminfo, "SHT_SUNW_syminfo"},
|
||||
{SHT_GNU_verdef, "SHT_GNU_verdef"},
|
||||
{SHT_GNU_verneed, "SHT_GNU_verneed"},
|
||||
{SHT_GNU_versym, "SHT_GNU_versym"},
|
||||
{SHT_HISUNW, "SHT_HISUNW"},
|
||||
{SHT_HIOS, "SHT_HIOS"},
|
||||
{SHT_LOPROC, "SHT_LOPROC"},
|
||||
{SHT_HIPROC, "SHT_HIPROC"},
|
||||
{SHT_LOUSER, "SHT_LOUSER"},
|
||||
{SHT_HIUSER, "SHT_HIUSER"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfSegmentFlagNames[] = {
|
||||
{PF_X, "PF_X"},
|
||||
{PF_W, "PF_W"},
|
||||
{PF_R, "PF_R"},
|
||||
{PF_MASKOS, "PF_MASKOS"},
|
||||
{PF_MASKPROC, "PF_MASKPROC"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfSectionFlagNames[] = {
|
||||
{SHF_WRITE, "SHF_WRITE"},
|
||||
{SHF_ALLOC, "SHF_ALLOC"},
|
||||
{SHF_EXECINSTR, "SHF_EXECINSTR"},
|
||||
{SHF_MERGE, "SHF_MERGE"},
|
||||
{SHF_STRINGS, "SHF_STRINGS"},
|
||||
{SHF_INFO_LINK, "SHF_INFO_LINK"},
|
||||
{SHF_LINK_ORDER, "SHF_LINK_ORDER"},
|
||||
{SHF_OS_NONCONFORMING, "SHF_OS_NONCONFORMING"},
|
||||
{SHF_GROUP, "SHF_GROUP"},
|
||||
{SHF_TLS, "SHF_TLS"},
|
||||
{SHF_COMPRESSED, "SHF_COMPRESSED"},
|
||||
{SHF_MASKOS, "SHF_MASKOS"},
|
||||
{SHF_MASKPROC, "SHF_MASKPROC"},
|
||||
{SHF_ORDERED, "SHF_ORDERED"},
|
||||
{SHF_EXCLUDE, "SHF_EXCLUDE"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfSymbolTypeNames[] = {
|
||||
{STT_NOTYPE, "STT_NOTYPE"}, {STT_OBJECT, "STT_OBJECT"},
|
||||
{STT_FUNC, "STT_FUNC"}, {STT_SECTION, "STT_SECTION"},
|
||||
{STT_FILE, "STT_FILE"}, {STT_COMMON, "STT_COMMON"},
|
||||
{STT_TLS, "STT_TLS"}, {STT_NUM, "STT_NUM"},
|
||||
{STT_LOOS, "STT_LOOS"}, {STT_GNU_IFUNC, "STT_GNU_IFUNC"},
|
||||
{STT_HIOS, "STT_HIOS"}, {STT_LOPROC, "STT_LOPROC"},
|
||||
{STT_HIPROC, "STT_HIPROC"}, {0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfSymbolBindNames[] = {
|
||||
{STB_LOCAL, "STB_LOCAL"}, {STB_GLOBAL, "STB_GLOBAL"},
|
||||
{STB_WEAK, "STB_WEAK"}, {STB_NUM, "STB_NUM"},
|
||||
{STB_LOOS, "STB_LOOS"}, {STB_GNU_UNIQUE, "STB_GNU_UNIQUE"},
|
||||
{STB_HIOS, "STB_HIOS"}, {STB_LOPROC, "STB_LOPROC"},
|
||||
{STB_HIPROC, "STB_HIPROC"}, {0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfSymbolVisibilityNames[] = {
|
||||
{STV_DEFAULT, "STV_DEFAULT"},
|
||||
{STV_INTERNAL, "STV_INTERNAL"},
|
||||
{STV_HIDDEN, "STV_HIDDEN"},
|
||||
{STV_PROTECTED, "STV_PROTECTED"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfSpecialSectionNames[] = {
|
||||
{SHN_UNDEF, "SHN_UNDEF"},
|
||||
{SHN_LORESERVE, "SHN_LORESERVE"},
|
||||
{SHN_LOPROC, "SHN_LOPROC"},
|
||||
{SHN_BEFORE, "SHN_BEFORE"},
|
||||
{SHN_AFTER, "SHN_AFTER"},
|
||||
{SHN_HIPROC, "SHN_HIPROC"},
|
||||
{SHN_LOOS, "SHN_LOOS"},
|
||||
{SHN_HIOS, "SHN_HIOS"},
|
||||
{SHN_ABS, "SHN_ABS"},
|
||||
{SHN_COMMON, "SHN_COMMON"},
|
||||
{SHN_XINDEX, "SHN_XINDEX"},
|
||||
{SHN_HIRESERVE, "SHN_HIRESERVE"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kElfNexgen32eRelocationNames[] = {
|
||||
{R_X86_64_64, "64"},
|
||||
{R_X86_64_PC32, "PC32"},
|
||||
{R_X86_64_GOT32, "GOT32"},
|
||||
{R_X86_64_PLT32, "PLT32"},
|
||||
{R_X86_64_COPY, "COPY"},
|
||||
{R_X86_64_GLOB_DAT, "GLOB_DAT"},
|
||||
{R_X86_64_JUMP_SLOT, "JUMP_SLOT"},
|
||||
{R_X86_64_RELATIVE, "RELATIVE"},
|
||||
{R_X86_64_GOTPCREL, "GOTPCREL"},
|
||||
{R_X86_64_32, "32"},
|
||||
{R_X86_64_32S, "32S"},
|
||||
{R_X86_64_16, "16"},
|
||||
{R_X86_64_PC16, "PC16"},
|
||||
{R_X86_64_8, "8"},
|
||||
{R_X86_64_PC8, "PC8"},
|
||||
{R_X86_64_DTPMOD64, "DTPMOD64"},
|
||||
{R_X86_64_DTPOFF64, "DTPOFF64"},
|
||||
{R_X86_64_TPOFF64, "TPOFF64"},
|
||||
{R_X86_64_TLSGD, "TLSGD"},
|
||||
{R_X86_64_TLSLD, "TLSLD"},
|
||||
{R_X86_64_DTPOFF32, "DTPOFF32"},
|
||||
{R_X86_64_GOTTPOFF, "GOTTPOFF"},
|
||||
{R_X86_64_TPOFF32, "TPOFF32"},
|
||||
{R_X86_64_PC64, "PC64"},
|
||||
{R_X86_64_GOTOFF64, "GOTOFF64"},
|
||||
{R_X86_64_GOTPC32, "GOTPC32"},
|
||||
{R_X86_64_GOT64, "GOT64"},
|
||||
{R_X86_64_GOTPCREL64, "GOTPCREL64"},
|
||||
{R_X86_64_GOTPC64, "GOTPC64"},
|
||||
{R_X86_64_GOTPLT64, "GOTPLT64"},
|
||||
{R_X86_64_PLTOFF64, "PLTOFF64"},
|
||||
{R_X86_64_SIZE32, "SIZE32"},
|
||||
{R_X86_64_SIZE64, "SIZE64"},
|
||||
{R_X86_64_GOTPC32_TLSDESC, "GOTPC32_TLSDESC"},
|
||||
{R_X86_64_TLSDESC_CALL, "TLSDESC_CALL"},
|
||||
{R_X86_64_TLSDESC, "TLSDESC"},
|
||||
{R_X86_64_IRELATIVE, "IRELATIVE"},
|
||||
{R_X86_64_RELATIVE64, "RELATIVE64"},
|
||||
{R_X86_64_GOTPCRELX, "GOTPCRELX"},
|
||||
{R_X86_64_REX_GOTPCRELX, "REX_GOTPCRELX"},
|
||||
{0, 0},
|
||||
};
|
24
tool/decode/lib/elfidnames.h
Normal file
24
tool/decode/lib/elfidnames.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_ELFIDNAMES_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_ELFIDNAMES_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern const struct IdName kElfTypeNames[];
|
||||
extern const struct IdName kElfOsabiNames[];
|
||||
extern const struct IdName kElfClassNames[];
|
||||
extern const struct IdName kElfDataNames[];
|
||||
extern const struct IdName kElfMachineNames[];
|
||||
extern const struct IdName kElfSegmentTypeNames[];
|
||||
extern const struct IdName kElfSectionTypeNames[];
|
||||
extern const struct IdName kElfSegmentFlagNames[];
|
||||
extern const struct IdName kElfSectionFlagNames[];
|
||||
extern const struct IdName kElfSymbolTypeNames[];
|
||||
extern const struct IdName kElfSymbolBindNames[];
|
||||
extern const struct IdName kElfSymbolVisibilityNames[];
|
||||
extern const struct IdName kElfSpecialSectionNames[];
|
||||
extern const struct IdName kElfNexgen32eRelocationNames[];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_ELFIDNAMES_H_ */
|
62
tool/decode/lib/flagger.c
Normal file
62
tool/decode/lib/flagger.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/alg/arraylist.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "tool/decode/lib/flagger.h"
|
||||
|
||||
struct FlagNameBuf {
|
||||
size_t i, n;
|
||||
char *p;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats numeric flags integer as symbolic code.
|
||||
*
|
||||
* @param names maps individual flags to string names in no order
|
||||
* @param id is the flags
|
||||
* @return NUL-terminated string that needs free()
|
||||
*/
|
||||
nodiscard char *recreateflags(const struct IdName *names, unsigned long id) {
|
||||
struct FlagNameBuf buf = {};
|
||||
char extrabuf[20];
|
||||
bool first;
|
||||
first = true;
|
||||
for (; names->name; names++) {
|
||||
if ((id == 0 && names->id == 0) ||
|
||||
(id != 0 && names->id != 0 && (id & names->id) == names->id)) {
|
||||
id &= ~names->id;
|
||||
if (!first) {
|
||||
append(&buf, "|");
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
concat(&buf, names->name, strlen(names->name));
|
||||
}
|
||||
}
|
||||
if (id) {
|
||||
if (buf.i) append(&buf, "|");
|
||||
concat(&buf, extrabuf, snprintf(extrabuf, sizeof(extrabuf), "%#x", id));
|
||||
} else if (!buf.i) {
|
||||
append(&buf, "0");
|
||||
}
|
||||
return buf.p;
|
||||
}
|
11
tool/decode/lib/flagger.h
Normal file
11
tool/decode/lib/flagger.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_FLAGGER_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_FLAGGER_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
char *recreateflags(const struct IdName *, unsigned long) nodiscard;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_FLAGGER_H_ */
|
29
tool/decode/lib/idname.c
Normal file
29
tool/decode/lib/idname.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "tool/decode/lib/idname.h"
|
||||
|
||||
const char *findnamebyid(const struct IdName *names, unsigned long id) {
|
||||
for (; names->name; names++) {
|
||||
if (names->id == id) {
|
||||
return names->name;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
15
tool/decode/lib/idname.h
Normal file
15
tool/decode/lib/idname.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_IDNAME_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_IDNAME_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct IdName {
|
||||
unsigned long id;
|
||||
const char *const name;
|
||||
};
|
||||
|
||||
const char *findnamebyid(const struct IdName *names, unsigned long id);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_IDNAME_H_ */
|
150
tool/decode/lib/machoidnames.c
Normal file
150
tool/decode/lib/machoidnames.c
Normal file
|
@ -0,0 +1,150 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macho.h"
|
||||
#include "tool/decode/lib/machoidnames.h"
|
||||
|
||||
const struct IdName kMachoFileTypeNames[] = {
|
||||
{MAC_OBJECT, "MAC_OBJECT"},
|
||||
{MAC_EXECUTE, "MAC_EXECUTE"},
|
||||
{MAC_FVMLIB, "MAC_FVMLIB"},
|
||||
{MAC_CORE, "MAC_CORE"},
|
||||
{MAC_PRELOAD, "MAC_PRELOAD"},
|
||||
{MAC_DYLIB, "MAC_DYLIB"},
|
||||
{MAC_DYLINKER, "MAC_DYLINKER"},
|
||||
{MAC_BUNDLE, "MAC_BUNDLE"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kMachoFlagNames[] = {
|
||||
{MAC_NOUNDEFS, "MAC_NOUNDEFS"},
|
||||
{MAC_INCRLINK, "MAC_INCRLINK"},
|
||||
{MAC_DYLDLINK, "MAC_DYLDLINK"},
|
||||
{MAC_BINDATLOAD, "MAC_BINDATLOAD"},
|
||||
{MAC_PREBOUND, "MAC_PREBOUND"},
|
||||
{MAC_SPLIT_SEGS, "MAC_SPLIT_SEGS"},
|
||||
{MAC_LAZY_INIT, "MAC_LAZY_INIT"},
|
||||
{MAC_TWOLEVEL, "MAC_TWOLEVEL"},
|
||||
{MAC_FORCE_FLAT, "MAC_FORCE_FLAT"},
|
||||
{MAC_NOMULTIDEFS, "MAC_NOMULTIDEFS"},
|
||||
{MAC_NOFIXPREBINDING, "MAC_NOFIXPREBINDING"},
|
||||
{MAC_PREBINDABLE, "MAC_PREBINDABLE"},
|
||||
{MAC_ALLMODSBOUND, "MAC_ALLMODSBOUND"},
|
||||
{MAC_SUBSECTIONS_VIA_SYMBOLS, "MAC_SUBSECTIONS_VIA_SYMBOLS"},
|
||||
{MAC_CANONICAL, "MAC_CANONICAL"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kMachoSegmentFlagNames[] = {
|
||||
{MAC_SG_HIGHVM, "MAC_SG_HIGHVM"},
|
||||
{MAC_SG_FVMLIB, "MAC_SG_FVMLIB"},
|
||||
{MAC_SG_NORELOC, "MAC_SG_NORELOC"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kMachoSectionTypeNames[] = {
|
||||
{MAC_S_REGULAR, "MAC_S_REGULAR"},
|
||||
{MAC_S_ZEROFILL, "MAC_S_ZEROFILL"},
|
||||
{MAC_S_CSTRING_LITERALS, "MAC_S_CSTRING_LITERALS"},
|
||||
{MAC_S_4BYTE_LITERALS, "MAC_S_4BYTE_LITERALS"},
|
||||
{MAC_S_8BYTE_LITERALS, "MAC_S_8BYTE_LITERALS"},
|
||||
{MAC_S_LITERAL_POINTERS, "MAC_S_LITERAL_POINTERS"},
|
||||
{MAC_S_NON_LAZY_SYMBOL_POINTERS, "MAC_S_NON_LAZY_SYMBOL_POINTERS"},
|
||||
{MAC_S_LAZY_SYMBOL_POINTERS, "MAC_S_LAZY_SYMBOL_POINTERS"},
|
||||
{MAC_S_SYMBOL_STUBS, "MAC_S_SYMBOL_STUBS"},
|
||||
{MAC_S_MOD_INIT_FUNC_POINTERS, "MAC_S_MOD_INIT_FUNC_POINTERS"},
|
||||
{MAC_S_MOD_TERM_FUNC_POINTERS, "MAC_S_MOD_TERM_FUNC_POINTERS"},
|
||||
{MAC_S_COALESCED, "MAC_S_COALESCED"},
|
||||
{MAC_S_GB_ZEROFILL, "MAC_S_GB_ZEROFILL"},
|
||||
{MAC_S_INTERPOSING, "MAC_S_INTERPOSING"},
|
||||
{MAC_S_16BYTE_LITERALS, "MAC_S_16BYTE_LITERALS"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kMachoSectionAttributeNames[] = {
|
||||
{MAC_SECTION_ATTRIBUTES_USR, "MAC_SECTION_ATTRIBUTES_USR"},
|
||||
{MAC_S_ATTR_PURE_INSTRUCTIONS, "MAC_S_ATTR_PURE_INSTRUCTIONS"},
|
||||
{MAC_S_ATTR_NO_TOC, "MAC_S_ATTR_NO_TOC"},
|
||||
{MAC_S_ATTR_STRIP_STATIC_SYMS, "MAC_S_ATTR_STRIP_STATIC_SYMS"},
|
||||
{MAC_S_ATTR_NO_DEAD_STRIP, "MAC_S_ATTR_NO_DEAD_STRIP"},
|
||||
{MAC_S_ATTR_LIVE_SUPPORT, "MAC_S_ATTR_LIVE_SUPPORT"},
|
||||
{MAC_S_ATTR_SELF_MODIFYING_CODE, "MAC_S_ATTR_SELF_MODIFYING_CODE"},
|
||||
{MAC_S_ATTR_DEBUG, "MAC_S_ATTR_DEBUG"},
|
||||
{MAC_SECTION_ATTRIBUTES_SYS, "MAC_SECTION_ATTRIBUTES_SYS"},
|
||||
{MAC_S_ATTR_SOME_INSTRUCTIONS, "MAC_S_ATTR_SOME_INSTRUCTIONS"},
|
||||
{MAC_S_ATTR_EXT_RELOC, "MAC_S_ATTR_EXT_RELOC"},
|
||||
{MAC_S_ATTR_LOC_RELOC, "MAC_S_ATTR_LOC_RELOC"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kMachoLoadCommandNames[] = {
|
||||
{MAC_LC_REQ_DYLD, "MAC_LC_REQ_DYLD"},
|
||||
{MAC_LC_SEGMENT, "MAC_LC_SEGMENT"},
|
||||
{MAC_LC_SYMTAB, "MAC_LC_SYMTAB"},
|
||||
{MAC_LC_SYMSEG, "MAC_LC_SYMSEG"},
|
||||
{MAC_LC_THREAD, "MAC_LC_THREAD"},
|
||||
{MAC_LC_UNIXTHREAD, "MAC_LC_UNIXTHREAD"},
|
||||
{MAC_LC_LOADFVMLIB, "MAC_LC_LOADFVMLIB"},
|
||||
{MAC_LC_IDFVMLIB, "MAC_LC_IDFVMLIB"},
|
||||
{MAC_LC_IDENT, "MAC_LC_IDENT"},
|
||||
{MAC_LC_FVMFILE, "MAC_LC_FVMFILE"},
|
||||
{MAC_LC_PREPAGE, "MAC_LC_PREPAGE"},
|
||||
{MAC_LC_DYSYMTAB, "MAC_LC_DYSYMTAB"},
|
||||
{MAC_LC_LOAD_DYLIB, "MAC_LC_LOAD_DYLIB"},
|
||||
{MAC_LC_ID_DYLIB, "MAC_LC_ID_DYLIB"},
|
||||
{MAC_LC_LOAD_DYLINKER, "MAC_LC_LOAD_DYLINKER"},
|
||||
{MAC_LC_ID_DYLINKER, "MAC_LC_ID_DYLINKER"},
|
||||
{MAC_LC_PREBOUND_DYLIB, "MAC_LC_PREBOUND_DYLIB"},
|
||||
{MAC_LC_ROUTINES, "MAC_LC_ROUTINES"},
|
||||
{MAC_LC_SUB_FRAMEWORK, "MAC_LC_SUB_FRAMEWORK"},
|
||||
{MAC_LC_SUB_UMBRELLA, "MAC_LC_SUB_UMBRELLA"},
|
||||
{MAC_LC_SUB_CLIENT, "MAC_LC_SUB_CLIENT"},
|
||||
{MAC_LC_SUB_LIBRARY, "MAC_LC_SUB_LIBRARY"},
|
||||
{MAC_LC_TWOLEVEL_HINTS, "MAC_LC_TWOLEVEL_HINTS"},
|
||||
{MAC_LC_PREBIND_CKSUM, "MAC_LC_PREBIND_CKSUM"},
|
||||
{MAC_LC_LOAD_WEAK_DYLIB, "MAC_LC_LOAD_WEAK_DYLIB"},
|
||||
{MAC_LC_SEGMENT_64, "MAC_LC_SEGMENT_64"},
|
||||
{MAC_LC_ROUTINES_64, "MAC_LC_ROUTINES_64"},
|
||||
{MAC_LC_UUID, "MAC_LC_UUID"},
|
||||
{MAC_LC_CODE_SIGNATURE, "MAC_LC_CODE_SIGNATURE"},
|
||||
{MAC_LC_SEGMENT_SPLIT_INFO, "MAC_LC_SEGMENT_SPLIT_INFO"},
|
||||
{MAC_LC_LAZY_LOAD_DYLIB, "MAC_LC_LAZY_LOAD_DYLIB"},
|
||||
{MAC_LC_ENCRYPTION_INFO, "MAC_LC_ENCRYPTION_INFO"},
|
||||
{MAC_LC_DYLD_INFO, "MAC_LC_DYLD_INFO"},
|
||||
{MAC_LC_VERSION_MIN_MACOSX, "MAC_LC_VERSION_MIN_MACOSX"},
|
||||
{MAC_LC_VERSION_MIN_IPHONEOS, "MAC_LC_VERSION_MIN_IPHONEOS"},
|
||||
{MAC_LC_FUNCTION_STARTS, "MAC_LC_FUNCTION_STARTS"},
|
||||
{MAC_LC_DYLD_ENVIRONMENT, "MAC_LC_DYLD_ENVIRONMENT"},
|
||||
{MAC_LC_DATA_IN_CODE, "MAC_LC_DATA_IN_CODE"},
|
||||
{MAC_LC_SOURCE_VERSION, "MAC_LC_SOURCE_VERSION"},
|
||||
{MAC_LC_RPATH, "MAC_LC_RPATH"},
|
||||
{MAC_LC_MAIN, "MAC_LC_MAIN"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kMachoVmProtNames[] = {
|
||||
{VM_PROT_READ, "VM_PROT_READ"},
|
||||
{VM_PROT_WRITE, "VM_PROT_WRITE"},
|
||||
{VM_PROT_EXECUTE, "VM_PROT_EXECUTE"},
|
||||
{VM_PROT_NO_CHANGE, "VM_PROT_NO_CHANGE"},
|
||||
{VM_PROT_COPY, "VM_PROT_COPY"},
|
||||
{VM_PROT_TRUSTED, "VM_PROT_TRUSTED"},
|
||||
{VM_PROT_STRIP_READ, "VM_PROT_STRIP_READ"},
|
||||
{0, 0},
|
||||
};
|
17
tool/decode/lib/machoidnames.h
Normal file
17
tool/decode/lib/machoidnames.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_MACHOIDNAMES_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_MACHOIDNAMES_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern const struct IdName kMachoFileTypeNames[];
|
||||
extern const struct IdName kMachoFlagNames[];
|
||||
extern const struct IdName kMachoSegmentFlagNames[];
|
||||
extern const struct IdName kMachoSectionTypeNames[];
|
||||
extern const struct IdName kMachoSectionAttributeNames[];
|
||||
extern const struct IdName kMachoLoadCommandNames[];
|
||||
extern const struct IdName kMachoVmProtNames[];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_MACHOIDNAMES_H_ */
|
51
tool/decode/lib/ntfileflagnames.c
Normal file
51
tool/decode/lib/ntfileflagnames.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "tool/decode/lib/ntfileflagnames.h"
|
||||
|
||||
const struct IdName kNtFileFlagNames[] = {
|
||||
{kNtFileAttributeReadonly, "kNtFileAttributeReadonly"},
|
||||
{kNtFileAttributeHidden, "kNtFileAttributeHidden"},
|
||||
{kNtFileAttributeSystem, "kNtFileAttributeSystem"},
|
||||
{kNtFileAttributeVolumelabel, "kNtFileAttributeVolumelabel"},
|
||||
{kNtFileAttributeDirectory, "kNtFileAttributeDirectory"},
|
||||
{kNtFileAttributeArchive, "kNtFileAttributeArchive"},
|
||||
{kNtFileAttributeDevice, "kNtFileAttributeDevice"},
|
||||
{kNtFileAttributeNormal, "kNtFileAttributeNormal"},
|
||||
{kNtFileAttributeTemporary, "kNtFileAttributeTemporary"},
|
||||
{kNtFileAttributeSparseFile, "kNtFileAttributeSparseFile"},
|
||||
{kNtFileAttributeReparsePoint, "kNtFileAttributeReparsePoint"},
|
||||
{kNtFileAttributeCompressed, "kNtFileAttributeCompressed"},
|
||||
{kNtFileAttributeOffline, "kNtFileAttributeOffline"},
|
||||
{kNtFileAttributeNotContentIndexed, "kNtFileAttributeNotContentIndexed"},
|
||||
{kNtFileAttributeEncrypted, "kNtFileAttributeEncrypted"},
|
||||
{kNtFileFlagWriteThrough, "kNtFileFlagWriteThrough"},
|
||||
{kNtFileFlagOverlapped, "kNtFileFlagOverlapped"},
|
||||
{kNtFileFlagNoBuffering, "kNtFileFlagNoBuffering"},
|
||||
{kNtFileFlagRandomAccess, "kNtFileFlagRandomAccess"},
|
||||
{kNtFileFlagSequentialScan, "kNtFileFlagSequentialScan"},
|
||||
{kNtFileFlagDeleteOnClose, "kNtFileFlagDeleteOnClose"},
|
||||
{kNtFileFlagBackupSemantics, "kNtFileFlagBackupSemantics"},
|
||||
{kNtFileFlagPosixSemantics, "kNtFileFlagPosixSemantics"},
|
||||
{kNtFileFlagOpenReparsePoint, "kNtFileFlagOpenReparsePoint"},
|
||||
{kNtFileFlagOpenNoRecall, "kNtFileFlagOpenNoRecall"},
|
||||
{kNtFileFlagFirstPipeInstance, "kNtFileFlagFirstPipeInstance"},
|
||||
{0, 0},
|
||||
};
|
11
tool/decode/lib/ntfileflagnames.h
Normal file
11
tool/decode/lib/ntfileflagnames.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_NTFILEFLAGNAMES_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_NTFILEFLAGNAMES_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern const struct IdName kNtFileFlagNames[];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_NTFILEFLAGNAMES_H_ */
|
179
tool/decode/lib/peidnames.c
Normal file
179
tool/decode/lib/peidnames.c
Normal file
|
@ -0,0 +1,179 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/pe.h"
|
||||
#include "tool/decode/lib/peidnames.h"
|
||||
|
||||
const struct IdName kNtImageFileMachineNames[] = {
|
||||
{kNtImageFileMachineUnknown, "kNtImageFileMachineUnknown"},
|
||||
{kNtImageFileMachineTargetHost, "kNtImageFileMachineTargetHost"},
|
||||
{kNtImageFileMachineI386, "kNtImageFileMachineI386"},
|
||||
{kNtImageFileMachineR3000, "kNtImageFileMachineR3000"},
|
||||
{kNtImageFileMachineR4000, "kNtImageFileMachineR4000"},
|
||||
{kNtImageFileMachineR10000, "kNtImageFileMachineR10000"},
|
||||
{kNtImageFileMachineWcemipsv2, "kNtImageFileMachineWcemipsv2"},
|
||||
{kNtImageFileMachineAlpha, "kNtImageFileMachineAlpha"},
|
||||
{kNtImageFileMachineSh3, "kNtImageFileMachineSh3"},
|
||||
{kNtImageFileMachineSh3dsp, "kNtImageFileMachineSh3dsp"},
|
||||
{kNtImageFileMachineSh3e, "kNtImageFileMachineSh3e"},
|
||||
{kNtImageFileMachineSh4, "kNtImageFileMachineSh4"},
|
||||
{kNtImageFileMachineSh5, "kNtImageFileMachineSh5"},
|
||||
{kNtImageFileMachineArm, "kNtImageFileMachineArm"},
|
||||
{kNtImageFileMachineThumb, "kNtImageFileMachineThumb"},
|
||||
{kNtImageFileMachineArmnt, "kNtImageFileMachineArmnt"},
|
||||
{kNtImageFileMachineAm33, "kNtImageFileMachineAm33"},
|
||||
{kNtImageFileMachinePowerpc, "kNtImageFileMachinePowerpc"},
|
||||
{kNtImageFileMachinePowerpcfp, "kNtImageFileMachinePowerpcfp"},
|
||||
{kNtImageFileMachineIa64, "kNtImageFileMachineIa64"},
|
||||
{kNtImageFileMachineMips16, "kNtImageFileMachineMips16"},
|
||||
{kNtImageFileMachineAlpha64, "kNtImageFileMachineAlpha64"},
|
||||
{kNtImageFileMachineMipsfpu, "kNtImageFileMachineMipsfpu"},
|
||||
{kNtImageFileMachineMipsfpu16, "kNtImageFileMachineMipsfpu16"},
|
||||
{kNtImageFileMachineAxp64, "kNtImageFileMachineAxp64"},
|
||||
{kNtImageFileMachineTricore, "kNtImageFileMachineTricore"},
|
||||
{kNtImageFileMachineCef, "kNtImageFileMachineCef"},
|
||||
{kNtImageFileMachineEbc, "kNtImageFileMachineEbc"},
|
||||
{kNtImageFileMachineNexgen32e, "kNtImageFileMachineNexgen32e"},
|
||||
{kNtImageFileMachineM32r, "kNtImageFileMachineM32r"},
|
||||
{kNtImageFileMachineArm64, "kNtImageFileMachineArm64"},
|
||||
{kNtImageFileMachineCee, "kNtImageFileMachineCee"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kNtPeOptionalHeaderMagicNames[] = {
|
||||
{kNtPe32bit, "kNtPe32bit"},
|
||||
{kNtPe64bit, "kNtPe64bit"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kNtImageDllcharacteristicNames[] = {
|
||||
{kNtImageDllcharacteristicsHighEntropyVa,
|
||||
"kNtImageDllcharacteristicsHighEntropyVa"},
|
||||
{kNtImageDllcharacteristicsDynamicBase,
|
||||
"kNtImageDllcharacteristicsDynamicBase"},
|
||||
{kNtImageDllcharacteristicsForceIntegrity,
|
||||
"kNtImageDllcharacteristicsForceIntegrity"},
|
||||
{kNtImageDllcharacteristicsNxCompat, "kNtImageDllcharacteristicsNxCompat"},
|
||||
{kNtImageDllcharacteristicsNoIsolation,
|
||||
"kNtImageDllcharacteristicsNoIsolation"},
|
||||
{kNtImageDllcharacteristicsNoSeh, "kNtImageDllcharacteristicsNoSeh"},
|
||||
{kNtImageDllcharacteristicsNoBind, "kNtImageDllcharacteristicsNoBind"},
|
||||
{kNtImageDllcharacteristicsAppcontainer,
|
||||
"kNtImageDllcharacteristicsAppcontainer"},
|
||||
{kNtImageDllcharacteristicsWdmDriver,
|
||||
"kNtImageDllcharacteristicsWdmDriver"},
|
||||
{kNtImageDllcharacteristicsGuardCf, "kNtImageDllcharacteristicsGuardCf"},
|
||||
{kNtImageDllcharacteristicsTerminalServerAware,
|
||||
"kNtImageDllcharacteristicsTerminalServerAware"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kNtImageSubsystemNames[] = {
|
||||
{kNtImageSubsystemUnknown, "kNtImageSubsystemUnknown"},
|
||||
{kNtImageSubsystemNative, "kNtImageSubsystemNative"},
|
||||
{kNtImageSubsystemWindowsGui, "kNtImageSubsystemWindowsGui"},
|
||||
{kNtImageSubsystemWindowsCui, "kNtImageSubsystemWindowsCui"},
|
||||
{kNtImageSubsystemOs2Cui, "kNtImageSubsystemOs2Cui"},
|
||||
{kNtImageSubsystemPosixCui, "kNtImageSubsystemPosixCui"},
|
||||
{kNtImageSubsystemNativeWindows, "kNtImageSubsystemNativeWindows"},
|
||||
{kNtImageSubsystemWindowsCeGui, "kNtImageSubsystemWindowsCeGui"},
|
||||
{kNtImageSubsystemEfiApplication, "kNtImageSubsystemEfiApplication"},
|
||||
{kNtImageSubsystemEfiBootServiceDriver,
|
||||
"kNtImageSubsystemEfiBootServiceDriver"},
|
||||
{kNtImageSubsystemEfiRuntimeDriver, "kNtImageSubsystemEfiRuntimeDriver"},
|
||||
{kNtImageSubsystemEfiRom, "kNtImageSubsystemEfiRom"},
|
||||
{kNtImageSubsystemXbox, "kNtImageSubsystemXbox"},
|
||||
{kNtImageSubsystemWindowsBootApplication,
|
||||
"kNtImageSubsystemWindowsBootApplication"},
|
||||
{kNtImageSubsystemXboxCodeCatalog, "kNtImageSubsystemXboxCodeCatalog"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kNtImageScnNames[] = {
|
||||
{kNtImageScnTypeNoPad, "kNtImageScnTypeNoPad"},
|
||||
{kNtImageScnCntCode, "kNtImageScnCntCode"},
|
||||
{kNtImageScnCntInitializedData, "kNtImageScnCntInitializedData"},
|
||||
{kNtImageScnCntUninitializedData, "kNtImageScnCntUninitializedData"},
|
||||
{kNtImageScnLnkOther, "kNtImageScnLnkOther"},
|
||||
{kNtImageScnLnkInfo, "kNtImageScnLnkInfo"},
|
||||
{kNtImageScnLnkRemove, "kNtImageScnLnkRemove"},
|
||||
{kNtImageScnLnkComdat, "kNtImageScnLnkComdat"},
|
||||
{kNtImageScnNoDeferSpecExc, "kNtImageScnNoDeferSpecExc"},
|
||||
{kNtImageScnGprel, "kNtImageScnGprel"},
|
||||
{kNtImageScnMemFardata, "kNtImageScnMemFardata"},
|
||||
{kNtImageScnMemPurgeable, "kNtImageScnMemPurgeable"},
|
||||
{kNtImageScnMem16bit, "kNtImageScnMem16bit"},
|
||||
{kNtImageScnMemLocked, "kNtImageScnMemLocked"},
|
||||
{kNtImageScnMemPreload, "kNtImageScnMemPreload"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kNtImageDirectoryEntryNames[] = {
|
||||
{kNtImageDirectoryEntryExport, "kNtImageDirectoryEntryExport"},
|
||||
{kNtImageDirectoryEntryImport, "kNtImageDirectoryEntryImport"},
|
||||
{kNtImageDirectoryEntryResource, "kNtImageDirectoryEntryResource"},
|
||||
{kNtImageDirectoryEntryException, "kNtImageDirectoryEntryException"},
|
||||
{kNtImageDirectoryEntrySecurity, "kNtImageDirectoryEntrySecurity"},
|
||||
{kNtImageDirectoryEntryBasereloc, "kNtImageDirectoryEntryBasereloc"},
|
||||
{kNtImageDirectoryEntryDebug, "kNtImageDirectoryEntryDebug"},
|
||||
{kNtImageDirectoryEntryArchitecture, "kNtImageDirectoryEntryArchitecture"},
|
||||
{kNtImageDirectoryEntryGlobalptr, "kNtImageDirectoryEntryGlobalptr"},
|
||||
{kNtImageDirectoryEntryTls, "kNtImageDirectoryEntryTls"},
|
||||
{kNtImageDirectoryEntryLoadConfig, "kNtImageDirectoryEntryLoadConfig"},
|
||||
{kNtImageDirectoryEntryBoundImport, "kNtImageDirectoryEntryBoundImport"},
|
||||
{kNtImageDirectoryEntryIat, "kNtImageDirectoryEntryIat"},
|
||||
{kNtImageDirectoryEntryDelayImport, "kNtImageDirectoryEntryDelayImport"},
|
||||
{kNtImageDirectoryEntryComDescriptor,
|
||||
"kNtImageDirectoryEntryComDescriptor"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kNtImageCharacteristicNames[] = {
|
||||
{kNtImageFileRelocsStripped, "kNtImageFileRelocsStripped"},
|
||||
{kNtImageFileExecutableImage, "kNtImageFileExecutableImage"},
|
||||
{kNtImageFileLineNumsStripped, "kNtImageFileLineNumsStripped"},
|
||||
{kNtImageFileLocalSymsStripped, "kNtImageFileLocalSymsStripped"},
|
||||
{kNtImageFileAggresiveWsTrim, "kNtImageFileAggresiveWsTrim"},
|
||||
{kNtImageFileLargeAddressAware, "kNtImageFileLargeAddressAware"},
|
||||
{kNtImageFileBytesReversedLo, "kNtImageFileBytesReversedLo"},
|
||||
{kNtImageFile32bitMachine, "kNtImageFile32bitMachine"},
|
||||
{kNtImageFileDebugStripped, "kNtImageFileDebugStripped"},
|
||||
{kNtImageFileRemovableRunFromSwap, "kNtImageFileRemovableRunFromSwap"},
|
||||
{kNtImageFileNetRunFromSwap, "kNtImageFileNetRunFromSwap"},
|
||||
{kNtImageFileSystem, "kNtImageFileSystem"},
|
||||
{kNtImageFileDll, "kNtImageFileDll"},
|
||||
{kNtImageFileUpSystemOnly, "kNtImageFileUpSystemOnly"},
|
||||
{kNtImageFileBytesReversedHi, "kNtImageFileBytesReversedHi"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kNtPeSectionNames[] = {
|
||||
{kNtPeSectionCntCode, "kNtPeSectionCntCode"},
|
||||
{kNtPeSectionCntInitializedData, "kNtPeSectionCntInitializedData"},
|
||||
{kNtPeSectionCntUninitializedData, "kNtPeSectionCntUninitializedData"},
|
||||
{kNtPeSectionGprel, "kNtPeSectionGprel"},
|
||||
{kNtPeSectionMemDiscardable, "kNtPeSectionMemDiscardable"},
|
||||
{kNtPeSectionMemNotCached, "kNtPeSectionMemNotCached"},
|
||||
{kNtPeSectionMemNotPaged, "kNtPeSectionMemNotPaged"},
|
||||
{kNtPeSectionMemShared, "kNtPeSectionMemShared"},
|
||||
{kNtPeSectionMemExecute, "kNtPeSectionMemExecute"},
|
||||
{kNtPeSectionMemRead, "kNtPeSectionMemRead"},
|
||||
{kNtPeSectionMemWrite, "kNtPeSectionMemWrite"},
|
||||
{0, 0},
|
||||
};
|
18
tool/decode/lib/peidnames.h
Normal file
18
tool/decode/lib/peidnames.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_PEIDNAMES_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_PEIDNAMES_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern const struct IdName kNtImageFileMachineNames[];
|
||||
extern const struct IdName kNtPeOptionalHeaderMagicNames[];
|
||||
extern const struct IdName kNtImageCharacteristicNames[];
|
||||
extern const struct IdName kNtImageDllcharacteristicNames[];
|
||||
extern const struct IdName kNtImageSubsystemNames[];
|
||||
extern const struct IdName kNtImageScnNames[];
|
||||
extern const struct IdName kNtImageDirectoryEntryNames[];
|
||||
extern const struct IdName kNtPeSectionNames[];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_PEIDNAMES_H_ */
|
73
tool/decode/lib/pollnames.S
Normal file
73
tool/decode/lib/pollnames.S
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/relocations.h"
|
||||
#include "ape/relocations.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
.Lrows = 0 # w/ 2 cols
|
||||
|
||||
.macro .tab sym:req str
|
||||
.pushsection .rodata.str1.1,"aSM",@progbits,1
|
||||
.L\@: .asciz "\str"
|
||||
.popsection
|
||||
.long RVA(\sym)
|
||||
.long RVA(.L\@)
|
||||
.Lrows = .Lrows + 1
|
||||
.endm
|
||||
|
||||
.initro 301,_init_kPollNames
|
||||
kPollNamesRo:
|
||||
.tab POLLNVAL "POLLNVAL"
|
||||
.tab POLLWRNORM "POLLWRNORM"
|
||||
.tab POLLWRBAND "POLLWRBAND"
|
||||
.tab POLLRDNORM "POLLRDNORM"
|
||||
.tab POLLRDHUP "POLLRDHUP"
|
||||
.tab POLLRDBAND "POLLRDBAND"
|
||||
.tab POLLHUP "POLLHUP"
|
||||
.tab POLLERR "POLLERR"
|
||||
.tab POLLPRI "POLLPRI"
|
||||
.tab POLLOUT "POLLOUT"
|
||||
.tab POLLIN "POLLIN"
|
||||
.endobj kPollNamesRo,globl,hidden
|
||||
.previous
|
||||
|
||||
/ Mapping of poll() flags to their string names.
|
||||
/ @see recreateflags()
|
||||
.initbss 301,_init_kPollNames
|
||||
kPollNames:
|
||||
.rept .Lrows
|
||||
.quad 0 # unsigned long id
|
||||
.quad 0 # const char *const name
|
||||
.endr
|
||||
.quad 0,0 # terminator row
|
||||
.endobj kPollNames,globl
|
||||
.previous
|
||||
|
||||
.init.start 301,_init_kPollNames
|
||||
pushpop .Lrows,%rcx # relocate RO→BSS b/c -fPIE crap
|
||||
0: lodsl
|
||||
mov (%rbx,%rax),%rax # read what systemfive.S decoded
|
||||
stosq
|
||||
lodsl
|
||||
add %rbx,%rax # %rbx is image base (cosmo abi)
|
||||
stosq
|
||||
loop 0b
|
||||
add $16,%rdi
|
||||
.init.end 301,_init_kPollNames
|
11
tool/decode/lib/pollnames.h
Normal file
11
tool/decode/lib/pollnames.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_POLLNAMES_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_POLLNAMES_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern struct IdName kPollNames[];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_POLLNAMES_H_ */
|
55
tool/decode/lib/socknames.c
Normal file
55
tool/decode/lib/socknames.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dns/dns.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
#include "libc/sysv/consts/ai.h"
|
||||
#include "libc/sysv/consts/ipproto.h"
|
||||
#include "libc/sysv/consts/sock.h"
|
||||
#include "tool/decode/lib/socknames.h"
|
||||
|
||||
const struct IdName kAddressFamilyNames[] = {
|
||||
{AF_UNSPEC, "AF_UNSPEC"},
|
||||
{AF_UNIX, "AF_UNIX"},
|
||||
{AF_INET, "AF_INET"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kSockTypeNames[] = {
|
||||
{SOCK_STREAM, "SOCK_STREAM"},
|
||||
{SOCK_DGRAM, "SOCK_DGRAM"},
|
||||
{SOCK_RAW, "SOCK_RAW"},
|
||||
{SOCK_RDM, "SOCK_RDM"},
|
||||
{SOCK_SEQPACKET, "SOCK_SEQPACKET"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kAddrInfoFlagNames[] = {
|
||||
{AI_PASSIVE, "AI_PASSIVE"},
|
||||
{AI_CANONNAME, "AI_CANONNAME"},
|
||||
{AI_NUMERICHOST, "AI_NUMERICHOST"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kProtocolNames[] = {
|
||||
{IPPROTO_IP, "IPPROTO_IP"}, {IPPROTO_ICMP, "IPPROTO_ICMP"},
|
||||
{IPPROTO_TCP, "IPPROTO_TCP"}, {IPPROTO_UDP, "IPPROTO_UDP"},
|
||||
{IPPROTO_RAW, "IPPROTO_RAW"}, {0, 0},
|
||||
};
|
14
tool/decode/lib/socknames.h
Normal file
14
tool/decode/lib/socknames.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_SOCKNAMES_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_SOCKNAMES_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern const struct IdName kAddressFamilyNames[];
|
||||
extern const struct IdName kSockTypeNames[];
|
||||
extern const struct IdName kAddrInfoFlagNames[];
|
||||
extern const struct IdName kProtocolNames[];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_SOCKNAMES_H_ */
|
60
tool/decode/lib/titlegen.c
Normal file
60
tool/decode/lib/titlegen.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "tool/decode/lib/titlegen.h"
|
||||
|
||||
const struct Modeline kModelineAsm = {
|
||||
" mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 ",
|
||||
" set et ft=asm ts=8 sw=8 fenc=utf-8 "};
|
||||
|
||||
/**
|
||||
* Displays one of those ANSI block source dividers we love so much.
|
||||
*/
|
||||
void showtitle(const char *brand, const char *tool, const char *title,
|
||||
const char *description, const struct Modeline *modeline) {
|
||||
char buf[512], *p;
|
||||
p = stpcpy(buf, brand);
|
||||
if (tool) {
|
||||
p = stpcpy(stpcpy(p, " § "), tool);
|
||||
if (title) {
|
||||
p = stpcpy(stpcpy(p, " » "), title);
|
||||
}
|
||||
}
|
||||
printf("/*");
|
||||
if (modeline) {
|
||||
printf("-*-%-71s-*-│\n│vi:%-72s:vi│\n╞", modeline->emacs, modeline->vim);
|
||||
for (unsigned i = 0; i < 78; ++i) printf("═");
|
||||
printf("╡\n│ %-76s ", buf);
|
||||
} else {
|
||||
for (unsigned i = 0; i < 75; ++i) printf("─");
|
||||
printf("│─╗\n│ %-73s ─╬─", buf);
|
||||
}
|
||||
printf("│\n╚─");
|
||||
for (unsigned i = 0; i < 75; ++i) printf("─");
|
||||
printf("%s", modeline ? "─" : "│");
|
||||
if (description) {
|
||||
/* TODO(jart): paragraph fill */
|
||||
printf("─╝\n%s ", description);
|
||||
} else {
|
||||
}
|
||||
printf("*/\n");
|
||||
}
|
18
tool/decode/lib/titlegen.h
Normal file
18
tool/decode/lib/titlegen.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_TITLEGEN_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_TITLEGEN_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct Modeline {
|
||||
const char *emacs;
|
||||
const char *vim;
|
||||
};
|
||||
|
||||
extern const struct Modeline kModelineAsm;
|
||||
|
||||
void showtitle(const char *brand, const char *tool, const char *title,
|
||||
const char *description, const struct Modeline *modeline);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_TITLEGEN_H_ */
|
29
tool/decode/lib/x86gradenames.c
Normal file
29
tool/decode/lib/x86gradenames.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nexgen32e/x86info.h"
|
||||
#include "tool/decode/lib/x86idnames.h"
|
||||
|
||||
const struct IdName kX86GradeNames[] = {
|
||||
{X86_GRADE_UNKNOWN, "Unknown"}, {X86_GRADE_APPLIANCE, "Appliance"},
|
||||
{X86_GRADE_MOBILE, "Mobile"}, {X86_GRADE_TABLET, "Tablet"},
|
||||
{X86_GRADE_DESKTOP, "Desktop"}, {X86_GRADE_CLIENT, "Client"},
|
||||
{X86_GRADE_DENSITY, "Density"}, {X86_GRADE_SERVER, "Server"},
|
||||
{X86_GRADE_SCIENCE, "Science"}, {0, 0},
|
||||
};
|
12
tool/decode/lib/x86idnames.h
Normal file
12
tool/decode/lib/x86idnames.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_X86IDNAMES_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_X86IDNAMES_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern const struct IdName kX86MarchNames[];
|
||||
extern const struct IdName kX86GradeNames[];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_X86IDNAMES_H_ */
|
47
tool/decode/lib/x86marchnames.c
Normal file
47
tool/decode/lib/x86marchnames.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nexgen32e/x86info.h"
|
||||
#include "tool/decode/lib/x86idnames.h"
|
||||
|
||||
const struct IdName kX86MarchNames[] = {
|
||||
{X86_MARCH_UNKNOWN, "Unknown"},
|
||||
{X86_MARCH_CORE2, "Core 2"},
|
||||
{X86_MARCH_NEHALEM, "Nehalem"},
|
||||
{X86_MARCH_WESTMERE, "Westmere"},
|
||||
{X86_MARCH_SANDYBRIDGE, "Sandybridge"},
|
||||
{X86_MARCH_IVYBRIDGE, "Ivybridge"},
|
||||
{X86_MARCH_HASWELL, "Haswell"},
|
||||
{X86_MARCH_BROADWELL, "Broadwell"},
|
||||
{X86_MARCH_SKYLAKE, "Skylake"},
|
||||
{X86_MARCH_KABYLAKE, "Kabylake"},
|
||||
{X86_MARCH_CANNONLAKE, "Cannonlake"},
|
||||
{X86_MARCH_ICELAKE, "Icelake"},
|
||||
{X86_MARCH_TIGERLAKE, "Tigerlake"},
|
||||
{X86_MARCH_BONNELL, "Bonnell"},
|
||||
{X86_MARCH_SALTWELL, "Saltwell"},
|
||||
{X86_MARCH_SILVERMONT, "Silvermont"},
|
||||
{X86_MARCH_AIRMONT, "Airmont"},
|
||||
{X86_MARCH_GOLDMONT, "Goldmont"},
|
||||
{X86_MARCH_GOLDMONTPLUS, "Goldmont Plus"},
|
||||
{X86_MARCH_TREMONT, "Tremont"},
|
||||
{X86_MARCH_KNIGHTSLANDING, "Knights Landing"},
|
||||
{X86_MARCH_KNIGHTSMILL, "Knights Mill"},
|
||||
{0, 0},
|
||||
};
|
47
tool/decode/lib/xederrors.c
Normal file
47
tool/decode/lib/xederrors.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/xed/x86.h"
|
||||
#include "tool/decode/lib/idname.h"
|
||||
|
||||
const struct IdName kXedErrorNames[] = {
|
||||
{XED_ERROR_NONE, "NONE"},
|
||||
{XED_ERROR_BUFFER_TOO_SHORT, "BUFFER_TOO_SHORT"},
|
||||
{XED_ERROR_GENERAL_ERROR, "GENERAL_ERROR"},
|
||||
{XED_ERROR_INVALID_FOR_CHIP, "INVALID_FOR_CHIP"},
|
||||
{XED_ERROR_BAD_REGISTER, "BAD_REGISTER"},
|
||||
{XED_ERROR_BAD_LOCK_PREFIX, "BAD_LOCK_PREFIX"},
|
||||
{XED_ERROR_BAD_REP_PREFIX, "BAD_REP_PREFIX"},
|
||||
{XED_ERROR_BAD_LEGACY_PREFIX, "BAD_LEGACY_PREFIX"},
|
||||
{XED_ERROR_BAD_REX_PREFIX, "BAD_REX_PREFIX"},
|
||||
{XED_ERROR_BAD_EVEX_UBIT, "BAD_EVEX_UBIT"},
|
||||
{XED_ERROR_BAD_MAP, "BAD_MAP"},
|
||||
{XED_ERROR_BAD_EVEX_V_PRIME, "BAD_EVEX_V_PRIME"},
|
||||
{XED_ERROR_BAD_EVEX_Z_NO_MASKING, "BAD_EVEX_Z_NO_MASKING"},
|
||||
{XED_ERROR_NO_OUTPUT_POINTER, "NO_OUTPUT_POINTER"},
|
||||
{XED_ERROR_NO_AGEN_CALL_BACK_REGISTERED, "NO_AGEN_CALL_BACK_REGISTERED"},
|
||||
{XED_ERROR_BAD_MEMOP_INDEX, "BAD_MEMOP_INDEX"},
|
||||
{XED_ERROR_CALLBACK_PROBLEM, "CALLBACK_PROBLEM"},
|
||||
{XED_ERROR_GATHER_REGS, "GATHER_REGS"},
|
||||
{XED_ERROR_INSTR_TOO_LONG, "INSTR_TOO_LONG"},
|
||||
{XED_ERROR_INVALID_MODE, "INVALID_MODE"},
|
||||
{XED_ERROR_BAD_EVEX_LL, "BAD_EVEX_LL"},
|
||||
{XED_ERROR_UNIMPLEMENTED, "UNIMPLEMENTED"},
|
||||
{0, 0},
|
||||
};
|
11
tool/decode/lib/xederrors.h
Normal file
11
tool/decode/lib/xederrors.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_XEDERRORS_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_XEDERRORS_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern const struct IdName kXedErrorNames[];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_XEDERRORS_H_ */
|
71
tool/decode/lib/zipnames.c
Normal file
71
tool/decode/lib/zipnames.c
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/zip.h"
|
||||
#include "tool/decode/lib/zipnames.h"
|
||||
|
||||
const struct IdName kZipCompressionNames[] = {
|
||||
{kZipCompressionNone, "kZipCompressionNone"},
|
||||
{kZipCompressionDeflate, "kZipCompressionDeflate"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kZipExtraNames[] = {
|
||||
{kZipExtraZip64, "kZipExtraZip64"},
|
||||
{kZipExtraNtfs, "kZipExtraNtfs"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kZipIattrNames[] = {
|
||||
{kZipIattrBinary, "kZipIattrBinary"},
|
||||
{kZipIattrAscii, "kZipIattrAscii"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kZipOsNames[] = {
|
||||
{kZipOsDos, "kZipOsDos"},
|
||||
{kZipOsAmiga, "kZipOsAmiga"},
|
||||
{kZipOsOpenvms, "kZipOsOpenvms"},
|
||||
{kZipOsUnix, "kZipOsUnix"},
|
||||
{kZipOsVmcms, "kZipOsVmcms"},
|
||||
{kZipOsAtarist, "kZipOsAtarist"},
|
||||
{kZipOsOs2hpfs, "kZipOsOs2hpfs"},
|
||||
{kZipOsMacintosh, "kZipOsMacintosh"},
|
||||
{kZipOsZsystem, "kZipOsZsystem"},
|
||||
{kZipOsCpm, "kZipOsCpm"},
|
||||
{kZipOsWindowsntfs, "kZipOsWindowsntfs"},
|
||||
{kZipOsMvsos390zos, "kZipOsMvsos390zos"},
|
||||
{kZipOsVse, "kZipOsVse"},
|
||||
{kZipOsAcornrisc, "kZipOsAcornrisc"},
|
||||
{kZipOsVfat, "kZipOsVfat"},
|
||||
{kZipOsAltmvs, "kZipOsAltmvs"},
|
||||
{kZipOsBeos, "kZipOsBeos"},
|
||||
{kZipOsTandem, "kZipOsTandem"},
|
||||
{kZipOsOs400, "kZipOsOs400"},
|
||||
{kZipOsOsxdarwin, "kZipOsOsxdarwin"},
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
const struct IdName kZipEraNames[] = {
|
||||
{kZipEra1989, "kZipEra1989"},
|
||||
{kZipEra1993, "kZipEra1993"},
|
||||
{kZipEra2001, "kZipEra2001"},
|
||||
{0, 0},
|
||||
};
|
15
tool/decode/lib/zipnames.h
Normal file
15
tool/decode/lib/zipnames.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_DECODE_LIB_ZIPNAMES_H_
|
||||
#define COSMOPOLITAN_TOOL_DECODE_LIB_ZIPNAMES_H_
|
||||
#include "tool/decode/lib/idname.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern const struct IdName kZipCompressionNames[];
|
||||
extern const struct IdName kZipExtraNames[];
|
||||
extern const struct IdName kZipIattrNames[];
|
||||
extern const struct IdName kZipOsNames[];
|
||||
extern const struct IdName kZipEraNames[];
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_TOOL_DECODE_LIB_ZIPNAMES_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue