diff options
author | Charles Crayne <chuck@thor.crayne.org> | 2007-10-21 14:21:43 -0700 |
---|---|---|
committer | Charles Crayne <chuck@thor.crayne.org> | 2007-10-21 14:21:43 -0700 |
commit | b0e1d423dd3e174a92a1d7256aec4e9b701ece3c (patch) | |
tree | 5fa33d58cb1ad04fdf3d0b47ba537998a300204e /output/outelf64.c | |
parent | 449e04b33036f4cca13526c2e62070aa8421ca7e (diff) | |
download | nasm-b0e1d423dd3e174a92a1d7256aec4e9b701ece3c.tar.gz nasm-b0e1d423dd3e174a92a1d7256aec4e9b701ece3c.tar.bz2 nasm-b0e1d423dd3e174a92a1d7256aec4e9b701ece3c.zip |
Clean up elf symbol table section
Diffstat (limited to 'output/outelf64.c')
-rw-r--r-- | output/outelf64.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/output/outelf64.c b/output/outelf64.c index 6ee5634..39da33f 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -67,7 +67,7 @@ typedef struct struct Reloc { struct Reloc *next; int64_t address; /* relative to _start_ of section */ - int64_t symbol; /* ELF symbol info thingy */ + int64_t symbol; /* symbol index */ int type; /* type of relocation */ }; @@ -676,13 +676,13 @@ static void elf_add_reloc(struct Section *sect, int32_t segment, int type) r->address = sect->len; if (segment == NO_SEG) - r->symbol = 2; + r->symbol = 0; else { int i; r->symbol = 0; for (i = 0; i < nsects; i++) if (segment == sects[i]->index) - r->symbol = i + 3; + r->symbol = i + 2; if (!r->symbol) r->symbol = GLOBAL_TEMP_BASE + raa_read(bsym, segment); } @@ -1145,7 +1145,7 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) * Next, an entry for the file name. */ p = entry; - WRITELONG(p, 1); /* we know it's 1st thing in strtab */ + WRITELONG(p, 1); /* we know it's 1st entry in strtab */ WRITESHORT(p, 4); /* type FILE */ WRITESHORT(p, SHN_ABS); WRITEDLONG(p, (uint64_t) 0); /* no value */ @@ -1158,11 +1158,11 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) * Now some standard symbols defining the segments, for relocation * purposes. */ - for (i = 1; i <= nsects + 1; i++) { + for (i = 1; i <= nsects; i++) { p = entry; WRITELONG(p, 0); /* no symbol name */ - WRITESHORT(p, 3); /* local section-type thing */ - WRITESHORT(p, (i == 1 ? SHN_ABS : i - 1)); /* the section id */ + WRITESHORT(p, 3); /* type, binding, and visibility */ + WRITESHORT(p, i); /* section id */ WRITEDLONG(p, (uint64_t) 0); /* offset zero */ WRITEDLONG(p, (uint64_t) 0); /* size zero */ saa_wbytes(s, entry, 24L); @@ -1179,8 +1179,8 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) continue; p = entry; WRITELONG(p, sym->strpos); - WRITECHAR(p, sym->type); /* local non-typed thing */ - WRITECHAR(p, sym->other); + WRITECHAR(p, sym->type); /* type and binding */ + WRITECHAR(p, sym->other); /* visibility */ WRITESHORT(p, sym->section); WRITEDLONG(p, (int64_t)sym->value); WRITEDLONG(p, (int64_t)sym->size); @@ -1198,8 +1198,8 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local) continue; p = entry; WRITELONG(p, sym->strpos); - WRITECHAR(p, sym->type); /* global non-typed thing */ - WRITECHAR(p, sym->other); + WRITECHAR(p, sym->type); /* type and binding */ + WRITECHAR(p, sym->other); /* visibility */ WRITESHORT(p, sym->section); WRITEDLONG(p, (int64_t)sym->value); WRITEDLONG(p, (int64_t)sym->size); @@ -1225,7 +1225,7 @@ static struct SAA *elf_build_reltab(int32_t *len, struct Reloc *r) int64_t sym = r->symbol; if (sym >= GLOBAL_TEMP_BASE) - sym += -GLOBAL_TEMP_BASE + (nsects + 3) + nlocals; + sym += -GLOBAL_TEMP_BASE + (nsects + 2) + nlocals; p = entry; WRITEDLONG(p, r->address); |