0
0
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:
Cyrill Gorcunov 2009-09-03 20:02:33 +04:00
parent 82a440da6d
commit 6ae5903676

View File

@ -562,8 +562,7 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset,
if (err)
nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
" valid number", special);
else if ((sym->symv.key | (sym->symv.key - 1))
!= 2 * sym->symv.key - 1)
else if ((sym->symv.key | (sym->symv.key - 1)) != 2 * sym->symv.key - 1)
nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a"
" 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,
sects[i]->rellen, sec_symtab, i + 1, 4, 8);
p += strlen(p) + 1;
}
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);
} else {
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
encountered so far in the symbol lines... */
/*
* 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
* encountered so far in the symbol lines...
*/
/* why not nasm_free(stabs_filename); we're done with the old one */
@ -1631,7 +1631,7 @@ static void stabs32_output(int type, void *param)
}
#define WRITE_STAB(p,n_strx,n_type,n_other,n_desc,n_value) \
do {\
do { \
WRITELONG(p,n_strx); \
WRITECHAR(p,n_type); \
WRITECHAR(p,n_other); \
@ -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 =
(uint8_t *)nasm_malloc((numlinestabs * 2 + 3) *
@ -1710,9 +1711,10 @@ static void stabs32_generate(void)
numstabs = 0;
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
of remaining stabs
/*
* 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
* of remaining stabs
*/
WRITE_STAB(sptr, fileidx[0], 0, 0, 0, strlen(allfiles[0] + 12));
@ -1721,9 +1723,11 @@ static void stabs32_generate(void)
/* relocation table entry */
/* Since the symbol table has two entries before */
/* the section symbols, the index in the info.section */
/* member must be adjusted by adding 2 */
/*
* Since the symbol table has two entries before
* the section symbols, the index in the info.section
* member must be adjusted by adding 2
*/
WRITELONG(rptr, (sptr - sbuf) - 4);
WRITELONG(rptr, ((ptr->info.section + 2) << 8) | R_386_32);
@ -1817,47 +1821,40 @@ static void dwarf32_output(int type, void *param)
(void)type;
s = (struct symlininfo *)param;
/* line number info is only gathered for executable sections */
if (!(sects[s->section]->flags & SHF_EXECINSTR))
return;
/* Check if section index has changed */
if (!(dwarf_csect && (dwarf_csect->section) == (s->section)))
{
dwarf32_findsect(s->section);
}
/* do nothing unless line or file has changed */
if (debug_immcall)
{
if (debug_immcall) {
ln = currentline - dwarf_csect->line;
aa = s->offset - dwarf_csect->offset;
inx = dwarf_clist->line;
plinep = dwarf_csect->psaa;
/* check for file change */
if (!(inx == dwarf_csect->file))
{
if (!(inx == dwarf_csect->file)) {
saa_write8(plinep,DW_LNS_set_file);
saa_write8(plinep,inx);
dwarf_csect->file = inx;
}
/* check for line change */
if (ln)
{
if (ln) {
/* test if in range of special op code */
maxln = line_base + line_range;
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);
}
else
{
if (ln)
{
} else {
if (ln) {
saa_write8(plinep,DW_LNS_advance_line);
saa_wleb128s(plinep,ln);
}
if (aa)
{
if (aa) {
saa_write8(plinep,DW_LNS_advance_pc);
saa_wleb128u(plinep,aa);
}
@ -1897,8 +1894,7 @@ static void dwarf32_generate(void)
psect = dwarf_fsect;
totlen = 0;
highaddr = 0;
for (indx = 0; indx < dwarf_nsections; indx++)
{
for (indx = 0; indx < dwarf_nsections; indx++) {
plinep = psect->psaa;
/* Line Number Program Epilogue */
saa_write8(plinep,2); /* std op 2 */
@ -2049,8 +2045,7 @@ static void dwarf32_generate(void)
saa_write8(plines,0); /* End of table */
/* File Name Table */
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_write8(plines,0); /* directory LEB128u */
saa_write8(plines,0); /* time LEB128u */
@ -2073,8 +2068,7 @@ static void dwarf32_generate(void)
linepoff += 13;
plinesrel = saa_init(1L);
psect = dwarf_fsect;
for (indx = 0; indx < dwarf_nsections; indx++)
{
for (indx = 0; indx < dwarf_nsections; indx++) {
saa_write32(plinesrel, linepoff);
saa_write32(plinesrel, ((uint32_t) (psect->section + 2) << 8) + R_386_32);
saa_write32(plinesrel, (uint32_t) 0);
@ -2136,18 +2130,15 @@ static void dwarf32_findfile(const char * fname)
struct linelist *match;
/* 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 */
else
{
else {
match = 0;
if (dwarf_flist)
{
if (dwarf_flist) {
match = dwarf_flist;
for (finx = 0; finx < dwarf_numfiles; finx++)
{
if (!(strcmp(fname, match->filename)))
{
for (finx = 0; finx < dwarf_numfiles; finx++) {
if (!(strcmp(fname, match->filename))) {
dwarf_clist = match;
return;
}
@ -2160,42 +2151,32 @@ static void dwarf32_findfile(const char * fname)
dwarf_clist->filename = nasm_malloc(strlen(fname) + 1);
strcpy(dwarf_clist->filename,fname);
dwarf_clist->next = 0;
/* if first entry */
if (!dwarf_flist)
{
if (!dwarf_flist) { /* if first entry */
dwarf_flist = dwarf_elist = dwarf_clist;
dwarf_clist->last = 0;
}
/* chain to previous entry */
else
{
} else { /* chain to previous entry */
dwarf_elist->next = dwarf_clist;
dwarf_elist = dwarf_clist;
}
}
}
/* */
static void dwarf32_findsect(const int index)
{
int sinx;
struct sectlist *match;
struct SAA *plinep;
/* return if index is current section index */
if (dwarf_csect && (dwarf_csect->section == index))
{
return;
}
/* search for match */
else
{
else {
match = 0;
if (dwarf_fsect)
{
if (dwarf_fsect) {
match = dwarf_fsect;
for (sinx = 0; sinx < dwarf_nsections; sinx++)
{
if ((match->section == index))
{
for (sinx = 0; sinx < dwarf_nsections; sinx++) {
if ((match->section == index)) {
dwarf_csect = match;
return;
}
@ -2216,15 +2197,11 @@ static void dwarf32_findsect(const int index)
saa_write8(plinep,5); /* operand length */
saa_write8(plinep,DW_LNE_set_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_csect->last = 0;
}
/* chain to previous entry */
else
{
} else { /* chain to previous entry */
dwarf_esect->next = dwarf_csect;
dwarf_esect = dwarf_csect;
}