diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2014-09-15 01:36:12 +0400 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2014-09-21 13:03:26 +0400 |
commit | c24568b0b0e5ca91e6326bbba5d02c90458fde86 (patch) | |
tree | 0a77d0c6e4cebf0543e595b3f1b3a8d34633ae6e | |
parent | 500dd5461cbce5e645039ac7472a3c7e772af726 (diff) | |
download | nasm-c24568b0b0e5ca91e6326bbba5d02c90458fde86.tar.gz |
output: elf -- Move common structures into outelf.h header
All Elf formats we're supporting at the moment have
are using same structures, move them into a header
and name then with elf_ prefix.
This makes a few fields to carry 64 bit integers while
in former Elf32|x formats they can be 32 bit wide, but
I think it's acceptable tradeoff.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r-- | output/outelf.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/output/outelf.h b/output/outelf.h index 62677215..4d6db5d7 100644 --- a/output/outelf.h +++ b/output/outelf.h @@ -38,6 +38,8 @@ #define OUTPUT_OUTELF_H #include "output/elf.h" +#include "rbtree.h" +#include "saa.h" /* symbol binding */ #define SYM_GLOBAL ELF32_ST_MKBIND(STB_GLOBAL) @@ -118,4 +120,41 @@ void elf_section_attrib(char *name, char *attr, int pass, WRITELONG(p, n_value); \ } while (0) +struct elf_reloc { + struct elf_reloc *next; + int64_t address; /* relative to _start_ of section */ + int64_t symbol; /* symbol index */ + int64_t offset; /* symbol addend */ + int type; /* type of relocation */ +}; + +struct elf_symbol { + struct rbtree symv; /* symbol value and symbol rbtree */ + int32_t strpos; /* string table position of name */ + int32_t section; /* section ID of the symbol */ + int type; /* symbol type */ + int other; /* symbol visibility */ + int32_t size; /* size of symbol */ + int32_t globnum; /* symbol table offset if global */ + struct elf_symbol *nextfwd; /* list of unresolved-size symbols */ + char *name; /* used temporarily if in above list */ +}; + +struct elf_section { + struct SAA *data; + uint64_t len; + uint64_t size; + uint64_t nrelocs; + int32_t index; + int type; /* SHT_PROGBITS or SHT_NOBITS */ + uint64_t align; /* alignment: power of two */ + uint64_t flags; /* section flags */ + char *name; + struct SAA *rel; + uint64_t rellen; + struct elf_reloc *head; + struct elf_reloc **tail; + struct rbtree *gsyms; /* global symbols in section */ +}; + #endif /* OUTPUT_OUTELF_H */ |