From f134cc63da27106365a3e735c9c375ed0326a2a0 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Fri, 9 Apr 2010 14:57:28 +0400 Subject: [PATCH] Elf: Some unification snippets for 32/64 bit versions Nothing serious, comments and style movements. Signed-off-by: Cyrill Gorcunov --- output/outelf32.c | 11 +++++------ output/outelf64.c | 13 ++++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index cf749f96..4a99ec97 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -341,7 +341,6 @@ static int elf_make_section(char *name, int type, int flags, int align) return nsects - 1; } - static int32_t elf_section_names(char *name, int pass, int *bits) { char *p; @@ -394,7 +393,7 @@ static int32_t elf_section_names(char *name, int pass, int *bits) if ((type && sects[i]->type != type) || (align && sects[i]->align != align) || (flags_and && ((sects[i]->flags & flags_and) != flags_or))) - nasm_error(ERR_WARNING, "section attributes ignored on" + nasm_error(ERR_WARNING, "incompatible section attributes ignored on" " redeclaration of section `%s'", name); } @@ -1008,12 +1007,12 @@ static void elf_write(void) /* .symtab */ elf_section_header(p - shstrtab, SHT_SYMTAB, 0, symtab, true, - symtablen, sec_strtab, symtablocal, 4, 16); + symtablen, sec_strtab, symtablocal, 4, 16); p += strlen(p) + 1; /* .strtab */ elf_section_header(p - shstrtab, SHT_STRTAB, 0, strs, true, - strslen, 0, 0, 1, 0); + strslen, 0, 0, 1, 0); p += strlen(p) + 1; /* The relocation sections */ @@ -1042,7 +1041,7 @@ static void elf_write(void) /* link -> symtable info -> section to refer to */ elf_section_header(p - shstrtab, SHT_REL, 0, stabrelbuf, false, - stabrellen, sec_symtab, sec_stab, 4, 8); + stabrellen, sec_symtab, sec_stab, 4, 8); p += strlen(p) + 1; } } else if (of_elf32.current_dfmt == &df_dwarf) { @@ -1551,7 +1550,7 @@ static void stabs32_output(int type, void *param) if (debug_immcall) { s = (struct symlininfo *)param; if (!(sects[s->section]->flags & SHF_EXECINSTR)) - return; /* we are only interested in the text stuff */ + return; /* line info is only collected for executable sections */ numlinestabs++; el = (struct linelist *)nasm_malloc(sizeof(struct linelist)); el->info.offset = s->offset; diff --git a/output/outelf64.c b/output/outelf64.c index 10ce75c0..15785a38 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -60,6 +60,9 @@ #ifdef OF_ELF64 +/* + * Relocation types. + */ struct Reloc { struct Reloc *next; int64_t address; /* relative to _start_ of section */ @@ -104,7 +107,7 @@ static char *shstrtab; static int shstrtablen, shstrtabsize; static struct SAA *syms; -static uint32_t nlocals, nglobs, ndebugs; +static uint32_t nlocals, nglobs, ndebugs; /* Symbol counts */ static int32_t def_seg; @@ -245,7 +248,7 @@ static void elf_init(void) bsym = raa_init(); strs = saa_init(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); shstrtab = NULL; shstrtablen = shstrtabsize = 0;; @@ -762,7 +765,8 @@ static void elf_out(int32_t segto, const void *data, i = nsects - 1; } } - /* invoke current debug_output routine */ + + /* again some stabs debugging stuff */ if (of_elf64.current_dfmt) { sinfo.offset = s->len; sinfo.section = i; @@ -1132,8 +1136,7 @@ static void elf_write(void) stabrellen, symtabsection, sec_stab, 4, 16); p += strlen(p) + 1; } - } - else if (of_elf64.current_dfmt == &df_dwarf) { + } else if (of_elf64.current_dfmt == &df_dwarf) { /* for dwarf debugging information, create the ten dwarf sections */ /* this function call creates the dwarf sections in memory */ -- 2.11.4.GIT