Skip to content

all: reduce type, align for 64-bit, using autopadding memholes after swap fields #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asm/labels.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ union label { /* actual label structures */
enum label_type type, mangled_type;
} defn;
struct {
int32_t movingon;
int64_t dummy;
union label *next;
int32_t movingon;
} admin;
};

Expand Down
43 changes: 22 additions & 21 deletions asm/preproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ enum sparmflags {

struct smac_param {
Token name;
const Token *def; /* Default, if any */
enum sparmflags flags;
char radix; /* Radix type for SPARM_EVAL */
const Token *def; /* Default, if any */
};

struct SMacro {
Expand Down Expand Up @@ -285,15 +285,10 @@ struct MMacro {
#endif
char *name;
int nparam_min, nparam_max;
enum nolist_flags nolist; /* is this macro listing-inhibited? */
bool casesense;
bool plus; /* is the last parameter greedy? */
bool capture_label; /* macro definition has %00; capture label */
int32_t in_progress; /* is this macro currently being expanded? */
int32_t max_depth; /* maximum number of recursive expansions allowed */
Token *dlist; /* All defaults as one list */
Token **defaults; /* Parameter default pointers */
int ndefs; /* number of default parameters */
Line *expansion;

struct mstk mstk; /* Macro expansion stack */
Expand All @@ -310,6 +305,12 @@ struct MMacro {
struct debug_macro_def *def; /* Definition */
struct debug_macro_inv *inv; /* Current invocation (if any) */
} dbg;

int ndefs; /* number of default parameters */
enum nolist_flags nolist; /* is this macro listing-inhibited? */
bool casesense;
bool plus; /* is the last parameter greedy? */
bool capture_label; /* macro definition has %00; capture label */
};


Expand Down Expand Up @@ -7595,28 +7596,28 @@ stdmac_map(const SMacro *s, Token **params, int nparam)
/* Add magic standard macros */
struct magic_macros {
const char *name;
bool casesense;
ExpandSMacro func;
int nparam;
enum sparmflags flags;
ExpandSMacro func;
bool casesense;
};

static void pp_add_magic_stdmac(void)
{
static const struct magic_macros magic_macros[] = {
{ "__?FILE?__", true, 0, 0, stdmac_file },
{ "__?LINE?__", true, 0, 0, stdmac_line },
{ "__?BITS?__", true, 0, 0, stdmac_bits },
{ "__?PTR?__", true, 0, 0, stdmac_ptr },
{ "%abs", false, 1, SPARM_EVAL, stdmac_abs },
{ "%count", false, 1, SPARM_VARADIC, stdmac_count },
{ "%eval", false, 1, SPARM_EVAL|SPARM_VARADIC, stdmac_join },
{ "%map", false, 1, SPARM_VARADIC, stdmac_map },
{ "%str", false, 1, SPARM_GREEDY|SPARM_STR, stdmac_join },
{ "%strcat", false, 1, SPARM_STR|SPARM_CONDQUOTE|SPARM_VARADIC, stdmac_strcat },
{ "%strlen", false, 1, SPARM_STR|SPARM_CONDQUOTE, stdmac_strlen },
{ "%tok", false, 1, SPARM_STR|SPARM_CONDQUOTE, stdmac_tok },
{ NULL, false, 0, 0, NULL }
{ "__?FILE?__", stdmac_file, 0, 0, true },
{ "__?LINE?__", stdmac_line, 0, 0, true },
{ "__?BITS?__", stdmac_bits, 0, 0, true },
{ "__?PTR?__", stdmac_ptr, 0, 0, true },
{ "%abs", stdmac_abs, 1, SPARM_EVAL, false },
{ "%count", stdmac_count, 1, SPARM_VARADIC, false },
{ "%eval", stdmac_join, 1, SPARM_EVAL|SPARM_VARADIC, false },
{ "%map", stdmac_map, 1, SPARM_VARADIC, false },
{ "%str", stdmac_join, 1, SPARM_GREEDY|SPARM_STR, false },
{ "%strcat", stdmac_strcat, 1, SPARM_STR|SPARM_CONDQUOTE|SPARM_VARADIC, false },
{ "%strlen", stdmac_strlen, 1, SPARM_STR|SPARM_CONDQUOTE, false },
{ "%tok", stdmac_tok, 1, SPARM_STR|SPARM_CONDQUOTE, false },
{ NULL, NULL, 0, 0, false }
};
const struct magic_macros *m;
SMacro tmpl;
Expand Down
5 changes: 3 additions & 2 deletions disasm/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
* Prefix information
*/
struct prefix_info {
uint32_t rex; /* REX prefix present */
uint8_t evex[3]; /* EVEX prefix present */

uint8_t osize; /* Operand size */
uint8_t asize; /* Address size */
uint8_t osp; /* Operand size prefix present */
Expand All @@ -89,8 +92,6 @@ struct prefix_info {
uint8_t vex_m; /* VEX.M field */
uint8_t vex_v;
uint8_t vex_lp; /* VEX.LP fields */
uint32_t rex; /* REX prefix present */
uint8_t evex[3]; /* EVEX prefix present */
};

#define getu8(x) (*(uint8_t *)(x))
Expand Down
12 changes: 6 additions & 6 deletions include/nasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ extern const char *_progname;
/* Time stamp for the official start of compilation */
struct compile_time {
time_t t;
bool have_local, have_gm, have_posix;
int64_t posix;
struct tm local;
struct tm gm;
bool have_local, have_gm, have_posix;
};
extern struct compile_time official_compile_time;

Expand Down Expand Up @@ -314,10 +314,10 @@ struct tokenval {
char *t_charptr;
int64_t t_integer;
int64_t t_inttwo;
const char *t_start; /* Pointer to token in input buffer */
int t_len; /* Length of token in input buffer */
enum token_type t_type;
int8_t t_flag;
const char *t_start; /* Pointer to token in input buffer */
int t_len; /* Length of token in input buffer */
};
typedef int (*scanner)(void *private_data, struct tokenval *tv);

Expand Down Expand Up @@ -760,15 +760,15 @@ typedef struct insn { /* an instruction itself */
int eops_float; /* true if DD and floating */
int32_t times; /* repeat count (TIMES prefix) */
bool rex_done; /* REX prefix emitted? */
uint8_t evex_p[3]; /* EVEX.P0: [RXB,R',00,mm], P1: [W,vvvv,1,pp] */
/* EVEX.P2: [z,L'L,b,V',aaa] */
int rex; /* Special REX Prefix */
int vexreg; /* Register encoded in VEX prefix */
int vex_cm; /* Class and M field for VEX prefix */
int vex_wlp; /* W, P and L information for VEX prefix */
uint8_t evex_p[3]; /* EVEX.P0: [RXB,R',00,mm], P1: [W,vvvv,1,pp] */
/* EVEX.P2: [z,L'L,b,V',aaa] */
enum ttypes evex_tuple; /* Tuple type for compressed Disp8*N */
int evex_rm; /* static rounding mode for AVX512 (EVEX) */
struct operand *evex_brerop; /* BR/ER/SAE operand position */
enum ttypes evex_tuple; /* Tuple type for compressed Disp8*N */
} insn;

/* Instruction flags type: IF_* flags are defined in insns.h */
Expand Down
21 changes: 10 additions & 11 deletions output/codeview.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,16 @@ struct source_file;
struct source_file {
const char *filename;
char *fullname;
uint32_t fullnamelen;

struct source_file *next;

uint32_t fullnamelen;

uint32_t filetbl_off;
uint32_t sourcetbl_off;

struct SAA *lines;
uint32_t num_lines;
struct SAA *lines;

unsigned char md5sum[MD5_HASHBYTES];
};
Expand All @@ -110,13 +111,8 @@ enum symbol_type {
};

struct cv8_symbol {
enum symbol_type type;
char *name;

uint32_t secrel;
uint16_t section;
uint32_t size;
uint32_t typeindex;
enum symbol_type type;

enum symtype {
TYPE_UNREGISTERED = 0x0000, /* T_NOTYPE */
Expand All @@ -132,22 +128,25 @@ struct cv8_symbol {
TYPE_REAL256= 0x0044,
TYPE_REAL512= 0x0045
} symtype;

uint32_t secrel;
uint32_t size;
uint32_t typeindex;
uint16_t section;
};

struct cv8_state {
int symbol_sect;
int type_sect;

uint32_t text_offset;

struct source_file *source_files, **source_files_tail;
const char *last_filename;
struct source_file *last_source_file;
struct hash_table file_hash;
unsigned num_files;
uint32_t total_filename_len;


uint32_t text_offset;
unsigned total_lines;

struct SAA *symbols;
Expand Down
2 changes: 1 addition & 1 deletion output/outaout.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ struct Symbol {
int32_t value; /* address, or COMMON variable size */
int32_t size; /* size for data or function exports */
int32_t segment; /* back-reference used by gsym_reloc */
int32_t symnum; /* index into symbol table */
struct Symbol *next; /* list of globals in each section */
struct Symbol *nextfwd; /* list of unresolved-size symbols */
char *name; /* for unresolved-size symbols */
int32_t symnum; /* index into symbol table */
};

/*
Expand Down
3 changes: 2 additions & 1 deletion output/outbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ static struct Section {
int64_t length; /* section length in bytes */

/* Section attributes */
int flags; /* see flag definitions above */
uint64_t align; /* section alignment */
uint64_t valign; /* notional section alignment */
uint64_t start; /* section start address */
Expand All @@ -130,6 +129,8 @@ static struct Section {
struct Section *prev; /* Points to previous section (implicit follows). */
struct Section *next; /* This links sections with a defined start address. */

int flags; /* see flag definitions above */

/* The extended bin format allows for sections to have a "virtual"
* start address. This is accomplished by creating two sections:
* one beginning at the Load Memory Address and the other beginning
Expand Down
2 changes: 1 addition & 1 deletion output/outcoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,8 @@ static void coff_sect_write(struct coff_Section *sect,

typedef struct tagString {
struct tagString *next;
int len;
char *String;
int len;
} STRING;

#define EXPORT_SECTION_NAME ".drectve"
Expand Down
2 changes: 1 addition & 1 deletion output/outdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

struct Section {
struct Section *next;
int32_t number;
char *name;
int32_t number;
} *dbgsect;

static unsigned long dbg_max_data_dump = 128;
Expand Down
2 changes: 1 addition & 1 deletion output/outelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ static int sec_debug;
struct symlininfo {
int offset;
int section; /* index into sects[] */
int segto; /* internal section number */
char *name; /* shallow-copied pointer of section name */
int segto; /* internal section number */
};

struct linelist {
Expand Down
2 changes: 1 addition & 1 deletion output/outelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ struct elf_section {
uint64_t nrelocs;
int32_t index; /* NASM index or NO_SEG if internal */
int shndx; /* ELF index */
int type; /* SHT_* */
uint64_t align; /* alignment: power of two */
uint64_t flags; /* section flags */
int64_t pass_last_seen;
Expand All @@ -128,6 +127,7 @@ struct elf_section {
struct elf_reloc *head;
struct elf_reloc **tail;
struct rbtree *gsyms; /* global symbols in section */
int type; /* SHT_* */
};

#endif /* OUTPUT_OUTELF_H */
8 changes: 4 additions & 4 deletions output/outieee.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ struct ieeeObjData {

struct ieeeFixupp {
struct ieeeFixupp *next;
int32_t id1;
int32_t id2;
int32_t offset;
int32_t addend;
enum {
FT_SEG = 0,
FT_REL = 1,
Expand All @@ -175,10 +179,6 @@ struct ieeeFixupp {
FT_EXTSEG = 7
} ftype;
int16_t size;
int32_t id1;
int32_t id2;
int32_t offset;
int32_t addend;
};

static int32_t ieee_entry_seg, ieee_entry_ofs;
Expand Down
2 changes: 1 addition & 1 deletion output/outlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ struct ol_symhead {
};

struct ol_sect {
uint32_t flags; /* Section/symbol flags */
struct ol_sect *next; /* Next section in declared order */
const char *name; /* Name of section */
struct ol_symhead syml; /* All symbols in this section */
struct ol_symhead symg; /* Global symbols in this section */
struct SAA *data; /* Contents of section */
struct SAA *reloc; /* Section relocations */
uint32_t flags; /* Section/symbol flags */
uint32_t index; /* Primary section index */
uint32_t subindex; /* Current subsection index */
};
Expand Down
33 changes: 17 additions & 16 deletions output/outmacho.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,29 @@ static void fwriteptr(uint64_t data, FILE * fp)
}

struct section {
/* nasm internal data */
struct section *next;
struct SAA *data;
int32_t index; /* Main section index */
int32_t subsection; /* Current subsection index */
int32_t fileindex;
struct reloc *relocs;
struct rbtree *syms[2]; /* All/global symbols symbols in section */
int align;
bool by_name; /* This section was specified by full MachO name */
char namestr[34]; /* segment,section as a C string */

/* data that goes into the file */
char sectname[16]; /* what this section is called */
char segname[16]; /* segment this section will be in */
char sectname[16]; /* what this section is called */
char segname[16]; /* segment this section will be in */

uint64_t addr; /* in-memory address (subject to alignment) */
uint64_t size; /* in-memory and -file size */
uint64_t offset; /* in-file offset */
uint32_t pad; /* padding bytes before section */
uint32_t nreloc; /* relocation entry count */
uint32_t flags; /* type and attributes (masked) */
uint32_t extreloc; /* external relocations */

/* nasm internal data */
struct section *next;
struct SAA *data;
int32_t index; /* Main section index */
int32_t subsection; /* Current subsection index */
struct reloc *relocs;
struct rbtree *syms[2]; /* All/global symbols symbols in section */
char namestr[34]; /* segment,section as a C string */
int align; /* align changed int -> int16_t for reduce cache size and fill mem holes */
uint32_t fileindex;
bool by_name; /* This section was specified by full MachO name */
};

#define S_NASM_TYPE_MASK 0x800004ff /* we consider these bits "section type" */
Expand Down Expand Up @@ -300,18 +301,18 @@ struct file_list {
struct file_list *next;
struct file_list *last;
const char *file_name;
uint32_t file;
struct dir_list *dir;
uint32_t file;
};

struct dw_sect_list {
struct SAA *psaa;
int32_t section;
uint32_t line;
uint64_t offset;
uint32_t file;
struct dw_sect_list *next;
struct dw_sect_list *last;
uint32_t file;
};

struct section_info {
Expand Down
Loading