mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-08-23 10:33:50 -04:00
WSAA: make the WSAA macros contain their own buffer
Make the WSAA macros contain their own buffer definitions. This eliminates the need to have a separate "workbuf" declared in the outelf backends, which isn't even used for anything else, except for a few completely redundant strcpys. Note: these macros probably should be replaced with actual functions. The overhead of the function call is likely to be more than offset by lower icache footprint.
This commit is contained in:
parent
435f1863be
commit
cb38f505e4
@ -255,7 +255,6 @@ static int8_t line_base = -5, line_range = 14, opcode_base = 13;
|
|||||||
static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen,
|
static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen,
|
||||||
abbrevlen, linelen, linerellen, framelen, loclen;
|
abbrevlen, linelen, linerellen, framelen, loclen;
|
||||||
static int32_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym;
|
static int32_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym;
|
||||||
static char workbuf[1024];
|
|
||||||
|
|
||||||
static struct dfmt df_dwarf;
|
static struct dfmt df_dwarf;
|
||||||
static struct dfmt df_stabs;
|
static struct dfmt df_stabs;
|
||||||
@ -307,7 +306,7 @@ static void elf_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
|
|||||||
bsym = raa_init();
|
bsym = raa_init();
|
||||||
strs = saa_init(1L);
|
strs = saa_init(1L);
|
||||||
saa_wbytes(strs, "\0", 1L);
|
saa_wbytes(strs, "\0", 1L);
|
||||||
saa_wbytes(strs, elf_module, (int32_t)(strlen(elf_module) + 1));
|
saa_wbytes(strs, elf_module, strlen(elf_module)+1);
|
||||||
strslen = 2 + strlen(elf_module);
|
strslen = 2 + strlen(elf_module);
|
||||||
shstrtab = NULL;
|
shstrtab = NULL;
|
||||||
shstrtablen = shstrtabsize = 0;;
|
shstrtablen = shstrtabsize = 0;;
|
||||||
@ -1896,8 +1895,8 @@ void dwarf32_output(int type, void *param)
|
|||||||
/* check for file change */
|
/* check for file change */
|
||||||
if (!(inx == dwarf_csect->file))
|
if (!(inx == dwarf_csect->file))
|
||||||
{
|
{
|
||||||
WSAACHAR(plinep,workbuf,DW_LNS_set_file);
|
WSAACHAR(plinep,DW_LNS_set_file);
|
||||||
WSAACHAR(plinep,workbuf,inx);
|
WSAACHAR(plinep,inx);
|
||||||
dwarf_csect->file = inx;
|
dwarf_csect->file = inx;
|
||||||
}
|
}
|
||||||
/* check for line change */
|
/* check for line change */
|
||||||
@ -1908,18 +1907,18 @@ void dwarf32_output(int type, void *param)
|
|||||||
soc = (ln - line_base) + (line_range * aa) + opcode_base;
|
soc = (ln - line_base) + (line_range * aa) + opcode_base;
|
||||||
if (ln >= line_base && ln < maxln && soc < 256)
|
if (ln >= line_base && ln < maxln && soc < 256)
|
||||||
{
|
{
|
||||||
WSAACHAR(plinep,workbuf,soc);
|
WSAACHAR(plinep,soc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ln)
|
if (ln)
|
||||||
{
|
{
|
||||||
WSAACHAR(plinep,workbuf,DW_LNS_advance_line);
|
WSAACHAR(plinep,DW_LNS_advance_line);
|
||||||
saa_wleb128s(plinep,ln);
|
saa_wleb128s(plinep,ln);
|
||||||
}
|
}
|
||||||
if (aa)
|
if (aa)
|
||||||
{
|
{
|
||||||
WSAACHAR(plinep,workbuf,DW_LNS_advance_pc);
|
WSAACHAR(plinep,DW_LNS_advance_pc);
|
||||||
saa_wleb128u(plinep,aa);
|
saa_wleb128u(plinep,aa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1934,6 +1933,7 @@ void dwarf32_output(int type, void *param)
|
|||||||
|
|
||||||
void dwarf32_generate(void)
|
void dwarf32_generate(void)
|
||||||
{
|
{
|
||||||
|
static const char nasm_signature[] = "NASM " NASM_VER;
|
||||||
uint8_t *pbuf;
|
uint8_t *pbuf;
|
||||||
int indx;
|
int indx;
|
||||||
struct linelist *ftentry;
|
struct linelist *ftentry;
|
||||||
@ -1946,14 +1946,14 @@ void dwarf32_generate(void)
|
|||||||
/* and build aranges section */
|
/* and build aranges section */
|
||||||
paranges = saa_init(1L);
|
paranges = saa_init(1L);
|
||||||
parangesrel = saa_init(1L);
|
parangesrel = saa_init(1L);
|
||||||
WSAASHORT(paranges,workbuf,2); /* dwarf version */
|
WSAASHORT(paranges,2); /* dwarf version */
|
||||||
WSAALONG(parangesrel,workbuf, paranges->datalen+4);
|
WSAALONG(parangesrel, paranges->datalen+4);
|
||||||
WSAALONG(parangesrel,workbuf, (dwarf_infosym << 8) + R_386_32); /* reloc to info */
|
WSAALONG(parangesrel, (dwarf_infosym << 8) + R_386_32); /* reloc to info */
|
||||||
WSAALONG(parangesrel,workbuf, (uint32_t) 0);
|
WSAALONG(parangesrel, 0);
|
||||||
WSAALONG(paranges,workbuf,0); /* offset into info */
|
WSAALONG(paranges,0); /* offset into info */
|
||||||
WSAACHAR(paranges,workbuf,4); /* pointer size */
|
WSAACHAR(paranges,4); /* pointer size */
|
||||||
WSAACHAR(paranges,workbuf,0); /* not segmented */
|
WSAACHAR(paranges,0); /* not segmented */
|
||||||
WSAALONG(paranges,workbuf,0); /* padding */
|
WSAALONG(paranges,0); /* padding */
|
||||||
/* iterate though sectlist entries */
|
/* iterate though sectlist entries */
|
||||||
psect = dwarf_fsect;
|
psect = dwarf_fsect;
|
||||||
totlen = 0;
|
totlen = 0;
|
||||||
@ -1962,25 +1962,25 @@ void dwarf32_generate(void)
|
|||||||
{
|
{
|
||||||
plinep = psect->psaa;
|
plinep = psect->psaa;
|
||||||
/* Line Number Program Epilogue */
|
/* Line Number Program Epilogue */
|
||||||
WSAACHAR(plinep,workbuf,2); /* std op 2 */
|
WSAACHAR(plinep,2); /* std op 2 */
|
||||||
WSAACHAR(plinep,workbuf,(sects[psect->section]->len)-psect->offset);
|
WSAACHAR(plinep,(sects[psect->section]->len)-psect->offset);
|
||||||
WSAACHAR(plinep,workbuf,DW_LNS_extended_op);
|
WSAACHAR(plinep,DW_LNS_extended_op);
|
||||||
WSAACHAR(plinep,workbuf,1); /* operand length */
|
WSAACHAR(plinep,1); /* operand length */
|
||||||
WSAACHAR(plinep,workbuf,DW_LNE_end_sequence);
|
WSAACHAR(plinep,DW_LNE_end_sequence);
|
||||||
totlen += plinep->datalen;
|
totlen += plinep->datalen;
|
||||||
/* range table relocation entry */
|
/* range table relocation entry */
|
||||||
WSAALONG(parangesrel,workbuf, paranges->datalen + 4);
|
WSAALONG(parangesrel, paranges->datalen + 4);
|
||||||
WSAALONG(parangesrel,workbuf, ((uint32_t) (psect->section + 2) << 8) + R_386_32);
|
WSAALONG(parangesrel, ((uint32_t) (psect->section + 2) << 8) + R_386_32);
|
||||||
WSAALONG(parangesrel,workbuf, (uint32_t) 0);
|
WSAALONG(parangesrel, (uint32_t) 0);
|
||||||
/* range table entry */
|
/* range table entry */
|
||||||
WSAALONG(paranges,workbuf,0x0000); /* range start */
|
WSAALONG(paranges,0x0000); /* range start */
|
||||||
WSAALONG(paranges,workbuf,sects[psect->section]->len); /* range length */
|
WSAALONG(paranges,sects[psect->section]->len); /* range length */
|
||||||
highaddr += sects[psect->section]->len;
|
highaddr += sects[psect->section]->len;
|
||||||
/* done with this entry */
|
/* done with this entry */
|
||||||
psect = psect->next;
|
psect = psect->next;
|
||||||
}
|
}
|
||||||
WSAALONG(paranges,workbuf,0); /* null address */
|
WSAALONG(paranges,0); /* null address */
|
||||||
WSAALONG(paranges,workbuf,0); /* null length */
|
WSAALONG(paranges,0); /* null length */
|
||||||
saalen = paranges->datalen;
|
saalen = paranges->datalen;
|
||||||
arangeslen = saalen + 4;
|
arangeslen = saalen + 4;
|
||||||
arangesbuf = pbuf = nasm_malloc(arangeslen);
|
arangesbuf = pbuf = nasm_malloc(arangeslen);
|
||||||
@ -1996,10 +1996,10 @@ void dwarf32_generate(void)
|
|||||||
|
|
||||||
/* build pubnames section */
|
/* build pubnames section */
|
||||||
ppubnames = saa_init(1L);
|
ppubnames = saa_init(1L);
|
||||||
WSAASHORT(ppubnames,workbuf,3); /* dwarf version */
|
WSAASHORT(ppubnames,3); /* dwarf version */
|
||||||
WSAALONG(ppubnames,workbuf,0); /* offset into info */
|
WSAALONG(ppubnames,0); /* offset into info */
|
||||||
WSAALONG(ppubnames,workbuf,0); /* space used in info */
|
WSAALONG(ppubnames,0); /* space used in info */
|
||||||
WSAALONG(ppubnames,workbuf,0); /* end of list */
|
WSAALONG(ppubnames,0); /* end of list */
|
||||||
saalen = ppubnames->datalen;
|
saalen = ppubnames->datalen;
|
||||||
pubnameslen = saalen + 4;
|
pubnameslen = saalen + 4;
|
||||||
pubnamesbuf = pbuf = nasm_malloc(pubnameslen);
|
pubnamesbuf = pbuf = nasm_malloc(pubnameslen);
|
||||||
@ -2010,37 +2010,35 @@ void dwarf32_generate(void)
|
|||||||
/* build info section */
|
/* build info section */
|
||||||
pinfo = saa_init(1L);
|
pinfo = saa_init(1L);
|
||||||
pinforel = saa_init(1L);
|
pinforel = saa_init(1L);
|
||||||
WSAASHORT(pinfo,workbuf,2); /* dwarf version */
|
WSAASHORT(pinfo,2); /* dwarf version */
|
||||||
WSAALONG(pinforel,workbuf, pinfo->datalen + 4);
|
WSAALONG(pinforel, pinfo->datalen + 4);
|
||||||
WSAALONG(pinforel,workbuf, (dwarf_abbrevsym << 8) + R_386_32); /* reloc to abbrev */
|
WSAALONG(pinforel, (dwarf_abbrevsym << 8) + R_386_32); /* reloc to abbrev */
|
||||||
WSAALONG(pinforel,workbuf, (uint32_t) 0);
|
WSAALONG(pinforel, 0);
|
||||||
WSAALONG(pinfo,workbuf,0); /* offset into abbrev */
|
WSAALONG(pinfo,0); /* offset into abbrev */
|
||||||
WSAACHAR(pinfo,workbuf,4); /* pointer size */
|
WSAACHAR(pinfo,4); /* pointer size */
|
||||||
WSAACHAR(pinfo,workbuf,1); /* abbrviation number LEB128u */
|
WSAACHAR(pinfo,1); /* abbrviation number LEB128u */
|
||||||
WSAALONG(pinforel,workbuf, pinfo->datalen + 4);
|
WSAALONG(pinforel, pinfo->datalen + 4);
|
||||||
WSAALONG(pinforel,workbuf, ((dwarf_fsect->section + 2) << 8) + R_386_32);
|
WSAALONG(pinforel, ((dwarf_fsect->section + 2) << 8) + R_386_32);
|
||||||
WSAALONG(pinforel,workbuf, (uint32_t) 0);
|
WSAALONG(pinforel, 0);
|
||||||
WSAALONG(pinfo,workbuf,0); /* DW_AT_low_pc */
|
WSAALONG(pinfo,0); /* DW_AT_low_pc */
|
||||||
WSAALONG(pinforel,workbuf, pinfo->datalen + 4);
|
WSAALONG(pinforel, pinfo->datalen + 4);
|
||||||
WSAALONG(pinforel,workbuf, ((dwarf_fsect->section + 2) << 8) + R_386_32);
|
WSAALONG(pinforel, ((dwarf_fsect->section + 2) << 8) + R_386_32);
|
||||||
WSAALONG(pinforel,workbuf, (uint32_t) 0);
|
WSAALONG(pinforel, 0);
|
||||||
WSAALONG(pinfo,workbuf,highaddr); /* DW_AT_high_pc */
|
WSAALONG(pinfo,highaddr); /* DW_AT_high_pc */
|
||||||
WSAALONG(pinforel,workbuf, pinfo->datalen + 4);
|
WSAALONG(pinforel, pinfo->datalen + 4);
|
||||||
WSAALONG(pinforel,workbuf, (dwarf_linesym << 8) + R_386_32); /* reloc to line */
|
WSAALONG(pinforel, (dwarf_linesym << 8) + R_386_32); /* reloc to line */
|
||||||
WSAALONG(pinforel,workbuf, (uint32_t) 0);
|
WSAALONG(pinforel, 0);
|
||||||
WSAALONG(pinfo,workbuf,0); /* DW_AT_stmt_list */
|
WSAALONG(pinfo,0); /* DW_AT_stmt_list */
|
||||||
strcpy(workbuf,elf_module); /* input file name */
|
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1);
|
||||||
saa_wbytes(pinfo, workbuf, (int32_t)(strlen(elf_module) + 1));
|
saa_wbytes(pinfo, nasm_signature, strlen(nasm_signature)+1);
|
||||||
sprintf(workbuf, "NASM %s", NASM_VER);
|
WSAASHORT(pinfo,DW_LANG_Mips_Assembler);
|
||||||
saa_wbytes(pinfo, workbuf, (int32_t)(strlen(workbuf) + 1));
|
WSAACHAR(pinfo,2); /* abbrviation number LEB128u */
|
||||||
WSAASHORT(pinfo,workbuf,DW_LANG_Mips_Assembler);
|
WSAALONG(pinforel, pinfo->datalen + 4);
|
||||||
WSAACHAR(pinfo,workbuf,2); /* abbrviation number LEB128u */
|
WSAALONG(pinforel, ((dwarf_fsect->section + 2) << 8) + R_386_32);
|
||||||
WSAALONG(pinforel,workbuf, pinfo->datalen + 4);
|
WSAALONG(pinforel, 0);
|
||||||
WSAALONG(pinforel,workbuf, ((dwarf_fsect->section + 2) << 8) + R_386_32);
|
WSAALONG(pinfo,0); /* DW_AT_low_pc */
|
||||||
WSAALONG(pinforel,workbuf, (uint32_t) 0);
|
WSAALONG(pinfo,0); /* DW_AT_frame_base */
|
||||||
WSAALONG(pinfo,workbuf,0); /* DW_AT_low_pc */
|
WSAACHAR(pinfo,0); /* end of entries */
|
||||||
WSAALONG(pinfo,workbuf,0); /* DW_AT_frame_base */
|
|
||||||
WSAACHAR(pinfo,workbuf,0); /* end of entries */
|
|
||||||
saalen = pinfo->datalen;
|
saalen = pinfo->datalen;
|
||||||
infolen = saalen + 4;
|
infolen = saalen + 4;
|
||||||
infobuf = pbuf = nasm_malloc(infolen);
|
infobuf = pbuf = nasm_malloc(infolen);
|
||||||
@ -2056,32 +2054,32 @@ void dwarf32_generate(void)
|
|||||||
|
|
||||||
/* build abbrev section */
|
/* build abbrev section */
|
||||||
pabbrev = saa_init(1L);
|
pabbrev = saa_init(1L);
|
||||||
WSAACHAR(pabbrev,workbuf,1); /* entry number LEB128u */
|
WSAACHAR(pabbrev,1); /* entry number LEB128u */
|
||||||
WSAACHAR(pabbrev,workbuf,DW_TAG_compile_unit); /* tag LEB128u */
|
WSAACHAR(pabbrev,DW_TAG_compile_unit); /* tag LEB128u */
|
||||||
WSAACHAR(pabbrev,workbuf,1); /* has children */
|
WSAACHAR(pabbrev,1); /* has children */
|
||||||
/* the following attributes and forms are all LEB128u values */
|
/* the following attributes and forms are all LEB128u values */
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_low_pc);
|
WSAACHAR(pabbrev,DW_AT_low_pc);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_addr);
|
WSAACHAR(pabbrev,DW_FORM_addr);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_high_pc);
|
WSAACHAR(pabbrev,DW_AT_high_pc);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_addr);
|
WSAACHAR(pabbrev,DW_FORM_addr);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_stmt_list);
|
WSAACHAR(pabbrev,DW_AT_stmt_list);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_data4);
|
WSAACHAR(pabbrev,DW_FORM_data4);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_name);
|
WSAACHAR(pabbrev,DW_AT_name);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_string);
|
WSAACHAR(pabbrev,DW_FORM_string);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_producer);
|
WSAACHAR(pabbrev,DW_AT_producer);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_string);
|
WSAACHAR(pabbrev,DW_FORM_string);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_language);
|
WSAACHAR(pabbrev,DW_AT_language);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_data2);
|
WSAACHAR(pabbrev,DW_FORM_data2);
|
||||||
WSAASHORT(pabbrev,workbuf,0); /* end of entry */
|
WSAASHORT(pabbrev,0); /* end of entry */
|
||||||
/* LEB128u usage same as above */
|
/* LEB128u usage same as above */
|
||||||
WSAACHAR(pabbrev,workbuf,2); /* entry number */
|
WSAACHAR(pabbrev,2); /* entry number */
|
||||||
WSAACHAR(pabbrev,workbuf,DW_TAG_subprogram);
|
WSAACHAR(pabbrev,DW_TAG_subprogram);
|
||||||
WSAACHAR(pabbrev,workbuf,0); /* no children */
|
WSAACHAR(pabbrev,0); /* no children */
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_low_pc);
|
WSAACHAR(pabbrev,DW_AT_low_pc);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_addr);
|
WSAACHAR(pabbrev,DW_FORM_addr);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_frame_base);
|
WSAACHAR(pabbrev,DW_AT_frame_base);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_data4);
|
WSAACHAR(pabbrev,DW_FORM_data4);
|
||||||
WSAASHORT(pabbrev,workbuf,0); /* end of entry */
|
WSAASHORT(pabbrev,0); /* end of entry */
|
||||||
abbrevlen = saalen = pabbrev->datalen;
|
abbrevlen = saalen = pabbrev->datalen;
|
||||||
abbrevbuf = pbuf = nasm_malloc(saalen);
|
abbrevbuf = pbuf = nasm_malloc(saalen);
|
||||||
saa_rnbytes(pabbrev, pbuf, saalen);
|
saa_rnbytes(pabbrev, pbuf, saalen);
|
||||||
@ -2090,37 +2088,37 @@ void dwarf32_generate(void)
|
|||||||
/* build line section */
|
/* build line section */
|
||||||
/* prolog */
|
/* prolog */
|
||||||
plines = saa_init(1L);
|
plines = saa_init(1L);
|
||||||
WSAACHAR(plines,workbuf,1); /* Minimum Instruction Length */
|
WSAACHAR(plines,1); /* Minimum Instruction Length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Initial value of 'is_stmt' */
|
WSAACHAR(plines,1); /* Initial value of 'is_stmt' */
|
||||||
WSAACHAR(plines,workbuf,line_base); /* Line Base */
|
WSAACHAR(plines,line_base); /* Line Base */
|
||||||
WSAACHAR(plines,workbuf,line_range); /* Line Range */
|
WSAACHAR(plines,line_range); /* Line Range */
|
||||||
WSAACHAR(plines,workbuf,opcode_base); /* Opcode Base */
|
WSAACHAR(plines,opcode_base); /* Opcode Base */
|
||||||
/* standard opcode lengths (# of LEB128u operands) */
|
/* standard opcode lengths (# of LEB128u operands) */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 1 length */
|
WSAACHAR(plines,0); /* Std opcode 1 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 2 length */
|
WSAACHAR(plines,1); /* Std opcode 2 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 3 length */
|
WSAACHAR(plines,1); /* Std opcode 3 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 4 length */
|
WSAACHAR(plines,1); /* Std opcode 4 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 5 length */
|
WSAACHAR(plines,1); /* Std opcode 5 length */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 6 length */
|
WSAACHAR(plines,0); /* Std opcode 6 length */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 7 length */
|
WSAACHAR(plines,0); /* Std opcode 7 length */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 8 length */
|
WSAACHAR(plines,0); /* Std opcode 8 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 9 length */
|
WSAACHAR(plines,1); /* Std opcode 9 length */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 10 length */
|
WSAACHAR(plines,0); /* Std opcode 10 length */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 11 length */
|
WSAACHAR(plines,0); /* Std opcode 11 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 12 length */
|
WSAACHAR(plines,1); /* Std opcode 12 length */
|
||||||
/* Directory Table */
|
/* Directory Table */
|
||||||
WSAACHAR(plines,workbuf,0); /* End of table */
|
WSAACHAR(plines,0); /* End of table */
|
||||||
/* File Name Table */
|
/* File Name Table */
|
||||||
ftentry = dwarf_flist;
|
ftentry = dwarf_flist;
|
||||||
for (indx = 0;indx<dwarf_numfiles;indx++)
|
for (indx = 0;indx<dwarf_numfiles;indx++)
|
||||||
{
|
{
|
||||||
saa_wbytes(plines, ftentry->filename, (int32_t)(strlen(ftentry->filename) + 1));
|
saa_wbytes(plines, ftentry->filename, (int32_t)(strlen(ftentry->filename) + 1));
|
||||||
WSAACHAR(plines,workbuf,0); /* directory LEB128u */
|
WSAACHAR(plines,0); /* directory LEB128u */
|
||||||
WSAACHAR(plines,workbuf,0); /* time LEB128u */
|
WSAACHAR(plines,0); /* time LEB128u */
|
||||||
WSAACHAR(plines,workbuf,0); /* size LEB128u */
|
WSAACHAR(plines,0); /* size LEB128u */
|
||||||
ftentry = ftentry->next;
|
ftentry = ftentry->next;
|
||||||
}
|
}
|
||||||
WSAACHAR(plines,workbuf,0); /* End of table */
|
WSAACHAR(plines,0); /* End of table */
|
||||||
linepoff = plines->datalen;
|
linepoff = plines->datalen;
|
||||||
linelen = linepoff + totlen + 10;
|
linelen = linepoff + totlen + 10;
|
||||||
linebuf = pbuf = nasm_malloc(linelen);
|
linebuf = pbuf = nasm_malloc(linelen);
|
||||||
@ -2138,9 +2136,9 @@ void dwarf32_generate(void)
|
|||||||
psect = dwarf_fsect;
|
psect = dwarf_fsect;
|
||||||
for (indx = 0; indx < dwarf_nsections; indx++)
|
for (indx = 0; indx < dwarf_nsections; indx++)
|
||||||
{
|
{
|
||||||
WSAALONG(plinesrel,workbuf, linepoff);
|
WSAALONG(plinesrel, linepoff);
|
||||||
WSAALONG(plinesrel,workbuf, ((uint32_t) (psect->section + 2) << 8) + R_386_32);
|
WSAALONG(plinesrel, ((uint32_t) (psect->section + 2) << 8) + R_386_32);
|
||||||
WSAALONG(plinesrel,workbuf, (uint32_t) 0);
|
WSAALONG(plinesrel, (uint32_t) 0);
|
||||||
plinep = psect->psaa;
|
plinep = psect->psaa;
|
||||||
saalen = plinep->datalen;
|
saalen = plinep->datalen;
|
||||||
saa_rnbytes(plinep, pbuf, saalen);
|
saa_rnbytes(plinep, pbuf, saalen);
|
||||||
@ -2275,10 +2273,10 @@ void dwarf32_findsect(const int index)
|
|||||||
dwarf_csect->section = index;
|
dwarf_csect->section = index;
|
||||||
dwarf_csect->next = 0;
|
dwarf_csect->next = 0;
|
||||||
/* set relocatable address at start of line program */
|
/* set relocatable address at start of line program */
|
||||||
WSAACHAR(plinep,workbuf,DW_LNS_extended_op);
|
WSAACHAR(plinep,DW_LNS_extended_op);
|
||||||
WSAACHAR(plinep,workbuf,5); /* operand length */
|
WSAACHAR(plinep,5); /* operand length */
|
||||||
WSAACHAR(plinep,workbuf,DW_LNE_set_address);
|
WSAACHAR(plinep,DW_LNE_set_address);
|
||||||
WSAALONG(plinep,workbuf,0); /* Start Address */
|
WSAALONG(plinep,0); /* Start Address */
|
||||||
/* if first entry */
|
/* if first entry */
|
||||||
if (!dwarf_fsect)
|
if (!dwarf_fsect)
|
||||||
{
|
{
|
||||||
|
@ -267,7 +267,6 @@ static int8_t line_base = -5, line_range = 14, opcode_base = 13;
|
|||||||
static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen,
|
static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen,
|
||||||
abbrevlen, linelen, linerellen, framelen, loclen;
|
abbrevlen, linelen, linerellen, framelen, loclen;
|
||||||
static int64_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym;
|
static int64_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym;
|
||||||
static char workbuf[1024];
|
|
||||||
|
|
||||||
|
|
||||||
static struct dfmt df_dwarf;
|
static struct dfmt df_dwarf;
|
||||||
@ -1915,8 +1914,8 @@ void dwarf64_output(int type, void *param)
|
|||||||
/* check for file change */
|
/* check for file change */
|
||||||
if (!(inx == dwarf_csect->file))
|
if (!(inx == dwarf_csect->file))
|
||||||
{
|
{
|
||||||
WSAACHAR(plinep,workbuf,DW_LNS_set_file);
|
WSAACHAR(plinep,DW_LNS_set_file);
|
||||||
WSAACHAR(plinep,workbuf,inx);
|
WSAACHAR(plinep,inx);
|
||||||
dwarf_csect->file = inx;
|
dwarf_csect->file = inx;
|
||||||
}
|
}
|
||||||
/* check for line change */
|
/* check for line change */
|
||||||
@ -1927,18 +1926,18 @@ void dwarf64_output(int type, void *param)
|
|||||||
soc = (ln - line_base) + (line_range * aa) + opcode_base;
|
soc = (ln - line_base) + (line_range * aa) + opcode_base;
|
||||||
if (ln >= line_base && ln < maxln && soc < 256)
|
if (ln >= line_base && ln < maxln && soc < 256)
|
||||||
{
|
{
|
||||||
WSAACHAR(plinep,workbuf,soc);
|
WSAACHAR(plinep,soc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ln)
|
if (ln)
|
||||||
{
|
{
|
||||||
WSAACHAR(plinep,workbuf,DW_LNS_advance_line);
|
WSAACHAR(plinep,DW_LNS_advance_line);
|
||||||
saa_wleb128s(plinep,ln);
|
saa_wleb128s(plinep,ln);
|
||||||
}
|
}
|
||||||
if (aa)
|
if (aa)
|
||||||
{
|
{
|
||||||
WSAACHAR(plinep,workbuf,DW_LNS_advance_pc);
|
WSAACHAR(plinep,DW_LNS_advance_pc);
|
||||||
saa_wleb128u(plinep,aa);
|
saa_wleb128u(plinep,aa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1953,6 +1952,7 @@ void dwarf64_output(int type, void *param)
|
|||||||
|
|
||||||
void dwarf64_generate(void)
|
void dwarf64_generate(void)
|
||||||
{
|
{
|
||||||
|
static const char nasm_signature[] = "NASM " NASM_VER;
|
||||||
uint8_t *pbuf;
|
uint8_t *pbuf;
|
||||||
int indx;
|
int indx;
|
||||||
struct linelist *ftentry;
|
struct linelist *ftentry;
|
||||||
@ -1965,14 +1965,14 @@ void dwarf64_generate(void)
|
|||||||
/* and build aranges section */
|
/* and build aranges section */
|
||||||
paranges = saa_init(1L);
|
paranges = saa_init(1L);
|
||||||
parangesrel = saa_init(1L);
|
parangesrel = saa_init(1L);
|
||||||
WSAASHORT(paranges,workbuf,3); /* dwarf version */
|
WSAASHORT(paranges,3); /* dwarf version */
|
||||||
WSAADLONG(parangesrel,workbuf, paranges->datalen+4);
|
WSAADLONG(parangesrel, paranges->datalen+4);
|
||||||
WSAADLONG(parangesrel,workbuf, (dwarf_infosym << 32) + R_X86_64_32); /* reloc to info */
|
WSAADLONG(parangesrel, (dwarf_infosym << 32) + R_X86_64_32); /* reloc to info */
|
||||||
WSAADLONG(parangesrel,workbuf, (uint64_t) 0);
|
WSAADLONG(parangesrel, 0);
|
||||||
WSAALONG(paranges,workbuf,0); /* offset into info */
|
WSAALONG(paranges,0); /* offset into info */
|
||||||
WSAACHAR(paranges,workbuf,8); /* pointer size */
|
WSAACHAR(paranges,8); /* pointer size */
|
||||||
WSAACHAR(paranges,workbuf,0); /* not segmented */
|
WSAACHAR(paranges,0); /* not segmented */
|
||||||
WSAALONG(paranges,workbuf,0); /* padding */
|
WSAALONG(paranges,0); /* padding */
|
||||||
/* iterate though sectlist entries */
|
/* iterate though sectlist entries */
|
||||||
psect = dwarf_fsect;
|
psect = dwarf_fsect;
|
||||||
totlen = 0;
|
totlen = 0;
|
||||||
@ -1981,25 +1981,25 @@ void dwarf64_generate(void)
|
|||||||
{
|
{
|
||||||
plinep = psect->psaa;
|
plinep = psect->psaa;
|
||||||
/* Line Number Program Epilogue */
|
/* Line Number Program Epilogue */
|
||||||
WSAACHAR(plinep,workbuf,2); /* std op 2 */
|
WSAACHAR(plinep,2); /* std op 2 */
|
||||||
WSAACHAR(plinep,workbuf,(sects[psect->section]->len)-psect->offset);
|
WSAACHAR(plinep,(sects[psect->section]->len)-psect->offset);
|
||||||
WSAACHAR(plinep,workbuf,DW_LNS_extended_op);
|
WSAACHAR(plinep,DW_LNS_extended_op);
|
||||||
WSAACHAR(plinep,workbuf,1); /* operand length */
|
WSAACHAR(plinep,1); /* operand length */
|
||||||
WSAACHAR(plinep,workbuf,DW_LNE_end_sequence);
|
WSAACHAR(plinep,DW_LNE_end_sequence);
|
||||||
totlen += plinep->datalen;
|
totlen += plinep->datalen;
|
||||||
/* range table relocation entry */
|
/* range table relocation entry */
|
||||||
WSAADLONG(parangesrel,workbuf, paranges->datalen + 4);
|
WSAADLONG(parangesrel, paranges->datalen + 4);
|
||||||
WSAADLONG(parangesrel,workbuf, ((uint64_t) (psect->section + 2) << 32) + R_X86_64_64);
|
WSAADLONG(parangesrel, ((uint64_t) (psect->section + 2) << 32) + R_X86_64_64);
|
||||||
WSAADLONG(parangesrel,workbuf, (uint64_t) 0);
|
WSAADLONG(parangesrel, (uint64_t) 0);
|
||||||
/* range table entry */
|
/* range table entry */
|
||||||
WSAADLONG(paranges,workbuf,0x0000); /* range start */
|
WSAADLONG(paranges,0x0000); /* range start */
|
||||||
WSAADLONG(paranges,workbuf,sects[psect->section]->len); /* range length */
|
WSAADLONG(paranges,sects[psect->section]->len); /* range length */
|
||||||
highaddr += sects[psect->section]->len;
|
highaddr += sects[psect->section]->len;
|
||||||
/* done with this entry */
|
/* done with this entry */
|
||||||
psect = psect->next;
|
psect = psect->next;
|
||||||
}
|
}
|
||||||
WSAADLONG(paranges,workbuf,0); /* null address */
|
WSAADLONG(paranges,0); /* null address */
|
||||||
WSAADLONG(paranges,workbuf,0); /* null length */
|
WSAADLONG(paranges,0); /* null length */
|
||||||
saalen = paranges->datalen;
|
saalen = paranges->datalen;
|
||||||
arangeslen = saalen + 4;
|
arangeslen = saalen + 4;
|
||||||
arangesbuf = pbuf = nasm_malloc(arangeslen);
|
arangesbuf = pbuf = nasm_malloc(arangeslen);
|
||||||
@ -2015,10 +2015,10 @@ void dwarf64_generate(void)
|
|||||||
|
|
||||||
/* build pubnames section */
|
/* build pubnames section */
|
||||||
ppubnames = saa_init(1L);
|
ppubnames = saa_init(1L);
|
||||||
WSAASHORT(ppubnames,workbuf,3); /* dwarf version */
|
WSAASHORT(ppubnames,3); /* dwarf version */
|
||||||
WSAALONG(ppubnames,workbuf,0); /* offset into info */
|
WSAALONG(ppubnames,0); /* offset into info */
|
||||||
WSAALONG(ppubnames,workbuf,0); /* space used in info */
|
WSAALONG(ppubnames,0); /* space used in info */
|
||||||
WSAALONG(ppubnames,workbuf,0); /* end of list */
|
WSAALONG(ppubnames,0); /* end of list */
|
||||||
saalen = ppubnames->datalen;
|
saalen = ppubnames->datalen;
|
||||||
pubnameslen = saalen + 4;
|
pubnameslen = saalen + 4;
|
||||||
pubnamesbuf = pbuf = nasm_malloc(pubnameslen);
|
pubnamesbuf = pbuf = nasm_malloc(pubnameslen);
|
||||||
@ -2029,37 +2029,35 @@ void dwarf64_generate(void)
|
|||||||
/* build info section */
|
/* build info section */
|
||||||
pinfo = saa_init(1L);
|
pinfo = saa_init(1L);
|
||||||
pinforel = saa_init(1L);
|
pinforel = saa_init(1L);
|
||||||
WSAASHORT(pinfo,workbuf,3); /* dwarf version */
|
WSAASHORT(pinfo,3); /* dwarf version */
|
||||||
WSAADLONG(pinforel,workbuf, pinfo->datalen + 4);
|
WSAADLONG(pinforel, pinfo->datalen + 4);
|
||||||
WSAADLONG(pinforel,workbuf, (dwarf_abbrevsym << 32) + R_X86_64_32); /* reloc to abbrev */
|
WSAADLONG(pinforel, (dwarf_abbrevsym << 32) + R_X86_64_32); /* reloc to abbrev */
|
||||||
WSAADLONG(pinforel,workbuf, (uint64_t) 0);
|
WSAADLONG(pinforel, 0);
|
||||||
WSAALONG(pinfo,workbuf,0); /* offset into abbrev */
|
WSAALONG(pinfo,0); /* offset into abbrev */
|
||||||
WSAACHAR(pinfo,workbuf,8); /* pointer size */
|
WSAACHAR(pinfo,8); /* pointer size */
|
||||||
WSAACHAR(pinfo,workbuf,1); /* abbrviation number LEB128u */
|
WSAACHAR(pinfo,1); /* abbrviation number LEB128u */
|
||||||
WSAADLONG(pinforel,workbuf, pinfo->datalen + 4);
|
WSAADLONG(pinforel, pinfo->datalen + 4);
|
||||||
WSAADLONG(pinforel,workbuf, ((uint64_t)(dwarf_fsect->section + 2) << 32) + R_X86_64_64);
|
WSAADLONG(pinforel, ((uint64_t)(dwarf_fsect->section + 2) << 32) + R_X86_64_64);
|
||||||
WSAADLONG(pinforel,workbuf, (uint64_t) 0);
|
WSAADLONG(pinforel, 0);
|
||||||
WSAADLONG(pinfo,workbuf,0); /* DW_AT_low_pc */
|
WSAADLONG(pinfo,0); /* DW_AT_low_pc */
|
||||||
WSAADLONG(pinforel,workbuf, pinfo->datalen + 4);
|
WSAADLONG(pinforel, pinfo->datalen + 4);
|
||||||
WSAADLONG(pinforel,workbuf, ((uint64_t)(dwarf_fsect->section + 2) << 32) + R_X86_64_64);
|
WSAADLONG(pinforel, ((uint64_t)(dwarf_fsect->section + 2) << 32) + R_X86_64_64);
|
||||||
WSAADLONG(pinforel,workbuf, (uint64_t) 0);
|
WSAADLONG(pinforel, 0);
|
||||||
WSAADLONG(pinfo,workbuf,highaddr); /* DW_AT_high_pc */
|
WSAADLONG(pinfo,highaddr); /* DW_AT_high_pc */
|
||||||
WSAADLONG(pinforel,workbuf, pinfo->datalen + 4);
|
WSAADLONG(pinforel, pinfo->datalen + 4);
|
||||||
WSAADLONG(pinforel,workbuf, (dwarf_linesym << 32) + R_X86_64_32); /* reloc to line */
|
WSAADLONG(pinforel, (dwarf_linesym << 32) + R_X86_64_32); /* reloc to line */
|
||||||
WSAADLONG(pinforel,workbuf, (uint64_t) 0);
|
WSAADLONG(pinforel, 0);
|
||||||
WSAALONG(pinfo,workbuf,0); /* DW_AT_stmt_list */
|
WSAALONG(pinfo,0); /* DW_AT_stmt_list */
|
||||||
strcpy(workbuf,elf_module); /* input file name */
|
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1);
|
||||||
saa_wbytes(pinfo, workbuf, (int32_t)(strlen(elf_module) + 1));
|
saa_wbytes(pinfo, nasm_signature, strlen(nasm_signature)+1);
|
||||||
sprintf(workbuf, "NASM %s", NASM_VER);
|
WSAASHORT(pinfo,DW_LANG_Mips_Assembler);
|
||||||
saa_wbytes(pinfo, workbuf, (int32_t)(strlen(workbuf) + 1));
|
WSAACHAR(pinfo,2); /* abbrviation number LEB128u */
|
||||||
WSAASHORT(pinfo,workbuf,DW_LANG_Mips_Assembler);
|
WSAADLONG(pinforel, pinfo->datalen + 4);
|
||||||
WSAACHAR(pinfo,workbuf,2); /* abbrviation number LEB128u */
|
WSAADLONG(pinforel, ((uint64_t)(dwarf_fsect->section + 2) << 32) + R_X86_64_64);
|
||||||
WSAADLONG(pinforel,workbuf, pinfo->datalen + 4);
|
WSAADLONG(pinforel, 0);
|
||||||
WSAADLONG(pinforel,workbuf, ((uint64_t)(dwarf_fsect->section + 2) << 32) + R_X86_64_64);
|
WSAADLONG(pinfo,0); /* DW_AT_low_pc */
|
||||||
WSAADLONG(pinforel,workbuf, (uint64_t) 0);
|
WSAADLONG(pinfo,0); /* DW_AT_frame_base */
|
||||||
WSAADLONG(pinfo,workbuf,0); /* DW_AT_low_pc */
|
WSAACHAR(pinfo,0); /* end of entries */
|
||||||
WSAADLONG(pinfo,workbuf,0); /* DW_AT_frame_base */
|
|
||||||
WSAACHAR(pinfo,workbuf,0); /* end of entries */
|
|
||||||
saalen = pinfo->datalen;
|
saalen = pinfo->datalen;
|
||||||
infolen = saalen + 4;
|
infolen = saalen + 4;
|
||||||
infobuf = pbuf = nasm_malloc(infolen);
|
infobuf = pbuf = nasm_malloc(infolen);
|
||||||
@ -2075,32 +2073,32 @@ void dwarf64_generate(void)
|
|||||||
|
|
||||||
/* build abbrev section */
|
/* build abbrev section */
|
||||||
pabbrev = saa_init(1L);
|
pabbrev = saa_init(1L);
|
||||||
WSAACHAR(pabbrev,workbuf,1); /* entry number LEB128u */
|
WSAACHAR(pabbrev,1); /* entry number LEB128u */
|
||||||
WSAACHAR(pabbrev,workbuf,DW_TAG_compile_unit); /* tag LEB128u */
|
WSAACHAR(pabbrev,DW_TAG_compile_unit); /* tag LEB128u */
|
||||||
WSAACHAR(pabbrev,workbuf,1); /* has children */
|
WSAACHAR(pabbrev,1); /* has children */
|
||||||
/* the following attributes and forms are all LEB128u values */
|
/* the following attributes and forms are all LEB128u values */
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_low_pc);
|
WSAACHAR(pabbrev,DW_AT_low_pc);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_addr);
|
WSAACHAR(pabbrev,DW_FORM_addr);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_high_pc);
|
WSAACHAR(pabbrev,DW_AT_high_pc);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_addr);
|
WSAACHAR(pabbrev,DW_FORM_addr);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_stmt_list);
|
WSAACHAR(pabbrev,DW_AT_stmt_list);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_data4);
|
WSAACHAR(pabbrev,DW_FORM_data4);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_name);
|
WSAACHAR(pabbrev,DW_AT_name);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_string);
|
WSAACHAR(pabbrev,DW_FORM_string);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_producer);
|
WSAACHAR(pabbrev,DW_AT_producer);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_string);
|
WSAACHAR(pabbrev,DW_FORM_string);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_language);
|
WSAACHAR(pabbrev,DW_AT_language);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_data2);
|
WSAACHAR(pabbrev,DW_FORM_data2);
|
||||||
WSAASHORT(pabbrev,workbuf,0); /* end of entry */
|
WSAASHORT(pabbrev,0); /* end of entry */
|
||||||
/* LEB128u usage same as above */
|
/* LEB128u usage same as above */
|
||||||
WSAACHAR(pabbrev,workbuf,2); /* entry number */
|
WSAACHAR(pabbrev,2); /* entry number */
|
||||||
WSAACHAR(pabbrev,workbuf,DW_TAG_subprogram);
|
WSAACHAR(pabbrev,DW_TAG_subprogram);
|
||||||
WSAACHAR(pabbrev,workbuf,0); /* no children */
|
WSAACHAR(pabbrev,0); /* no children */
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_low_pc);
|
WSAACHAR(pabbrev,DW_AT_low_pc);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_addr);
|
WSAACHAR(pabbrev,DW_FORM_addr);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_AT_frame_base);
|
WSAACHAR(pabbrev,DW_AT_frame_base);
|
||||||
WSAACHAR(pabbrev,workbuf,DW_FORM_data4);
|
WSAACHAR(pabbrev,DW_FORM_data4);
|
||||||
WSAASHORT(pabbrev,workbuf,0); /* end of entry */
|
WSAASHORT(pabbrev,0); /* end of entry */
|
||||||
abbrevlen = saalen = pabbrev->datalen;
|
abbrevlen = saalen = pabbrev->datalen;
|
||||||
abbrevbuf = pbuf = nasm_malloc(saalen);
|
abbrevbuf = pbuf = nasm_malloc(saalen);
|
||||||
saa_rnbytes(pabbrev, pbuf, saalen);
|
saa_rnbytes(pabbrev, pbuf, saalen);
|
||||||
@ -2109,37 +2107,37 @@ void dwarf64_generate(void)
|
|||||||
/* build line section */
|
/* build line section */
|
||||||
/* prolog */
|
/* prolog */
|
||||||
plines = saa_init(1L);
|
plines = saa_init(1L);
|
||||||
WSAACHAR(plines,workbuf,1); /* Minimum Instruction Length */
|
WSAACHAR(plines,1); /* Minimum Instruction Length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Initial value of 'is_stmt' */
|
WSAACHAR(plines,1); /* Initial value of 'is_stmt' */
|
||||||
WSAACHAR(plines,workbuf,line_base); /* Line Base */
|
WSAACHAR(plines,line_base); /* Line Base */
|
||||||
WSAACHAR(plines,workbuf,line_range); /* Line Range */
|
WSAACHAR(plines,line_range); /* Line Range */
|
||||||
WSAACHAR(plines,workbuf,opcode_base); /* Opcode Base */
|
WSAACHAR(plines,opcode_base); /* Opcode Base */
|
||||||
/* standard opcode lengths (# of LEB128u operands) */
|
/* standard opcode lengths (# of LEB128u operands) */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 1 length */
|
WSAACHAR(plines,0); /* Std opcode 1 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 2 length */
|
WSAACHAR(plines,1); /* Std opcode 2 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 3 length */
|
WSAACHAR(plines,1); /* Std opcode 3 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 4 length */
|
WSAACHAR(plines,1); /* Std opcode 4 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 5 length */
|
WSAACHAR(plines,1); /* Std opcode 5 length */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 6 length */
|
WSAACHAR(plines,0); /* Std opcode 6 length */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 7 length */
|
WSAACHAR(plines,0); /* Std opcode 7 length */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 8 length */
|
WSAACHAR(plines,0); /* Std opcode 8 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 9 length */
|
WSAACHAR(plines,1); /* Std opcode 9 length */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 10 length */
|
WSAACHAR(plines,0); /* Std opcode 10 length */
|
||||||
WSAACHAR(plines,workbuf,0); /* Std opcode 11 length */
|
WSAACHAR(plines,0); /* Std opcode 11 length */
|
||||||
WSAACHAR(plines,workbuf,1); /* Std opcode 12 length */
|
WSAACHAR(plines,1); /* Std opcode 12 length */
|
||||||
/* Directory Table */
|
/* Directory Table */
|
||||||
WSAACHAR(plines,workbuf,0); /* End of table */
|
WSAACHAR(plines,0); /* End of table */
|
||||||
/* File Name Table */
|
/* File Name Table */
|
||||||
ftentry = dwarf_flist;
|
ftentry = dwarf_flist;
|
||||||
for (indx = 0;indx<dwarf_numfiles;indx++)
|
for (indx = 0;indx<dwarf_numfiles;indx++)
|
||||||
{
|
{
|
||||||
saa_wbytes(plines, ftentry->filename, (int32_t)(strlen(ftentry->filename) + 1));
|
saa_wbytes(plines, ftentry->filename, (int32_t)(strlen(ftentry->filename) + 1));
|
||||||
WSAACHAR(plines,workbuf,0); /* directory LEB128u */
|
WSAACHAR(plines,0); /* directory LEB128u */
|
||||||
WSAACHAR(plines,workbuf,0); /* time LEB128u */
|
WSAACHAR(plines,0); /* time LEB128u */
|
||||||
WSAACHAR(plines,workbuf,0); /* size LEB128u */
|
WSAACHAR(plines,0); /* size LEB128u */
|
||||||
ftentry = ftentry->next;
|
ftentry = ftentry->next;
|
||||||
}
|
}
|
||||||
WSAACHAR(plines,workbuf,0); /* End of table */
|
WSAACHAR(plines,0); /* End of table */
|
||||||
linepoff = plines->datalen;
|
linepoff = plines->datalen;
|
||||||
linelen = linepoff + totlen + 10;
|
linelen = linepoff + totlen + 10;
|
||||||
linebuf = pbuf = nasm_malloc(linelen);
|
linebuf = pbuf = nasm_malloc(linelen);
|
||||||
@ -2157,9 +2155,9 @@ void dwarf64_generate(void)
|
|||||||
psect = dwarf_fsect;
|
psect = dwarf_fsect;
|
||||||
for (indx = 0; indx < dwarf_nsections; indx++)
|
for (indx = 0; indx < dwarf_nsections; indx++)
|
||||||
{
|
{
|
||||||
WSAADLONG(plinesrel,workbuf, linepoff);
|
WSAADLONG(plinesrel, linepoff);
|
||||||
WSAADLONG(plinesrel,workbuf, ((uint64_t) (psect->section + 2) << 32) + R_X86_64_64);
|
WSAADLONG(plinesrel, ((uint64_t) (psect->section + 2) << 32) + R_X86_64_64);
|
||||||
WSAADLONG(plinesrel,workbuf, (uint64_t) 0);
|
WSAADLONG(plinesrel, (uint64_t) 0);
|
||||||
plinep = psect->psaa;
|
plinep = psect->psaa;
|
||||||
saalen = plinep->datalen;
|
saalen = plinep->datalen;
|
||||||
saa_rnbytes(plinep, pbuf, saalen);
|
saa_rnbytes(plinep, pbuf, saalen);
|
||||||
@ -2294,10 +2292,10 @@ void dwarf64_findsect(const int index)
|
|||||||
dwarf_csect->section = index;
|
dwarf_csect->section = index;
|
||||||
dwarf_csect->next = 0;
|
dwarf_csect->next = 0;
|
||||||
/* set relocatable address at start of line program */
|
/* set relocatable address at start of line program */
|
||||||
WSAACHAR(plinep,workbuf,DW_LNS_extended_op);
|
WSAACHAR(plinep,DW_LNS_extended_op);
|
||||||
WSAACHAR(plinep,workbuf,9); /* operand length */
|
WSAACHAR(plinep,9); /* operand length */
|
||||||
WSAACHAR(plinep,workbuf,DW_LNE_set_address);
|
WSAACHAR(plinep,DW_LNE_set_address);
|
||||||
WSAADLONG(plinep,workbuf,0); /* Start Address */
|
WSAADLONG(plinep,0); /* Start Address */
|
||||||
/* if first entry */
|
/* if first entry */
|
||||||
if (!dwarf_fsect)
|
if (!dwarf_fsect)
|
||||||
{
|
{
|
||||||
|
45
wsaa.h
45
wsaa.h
@ -4,53 +4,56 @@
|
|||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
#include "nasmlib.h"
|
#include "nasmlib.h"
|
||||||
|
|
||||||
|
/* XXX: only LITTLE_ENDIAN is actually needed here. The way these
|
||||||
|
macros is written, it does not require that unaligned references
|
||||||
|
are permitted. */
|
||||||
#if X86_MEMORY
|
#if X86_MEMORY
|
||||||
|
|
||||||
#define WSAACHAR(s,p,v) \
|
#define WSAACHAR(s,v) \
|
||||||
do { \
|
do { \
|
||||||
*(uint8_t *)(p) = (v); \
|
uint8_t _wsb_v = (v); \
|
||||||
saa_wbytes(s, p, 1); \
|
saa_wbytes(s, &_wsb_v, 1); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define WSAASHORT(s,p,v) \
|
#define WSAASHORT(s,v) \
|
||||||
do { \
|
do { \
|
||||||
*(uint16_t *)(p) = (v); \
|
uint16_t _wss_v = (v); \
|
||||||
saa_wbytes(s, p, 2); \
|
saa_wbytes(s, &_wss_v, 2); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define WSAALONG(s,p,v) \
|
#define WSAALONG(s,v) \
|
||||||
do { \
|
do { \
|
||||||
*(uint32_t *)(p) = (v); \
|
uint32_t _wsl_v = (v); \
|
||||||
saa_wbytes(s, p, 4); \
|
saa_wbytes(s, &_wsl_v, 4); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define WSAADLONG(s,p,v) \
|
#define WSAADLONG(s,v) \
|
||||||
do { \
|
do { \
|
||||||
*(uint64_t *)(p) = (v); \
|
uint64_t _wsq_v = (v); \
|
||||||
saa_wbytes(s, p, 8); \
|
saa_wbytes(s, &_wsq_v, 8); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#else /* !X86_MEMORY */
|
#else /* !X86_MEMORY */
|
||||||
|
|
||||||
#define WSAACHAR(s,p,v) \
|
#define WSAACHAR(s,v) \
|
||||||
do { \
|
do { \
|
||||||
*(uint8_t *)(p) = (v); \
|
uint8_t _wsb_v = (v); \
|
||||||
saa_wbytes(s, p, 1); \
|
saa_wbytes(s, &_wsb_v, 1); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define WSAASHORT(s,p,v) \
|
#define WSAASHORT(s,v) \
|
||||||
do { \
|
do { \
|
||||||
uint16_t _wss_v = (v); \
|
uint16_t _wss_v = (v); \
|
||||||
uint8_t *_wss_p = (uint8_t *)(p); \
|
uint8_t _wss_p[2]; \
|
||||||
_wss_p[0] = _wss_v; \
|
_wss_p[0] = _wss_v; \
|
||||||
_wss_p[1] = _wss_v >> 8; \
|
_wss_p[1] = _wss_v >> 8; \
|
||||||
saa_wbytes(s, _wss_p, 2); \
|
saa_wbytes(s, _wss_p, 2); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define WSAALONG(s,p,v) \
|
#define WSAALONG(s,v) \
|
||||||
do { \
|
do { \
|
||||||
uint32_t _wsl_v = (v); \
|
uint32_t _wsl_v = (v); \
|
||||||
uint8_t *_wsl_p = (uint8_t *)(p); \
|
uint8_t _wsl_p[4]; \
|
||||||
_wsl_p[0] = _wsl_v; \
|
_wsl_p[0] = _wsl_v; \
|
||||||
_wsl_p[1] = _wsl_v >> 8; \
|
_wsl_p[1] = _wsl_v >> 8; \
|
||||||
_wsl_p[2] = _wsl_v >> 16; \
|
_wsl_p[2] = _wsl_v >> 16; \
|
||||||
@ -58,10 +61,10 @@
|
|||||||
saa_wbytes(s, _wsl_p, 4); \
|
saa_wbytes(s, _wsl_p, 4); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define WSAADLONG(s,p,v) \
|
#define WSAADLONG(s,v) \
|
||||||
do { \
|
do { \
|
||||||
uint64_t _wsq_v = (v); \
|
uint64_t _wsq_v = (v); \
|
||||||
uint8_t *_wsq_p = (uint8_t *)(p); \
|
uint8_t _wsq_p[8]; \
|
||||||
_wsq_p[0] = _wsq_v; \
|
_wsq_p[0] = _wsq_v; \
|
||||||
_wsq_p[1] = _wsq_v >> 8; \
|
_wsq_p[1] = _wsq_v >> 8; \
|
||||||
_wsq_p[2] = _wsq_v >> 16; \
|
_wsq_p[2] = _wsq_v >> 16; \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user