mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-08-23 10:33:50 -04:00
output/outelf32.c: tab-space cleanup
Together with a small style nitpicking. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
82a440da6d
commit
6ae5903676
@ -562,8 +562,7 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset,
|
|||||||
if (err)
|
if (err)
|
||||||
nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
|
nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
|
||||||
" valid number", special);
|
" valid number", special);
|
||||||
else if ((sym->symv.key | (sym->symv.key - 1))
|
else if ((sym->symv.key | (sym->symv.key - 1)) != 2 * sym->symv.key - 1)
|
||||||
!= 2 * sym->symv.key - 1)
|
|
||||||
nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
|
nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
|
||||||
" power of two", special);
|
" power of two", special);
|
||||||
}
|
}
|
||||||
@ -1081,7 +1080,6 @@ static void elf_write(void)
|
|||||||
elf_section_header(p - shstrtab, SHT_REL, 0, sects[i]->rel, true,
|
elf_section_header(p - shstrtab, SHT_REL, 0, sects[i]->rel, true,
|
||||||
sects[i]->rellen, sec_symtab, i + 1, 4, 8);
|
sects[i]->rellen, sec_symtab, i + 1, 4, 8);
|
||||||
p += strlen(p) + 1;
|
p += strlen(p) + 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (of_elf32.current_dfmt == &df_stabs) {
|
if (of_elf32.current_dfmt == &df_stabs) {
|
||||||
@ -1504,9 +1502,11 @@ static void stabs32_linenum(const char *filename, int32_t linenumber,
|
|||||||
strcpy(stabs_filename, filename);
|
strcpy(stabs_filename, filename);
|
||||||
} else {
|
} else {
|
||||||
if (strcmp(stabs_filename, filename)) {
|
if (strcmp(stabs_filename, filename)) {
|
||||||
/* yep, a memory leak...this program is one-shot anyway, so who cares...
|
/*
|
||||||
in fact, this leak comes in quite handy to maintain a list of files
|
* yep, a memory leak...this program is one-shot anyway, so who cares...
|
||||||
encountered so far in the symbol lines... */
|
* in fact, this leak comes in quite handy to maintain a list of files
|
||||||
|
* encountered so far in the symbol lines...
|
||||||
|
*/
|
||||||
|
|
||||||
/* why not nasm_free(stabs_filename); we're done with the old one */
|
/* why not nasm_free(stabs_filename); we're done with the old one */
|
||||||
|
|
||||||
@ -1686,8 +1686,9 @@ static void stabs32_generate(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* worst case size of the stab buffer would be:
|
/*
|
||||||
the sourcefiles changes each line, which would mean 1 SOL, 1 SYMLIN per line
|
* worst case size of the stab buffer would be:
|
||||||
|
* the sourcefiles changes each line, which would mean 1 SOL, 1 SYMLIN per line
|
||||||
*/
|
*/
|
||||||
sbuf =
|
sbuf =
|
||||||
(uint8_t *)nasm_malloc((numlinestabs * 2 + 3) *
|
(uint8_t *)nasm_malloc((numlinestabs * 2 + 3) *
|
||||||
@ -1710,9 +1711,10 @@ static void stabs32_generate(void)
|
|||||||
numstabs = 0;
|
numstabs = 0;
|
||||||
|
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
/* this is the first stab, its strx points to the filename of the
|
/*
|
||||||
the source-file, the n_desc field should be set to the number
|
* this is the first stab, its strx points to the filename of the
|
||||||
of remaining stabs
|
* the source-file, the n_desc field should be set to the number
|
||||||
|
* of remaining stabs
|
||||||
*/
|
*/
|
||||||
WRITE_STAB(sptr, fileidx[0], 0, 0, 0, strlen(allfiles[0] + 12));
|
WRITE_STAB(sptr, fileidx[0], 0, 0, 0, strlen(allfiles[0] + 12));
|
||||||
|
|
||||||
@ -1721,9 +1723,11 @@ static void stabs32_generate(void)
|
|||||||
|
|
||||||
/* relocation table entry */
|
/* relocation table entry */
|
||||||
|
|
||||||
/* Since the symbol table has two entries before */
|
/*
|
||||||
/* the section symbols, the index in the info.section */
|
* Since the symbol table has two entries before
|
||||||
/* member must be adjusted by adding 2 */
|
* the section symbols, the index in the info.section
|
||||||
|
* member must be adjusted by adding 2
|
||||||
|
*/
|
||||||
|
|
||||||
WRITELONG(rptr, (sptr - sbuf) - 4);
|
WRITELONG(rptr, (sptr - sbuf) - 4);
|
||||||
WRITELONG(rptr, ((ptr->info.section + 2) << 8) | R_386_32);
|
WRITELONG(rptr, ((ptr->info.section + 2) << 8) | R_386_32);
|
||||||
@ -1817,47 +1821,40 @@ static void dwarf32_output(int type, void *param)
|
|||||||
(void)type;
|
(void)type;
|
||||||
|
|
||||||
s = (struct symlininfo *)param;
|
s = (struct symlininfo *)param;
|
||||||
|
|
||||||
/* line number info is only gathered for executable sections */
|
/* line number info is only gathered for executable sections */
|
||||||
if (!(sects[s->section]->flags & SHF_EXECINSTR))
|
if (!(sects[s->section]->flags & SHF_EXECINSTR))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Check if section index has changed */
|
/* Check if section index has changed */
|
||||||
if (!(dwarf_csect && (dwarf_csect->section) == (s->section)))
|
if (!(dwarf_csect && (dwarf_csect->section) == (s->section)))
|
||||||
{
|
|
||||||
dwarf32_findsect(s->section);
|
dwarf32_findsect(s->section);
|
||||||
}
|
|
||||||
/* do nothing unless line or file has changed */
|
/* do nothing unless line or file has changed */
|
||||||
if (debug_immcall)
|
if (debug_immcall) {
|
||||||
{
|
|
||||||
ln = currentline - dwarf_csect->line;
|
ln = currentline - dwarf_csect->line;
|
||||||
aa = s->offset - dwarf_csect->offset;
|
aa = s->offset - dwarf_csect->offset;
|
||||||
inx = dwarf_clist->line;
|
inx = dwarf_clist->line;
|
||||||
plinep = dwarf_csect->psaa;
|
plinep = dwarf_csect->psaa;
|
||||||
/* check for file change */
|
/* check for file change */
|
||||||
if (!(inx == dwarf_csect->file))
|
if (!(inx == dwarf_csect->file)) {
|
||||||
{
|
|
||||||
saa_write8(plinep,DW_LNS_set_file);
|
saa_write8(plinep,DW_LNS_set_file);
|
||||||
saa_write8(plinep,inx);
|
saa_write8(plinep,inx);
|
||||||
dwarf_csect->file = inx;
|
dwarf_csect->file = inx;
|
||||||
}
|
}
|
||||||
/* check for line change */
|
/* check for line change */
|
||||||
if (ln)
|
if (ln) {
|
||||||
{
|
|
||||||
/* test if in range of special op code */
|
/* test if in range of special op code */
|
||||||
maxln = line_base + line_range;
|
maxln = line_base + line_range;
|
||||||
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) {
|
||||||
{
|
|
||||||
saa_write8(plinep,soc);
|
saa_write8(plinep,soc);
|
||||||
}
|
} else {
|
||||||
else
|
if (ln) {
|
||||||
{
|
|
||||||
if (ln)
|
|
||||||
{
|
|
||||||
saa_write8(plinep,DW_LNS_advance_line);
|
saa_write8(plinep,DW_LNS_advance_line);
|
||||||
saa_wleb128s(plinep,ln);
|
saa_wleb128s(plinep,ln);
|
||||||
}
|
}
|
||||||
if (aa)
|
if (aa) {
|
||||||
{
|
|
||||||
saa_write8(plinep,DW_LNS_advance_pc);
|
saa_write8(plinep,DW_LNS_advance_pc);
|
||||||
saa_wleb128u(plinep,aa);
|
saa_wleb128u(plinep,aa);
|
||||||
}
|
}
|
||||||
@ -1897,8 +1894,7 @@ static void dwarf32_generate(void)
|
|||||||
psect = dwarf_fsect;
|
psect = dwarf_fsect;
|
||||||
totlen = 0;
|
totlen = 0;
|
||||||
highaddr = 0;
|
highaddr = 0;
|
||||||
for (indx = 0; indx < dwarf_nsections; indx++)
|
for (indx = 0; indx < dwarf_nsections; indx++) {
|
||||||
{
|
|
||||||
plinep = psect->psaa;
|
plinep = psect->psaa;
|
||||||
/* Line Number Program Epilogue */
|
/* Line Number Program Epilogue */
|
||||||
saa_write8(plinep,2); /* std op 2 */
|
saa_write8(plinep,2); /* std op 2 */
|
||||||
@ -2049,8 +2045,7 @@ static void dwarf32_generate(void)
|
|||||||
saa_write8(plines,0); /* End of table */
|
saa_write8(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));
|
||||||
saa_write8(plines,0); /* directory LEB128u */
|
saa_write8(plines,0); /* directory LEB128u */
|
||||||
saa_write8(plines,0); /* time LEB128u */
|
saa_write8(plines,0); /* time LEB128u */
|
||||||
@ -2073,8 +2068,7 @@ static void dwarf32_generate(void)
|
|||||||
linepoff += 13;
|
linepoff += 13;
|
||||||
plinesrel = saa_init(1L);
|
plinesrel = saa_init(1L);
|
||||||
psect = dwarf_fsect;
|
psect = dwarf_fsect;
|
||||||
for (indx = 0; indx < dwarf_nsections; indx++)
|
for (indx = 0; indx < dwarf_nsections; indx++) {
|
||||||
{
|
|
||||||
saa_write32(plinesrel, linepoff);
|
saa_write32(plinesrel, linepoff);
|
||||||
saa_write32(plinesrel, ((uint32_t) (psect->section + 2) << 8) + R_386_32);
|
saa_write32(plinesrel, ((uint32_t) (psect->section + 2) << 8) + R_386_32);
|
||||||
saa_write32(plinesrel, (uint32_t) 0);
|
saa_write32(plinesrel, (uint32_t) 0);
|
||||||
@ -2136,18 +2130,15 @@ static void dwarf32_findfile(const char * fname)
|
|||||||
struct linelist *match;
|
struct linelist *match;
|
||||||
|
|
||||||
/* return if fname is current file name */
|
/* return if fname is current file name */
|
||||||
if (dwarf_clist && !(strcmp(fname, dwarf_clist->filename))) return;
|
if (dwarf_clist && !(strcmp(fname, dwarf_clist->filename)))
|
||||||
|
return;
|
||||||
/* search for match */
|
/* search for match */
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
match = 0;
|
match = 0;
|
||||||
if (dwarf_flist)
|
if (dwarf_flist) {
|
||||||
{
|
|
||||||
match = dwarf_flist;
|
match = dwarf_flist;
|
||||||
for (finx = 0; finx < dwarf_numfiles; finx++)
|
for (finx = 0; finx < dwarf_numfiles; finx++) {
|
||||||
{
|
if (!(strcmp(fname, match->filename))) {
|
||||||
if (!(strcmp(fname, match->filename)))
|
|
||||||
{
|
|
||||||
dwarf_clist = match;
|
dwarf_clist = match;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2160,42 +2151,32 @@ static void dwarf32_findfile(const char * fname)
|
|||||||
dwarf_clist->filename = nasm_malloc(strlen(fname) + 1);
|
dwarf_clist->filename = nasm_malloc(strlen(fname) + 1);
|
||||||
strcpy(dwarf_clist->filename,fname);
|
strcpy(dwarf_clist->filename,fname);
|
||||||
dwarf_clist->next = 0;
|
dwarf_clist->next = 0;
|
||||||
/* if first entry */
|
if (!dwarf_flist) { /* if first entry */
|
||||||
if (!dwarf_flist)
|
|
||||||
{
|
|
||||||
dwarf_flist = dwarf_elist = dwarf_clist;
|
dwarf_flist = dwarf_elist = dwarf_clist;
|
||||||
dwarf_clist->last = 0;
|
dwarf_clist->last = 0;
|
||||||
}
|
} else { /* chain to previous entry */
|
||||||
/* chain to previous entry */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dwarf_elist->next = dwarf_clist;
|
dwarf_elist->next = dwarf_clist;
|
||||||
dwarf_elist = dwarf_clist;
|
dwarf_elist = dwarf_clist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* */
|
|
||||||
static void dwarf32_findsect(const int index)
|
static void dwarf32_findsect(const int index)
|
||||||
{
|
{
|
||||||
int sinx;
|
int sinx;
|
||||||
struct sectlist *match;
|
struct sectlist *match;
|
||||||
struct SAA *plinep;
|
struct SAA *plinep;
|
||||||
|
|
||||||
/* return if index is current section index */
|
/* return if index is current section index */
|
||||||
if (dwarf_csect && (dwarf_csect->section == index))
|
if (dwarf_csect && (dwarf_csect->section == index))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
/* search for match */
|
/* search for match */
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
match = 0;
|
match = 0;
|
||||||
if (dwarf_fsect)
|
if (dwarf_fsect) {
|
||||||
{
|
|
||||||
match = dwarf_fsect;
|
match = dwarf_fsect;
|
||||||
for (sinx = 0; sinx < dwarf_nsections; sinx++)
|
for (sinx = 0; sinx < dwarf_nsections; sinx++) {
|
||||||
{
|
if ((match->section == index)) {
|
||||||
if ((match->section == index))
|
|
||||||
{
|
|
||||||
dwarf_csect = match;
|
dwarf_csect = match;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2216,15 +2197,11 @@ static void dwarf32_findsect(const int index)
|
|||||||
saa_write8(plinep,5); /* operand length */
|
saa_write8(plinep,5); /* operand length */
|
||||||
saa_write8(plinep,DW_LNE_set_address);
|
saa_write8(plinep,DW_LNE_set_address);
|
||||||
saa_write32(plinep,0); /* Start Address */
|
saa_write32(plinep,0); /* Start Address */
|
||||||
/* if first entry */
|
|
||||||
if (!dwarf_fsect)
|
if (!dwarf_fsect) { /* if first entry */
|
||||||
{
|
|
||||||
dwarf_fsect = dwarf_esect = dwarf_csect;
|
dwarf_fsect = dwarf_esect = dwarf_csect;
|
||||||
dwarf_csect->last = 0;
|
dwarf_csect->last = 0;
|
||||||
}
|
} else { /* chain to previous entry */
|
||||||
/* chain to previous entry */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dwarf_esect->next = dwarf_csect;
|
dwarf_esect->next = dwarf_csect;
|
||||||
dwarf_esect = dwarf_csect;
|
dwarf_esect = dwarf_csect;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user