From 583f505155b0baa48ab4e5a4b022af73fa2dd06b Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Sun, 13 Mar 2016 01:04:55 +0300 Subject: [PATCH] out: Elf64, Elf32, Elfx32 -- Style merge Signed-off-by: Cyrill Gorcunov --- output/outelf32.c | 15 ++++----------- output/outelf64.c | 9 ++------- output/outelfx32.c | 9 ++------- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 0e680c7e..ab62b6e9 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -964,7 +964,7 @@ static void elf_write(void) * Now output the section header table. */ - elf_foffs = 0x40 + 0x28 * nsections; + elf_foffs = 0x40 + sizeof(Elf32_Shdr) * nsections; align = ALIGN(elf_foffs, SEC_FILEALIGN) - elf_foffs; elf_foffs += align; elf_nsect = 0; @@ -1153,7 +1153,6 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) * dwarf needs symbols for debug sections * which are relocation targets. */ - /*** fix for 32 bit ***/ if (dfmt == &df_dwarf) { dwarf_infosym = *local; p = entry; @@ -1374,8 +1373,7 @@ const struct ofmt of_elf32 = { elf_cleanup }; -/* again, the stabs debugging stuff (code) */ - +/* common debugging routines */ static void debug_typevalue(int32_t type) { int32_t stype, ssize; @@ -1445,11 +1443,9 @@ static void debug_typevalue(int32_t type) /* stabs debugging routines */ -static void stabs_linenum(const char *filename, int32_t linenumber, - int32_t segto) +static void stabs_linenum(const char *filename, int32_t linenumber, int32_t segto) { (void)segto; - if (!stabs_filename) { stabs_filename = (char *)nasm_malloc(strlen(filename) + 1); strcpy(stabs_filename, filename); @@ -1459,7 +1455,6 @@ static void stabs_linenum(const char *filename, int32_t linenumber, 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 */ stabs_filename = (char *)nasm_malloc(strlen(filename) + 1); @@ -1512,9 +1507,7 @@ static void stabs_generate(void) ptr = stabslines; - allfiles = (char **)nasm_malloc(numlinestabs * sizeof(char *)); - for (i = 0; i < numlinestabs; i++) - allfiles[i] = 0; + allfiles = (char **)nasm_zalloc(numlinestabs * sizeof(char *)); numfiles = 0; while (ptr) { if (numfiles == 0) { diff --git a/output/outelf64.c b/output/outelf64.c index 1f8247a5..7aed5a28 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -986,9 +986,7 @@ static void elf_write(void) add_sectname("", ".stab"); add_sectname("", ".stabstr"); add_sectname(".rel", ".stab"); - } - - else if (dfmt == &df_dwarf) { + } else if (dfmt == &df_dwarf) { /* the dwarf debug standard specifies the following ten sections, not all of which are currently implemented, although all of them are defined. */ @@ -1210,7 +1208,6 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) (*local)++; } - /* * Now the other local symbols. */ @@ -1552,7 +1549,6 @@ static void stabs_linenum(const char *filename, int32_t linenumber, int32_t segt currentline = linenumber; } - static void stabs_output(int type, void *param) { struct symlininfo *s; @@ -1991,8 +1987,7 @@ static void dwarf_generate(void) saa_write8(plines,0); /* End of table */ /* File Name Table */ ftentry = dwarf_flist; - for (indx = 0;indxfilename, (int32_t)(strlen(ftentry->filename) + 1)); saa_write8(plines,0); /* directory LEB128u */ saa_write8(plines,0); /* time LEB128u */ diff --git a/output/outelfx32.c b/output/outelfx32.c index ed949426..37d5dca1 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -949,9 +949,7 @@ static void elf_write(void) add_sectname("", ".stab"); add_sectname("", ".stabstr"); add_sectname(".rel", ".stab"); - } - - else if (dfmt == &df_dwarf) { + } else if (dfmt == &df_dwarf) { /* the dwarf debug standard specifies the following ten sections, not all of which are currently implemented, although all of them are defined. */ @@ -1172,7 +1170,6 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) (*local)++; } - /* * Now the other local symbols. */ @@ -1512,7 +1509,6 @@ static void stabs_linenum(const char *filename, int32_t linenumber, int32_t segt currentline = linenumber; } - static void stabs_output(int type, void *param) { struct symlininfo *s; @@ -1948,8 +1944,7 @@ static void dwarf_generate(void) saa_write8(plines,0); /* End of table */ /* File Name Table */ ftentry = dwarf_flist; - for (indx = 0;indxfilename, (int32_t)(strlen(ftentry->filename) + 1)); saa_write8(plines,0); /* directory LEB128u */ saa_write8(plines,0); /* time LEB128u */