summaryrefslogtreecommitdiff
path: root/output
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2012-11-16 22:57:07 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2012-11-16 22:57:07 +0400
commit5fa17e83985a0659427cd5e085ca4bd331c07f8c (patch)
tree27a128ed30a4f1b1919e048d3e5b4183808de4ed /output
parent7ce86b500c792b782b7b076f50b220fc62234954 (diff)
downloadnasm-5fa17e83985a0659427cd5e085ca4bd331c07f8c.tar.gz
nasm-5fa17e83985a0659427cd5e085ca4bd331c07f8c.tar.bz2
nasm-5fa17e83985a0659427cd5e085ca4bd331c07f8c.zip
output: Add more Elf unification
One day the elf output routines would be abstracted enough to be merged in one file. This patch simply removes some differences from elf32/64 code. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'output')
-rw-r--r--output/outelf32.c9
-rw-r--r--output/outelf64.c41
2 files changed, 24 insertions, 26 deletions
diff --git a/output/outelf32.c b/output/outelf32.c
index 9ef2457..00b3f5e 100644
--- a/output/outelf32.c
+++ b/output/outelf32.c
@@ -664,8 +664,9 @@ static int32_t elf_add_gsym_reloc(struct Section *sect,
s = sects[i];
break;
}
+
if (!s) {
- if (exact && offset != 0)
+ if (exact && offset)
nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol"
" for this reference");
else
@@ -1021,7 +1022,7 @@ static void elf_write(void)
/* .shstrtab */
elf_section_header(p - shstrtab, SHT_STRTAB, 0, shstrtab, false,
- shstrtablen, 0, 0, 1, 0);
+ shstrtablen, 0, 0, 1, 0);
p += strlen(p) + 1;
/* .symtab */
@@ -1266,10 +1267,6 @@ static struct SAA *elf_build_reltab(int32_t *len, struct Reloc *r)
while (r) {
int32_t sym = r->symbol;
- /*
- * Create a real symbol index; the +2 refers to the two special
- * entries, the null entry and the filename entry.
- */
if (sym >= GLOBAL_TEMP_BASE)
sym += global_offset;
diff --git a/output/outelf64.c b/output/outelf64.c
index 5635761..9776972 100644
--- a/output/outelf64.c
+++ b/output/outelf64.c
@@ -1406,6 +1406,7 @@ static void elf_sect_write(struct Section *sect, const void *data, size_t len)
saa_wbytes(sect->data, data, len);
sect->len += len;
}
+
static void elf_sect_writeaddr(struct Section *sect, int64_t data, size_t len)
{
saa_writeaddr(sect->data, data, len);
@@ -1444,7 +1445,7 @@ static int elf_directive(enum directives directive, char *value, int pass)
switch (directive) {
case D_OSABI:
if (pass == 2)
- return 1; /* ignore in pass 2 */
+ return 1; /* ignore in pass 2 */
n = readnum(value, &err);
if (err) {
@@ -2058,26 +2059,26 @@ static void dwarf64_generate(void)
/* build line section */
/* prolog */
plines = saa_init(1L);
- saa_write8(plines,1); /* Minimum Instruction Length */
- saa_write8(plines,1); /* Initial value of 'is_stmt' */
- saa_write8(plines,line_base); /* Line Base */
- saa_write8(plines,line_range); /* Line Range */
- saa_write8(plines,opcode_base); /* Opcode Base */
+ saa_write8(plines,1); /* Minimum Instruction Length */
+ saa_write8(plines,1); /* Initial value of 'is_stmt' */
+ saa_write8(plines,line_base); /* Line Base */
+ saa_write8(plines,line_range); /* Line Range */
+ saa_write8(plines,opcode_base); /* Opcode Base */
/* standard opcode lengths (# of LEB128u operands) */
- saa_write8(plines,0); /* Std opcode 1 length */
- saa_write8(plines,1); /* Std opcode 2 length */
- saa_write8(plines,1); /* Std opcode 3 length */
- saa_write8(plines,1); /* Std opcode 4 length */
- saa_write8(plines,1); /* Std opcode 5 length */
- saa_write8(plines,0); /* Std opcode 6 length */
- saa_write8(plines,0); /* Std opcode 7 length */
- saa_write8(plines,0); /* Std opcode 8 length */
- saa_write8(plines,1); /* Std opcode 9 length */
- saa_write8(plines,0); /* Std opcode 10 length */
- saa_write8(plines,0); /* Std opcode 11 length */
- saa_write8(plines,1); /* Std opcode 12 length */
- /* Directory Table */
- saa_write8(plines,0); /* End of table */
+ saa_write8(plines,0); /* Std opcode 1 length */
+ saa_write8(plines,1); /* Std opcode 2 length */
+ saa_write8(plines,1); /* Std opcode 3 length */
+ saa_write8(plines,1); /* Std opcode 4 length */
+ saa_write8(plines,1); /* Std opcode 5 length */
+ saa_write8(plines,0); /* Std opcode 6 length */
+ saa_write8(plines,0); /* Std opcode 7 length */
+ saa_write8(plines,0); /* Std opcode 8 length */
+ saa_write8(plines,1); /* Std opcode 9 length */
+ saa_write8(plines,0); /* Std opcode 10 length */
+ saa_write8(plines,0); /* Std opcode 11 length */
+ saa_write8(plines,1); /* Std opcode 12 length */
+ /* Directory Table */
+ saa_write8(plines,0); /* End of table */
/* File Name Table */
ftentry = dwarf_flist;
for (indx = 0;indx<dwarf_numfiles;indx++)