You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(208) |
Jun
(43) |
Jul
|
Aug
(2) |
Sep
(17) |
Oct
|
Nov
(4) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
(11) |
Mar
(3) |
Apr
(2) |
May
|
Jun
(3) |
Jul
(29) |
Aug
(29) |
Sep
(48) |
Oct
|
Nov
|
Dec
(5) |
2004 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2005 |
Jan
(12) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(1) |
Jun
(2) |
Jul
|
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(1) |
Dec
(2) |
2006 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(21) |
Nov
(25) |
Dec
(16) |
2007 |
Jan
(26) |
Feb
(26) |
Mar
(18) |
Apr
(51) |
May
(45) |
Jun
(26) |
Jul
(6) |
Aug
(85) |
Sep
(161) |
Oct
(111) |
Nov
(83) |
Dec
(18) |
2008 |
Jan
(31) |
Feb
(27) |
Mar
|
Apr
(16) |
May
(142) |
Jun
(136) |
Jul
(51) |
Aug
(21) |
Sep
(47) |
Oct
(428) |
Nov
(19) |
Dec
(6) |
2009 |
Jan
(11) |
Feb
(37) |
Mar
(17) |
Apr
(15) |
May
(13) |
Jun
(61) |
Jul
(127) |
Aug
(15) |
Sep
(22) |
Oct
(28) |
Nov
(37) |
Dec
(10) |
2010 |
Jan
(18) |
Feb
(22) |
Mar
(10) |
Apr
(41) |
May
|
Jun
(48) |
Jul
(61) |
Aug
(54) |
Sep
(34) |
Oct
(15) |
Nov
(49) |
Dec
(11) |
2011 |
Jan
|
Feb
(24) |
Mar
(10) |
Apr
(9) |
May
|
Jun
(33) |
Jul
(41) |
Aug
(20) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
(86) |
Mar
(12) |
Apr
|
May
(10) |
Jun
|
Jul
(9) |
Aug
(4) |
Sep
(11) |
Oct
(3) |
Nov
(3) |
Dec
(10) |
2013 |
Jan
(1) |
Feb
(23) |
Mar
(15) |
Apr
(7) |
May
(20) |
Jun
(3) |
Jul
(15) |
Aug
|
Sep
(29) |
Oct
(16) |
Nov
(69) |
Dec
(18) |
2014 |
Jan
|
Feb
(8) |
Mar
|
Apr
|
May
(16) |
Jun
(7) |
Jul
|
Aug
(5) |
Sep
(2) |
Oct
(4) |
Nov
(25) |
Dec
(8) |
2015 |
Jan
(6) |
Feb
(6) |
Mar
|
Apr
(1) |
May
(2) |
Jun
(1) |
Jul
(7) |
Aug
|
Sep
(2) |
Oct
(1) |
Nov
(6) |
Dec
|
2016 |
Jan
(12) |
Feb
(97) |
Mar
(57) |
Apr
(52) |
May
(33) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
(3) |
Nov
(3) |
Dec
|
2017 |
Jan
(4) |
Feb
|
Mar
(23) |
Apr
(5) |
May
|
Jun
(2) |
Jul
(3) |
Aug
(2) |
Sep
|
Oct
(6) |
Nov
(3) |
Dec
(3) |
2018 |
Jan
(4) |
Feb
(11) |
Mar
|
Apr
(1) |
May
(3) |
Jun
(6) |
Jul
|
Aug
(5) |
Sep
(5) |
Oct
(36) |
Nov
(128) |
Dec
(18) |
2019 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(24) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:21
|
Commit-ID: 8ba28bc20b10e8921bdd20313c6d8c35f674a35e Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=8ba28bc20b10e8921bdd20313c6d8c35f674a35e Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 13:45:03 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +0300 out: Elf32 -- Unify dwarf_ nums Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 2 +- output/outelf64.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 2868090..afd9438 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -151,7 +151,7 @@ static uint8_t *arangesbuf = 0, *arangesrelbuf = 0, *pubnamesbuf = 0, *infobuf = static int8_t line_base = -5, line_range = 14, opcode_base = 13; static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, abbrevlen, linelen, linerellen, framelen, loclen; -static int32_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; +static int64_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; static const struct dfmt df_dwarf; static const struct dfmt df_stabs; diff --git a/output/outelf64.c b/output/outelf64.c index fd23502..93696b1 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -153,7 +153,6 @@ static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, abbrevlen, linelen, linerellen, framelen, loclen; static int64_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; - static const struct dfmt df_dwarf; static const struct dfmt df_stabs; static struct elf_symbol *lastsym; |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:20
|
Commit-ID: 6285d72efbf6b8e69de685d1184927344e41c87a Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=6285d72efbf6b8e69de685d1184927344e41c87a Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 11:12:06 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +0300 out: Elf64, Elfx32 -- Style fix Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf64.c | 4 +--- output/outelfx32.c | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/output/outelf64.c b/output/outelf64.c index 7aed5a2..cfb6e57 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -217,7 +217,6 @@ static void elf_init(void) define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false); def_seg = seg_alloc(); - } static void elf_cleanup(void) @@ -1835,8 +1834,7 @@ static void dwarf_generate(void) psect = dwarf_fsect; totlen = 0; highaddr = 0; - for (indx = 0; indx < dwarf_nsections; indx++) - { + for (indx = 0; indx < dwarf_nsections; indx++) { plinep = psect->psaa; /* Line Number Program Epilogue */ saa_write8(plinep,2); /* std op 2 */ diff --git a/output/outelfx32.c b/output/outelfx32.c index 1c504db..5e83239 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -217,7 +217,6 @@ static void elf_init(void) define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false); def_seg = seg_alloc(); - } static void elf_cleanup(void) |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:20
|
Commit-ID: a541094beb7a79682aefa60e32ee2c40a3f87e30 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=a541094beb7a79682aefa60e32ee2c40a3f87e30 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 10:27:50 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +0300 out: Elf32, Elfx32 -- Unify struct ELF_SECTDATA and @elf_foffs Use int64_t. Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 4 ++-- output/outelfx32.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 961c883..67cdaa3 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -86,11 +86,11 @@ extern const struct ofmt of_elf32; static struct ELF_SECTDATA { void *data; - int32_t len; + int64_t len; bool is_saa; } *elf_sects; static int elf_nsect, nsections; -static int32_t elf_foffs; +static int64_t elf_foffs; static void elf_write(void); static void elf_sect_write(struct elf_section *, const uint8_t *, diff --git a/output/outelfx32.c b/output/outelfx32.c index 37d5dca..1c504db 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -86,11 +86,11 @@ extern const struct ofmt of_elfx32; static struct ELF_SECTDATA { void *data; - int32_t len; + int64_t len; bool is_saa; } *elf_sects; static int elf_nsect, nsections; -static int32_t elf_foffs; +static int64_t elf_foffs; static void elf_write(void); static void elf_sect_write(struct elf_section *, const void *, size_t); |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:19
|
Commit-ID: fbbe8fe9e2905fc901cac3eee1a9ac5b239e7ca8 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=fbbe8fe9e2905fc901cac3eee1a9ac5b239e7ca8 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 10:22:10 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +0300 out: Elf32 -- Unify struct symlininfo Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/output/outelf32.c b/output/outelf32.c index ab62b6e..c9d4af6 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -108,7 +108,8 @@ struct erel { struct symlininfo { int offset; - int section; /* section index */ + int section; /* index into sects[] */ + int segto; /* internal section number */ char *name; /* shallow-copied pointer of section name */ }; @@ -689,6 +690,7 @@ static void elf_out(int32_t segto, const void *data, /* again some stabs debugging stuff */ sinfo.offset = s->len; sinfo.section = i; + sinfo.segto = segto; sinfo.name = s->name; dfmt->debug_output(TY_STABSSYMLIN, &sinfo); /* end of debugging stuff */ |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:19
|
Commit-ID: a65e0481c264c5dc27272659746f8d07233ca958 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=a65e0481c264c5dc27272659746f8d07233ca958 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 00:56:34 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +0300 out: Elfx32, Elf32 -- Unify elf_add_reloc Make offset being int64_t and use 0 for Elf32. Thus it gonna be the same for all Elfs. Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 23 +++++++++++++---------- output/outelfx32.c | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index b2ba68a..3083b10 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -551,7 +551,8 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, nasm_error(ERR_NONFATAL, "no special symbol features supported here"); } -static void elf_add_reloc(struct elf_section *sect, int32_t segment, int type) +static void elf_add_reloc(struct elf_section *sect, int32_t segment, + int64_t offset, int type) { struct elf_reloc *r; @@ -559,6 +560,8 @@ static void elf_add_reloc(struct elf_section *sect, int32_t segment, int type) sect->tail = &r->next; r->address = sect->len; + r->offset = offset; + if (segment != NO_SEG) { int i; for (i = 0; i < nsects; i++) @@ -623,7 +626,7 @@ static int32_t elf_add_gsym_reloc(struct elf_section *sect, nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol" " for this reference"); else - elf_add_reloc(sect, segment, type); + elf_add_reloc(sect, segment, 0, type); return offset; } @@ -736,14 +739,14 @@ static void elf_out(int32_t segto, const void *data, switch (asize) { case 1: gnu16 = true; - elf_add_reloc(s, segment, R_386_8); + elf_add_reloc(s, segment, 0, R_386_8); break; case 2: gnu16 = true; - elf_add_reloc(s, segment, R_386_16); + elf_add_reloc(s, segment, 0, R_386_16); break; case 4: - elf_add_reloc(s, segment, R_386_32); + elf_add_reloc(s, segment, 0, R_386_32); break; default: /* Error issued further down */ break; @@ -755,9 +758,9 @@ static void elf_out(int32_t segto, const void *data, * need to fix up the data item by $-$$. */ addr += s->len; - elf_add_reloc(s, segment, R_386_GOTPC); + elf_add_reloc(s, segment, 0, R_386_GOTPC); } else if (wrt == elf_gotoff_sect + 1) { - elf_add_reloc(s, segment, R_386_GOTOFF); + elf_add_reloc(s, segment, 0, R_386_GOTOFF); } else if (wrt == elf_tlsie_sect + 1) { addr = elf_add_gsym_reloc(s, segment, addr, R_386_TLS_IE, true); @@ -823,7 +826,7 @@ static void elf_out(int32_t segto, const void *data, if (wrt == NO_SEG) { nasm_error(ERR_WARNING | ERR_WARN_GNUELF, "8- or 16-bit relocations in ELF is a GNU extension"); - elf_add_reloc(s, segment, reltype); + elf_add_reloc(s, segment, 0, reltype); } else { nasm_error(ERR_NONFATAL, "Unsupported non-32-bit ELF relocation"); @@ -842,9 +845,9 @@ static void elf_out(int32_t segto, const void *data, " segment base references"); } else { if (wrt == NO_SEG) { - elf_add_reloc(s, segment, R_386_PC32); + elf_add_reloc(s, segment, 0, R_386_PC32); } else if (wrt == elf_plt_sect + 1) { - elf_add_reloc(s, segment, R_386_PLT32); + elf_add_reloc(s, segment, 0, R_386_PLT32); } else if (wrt == elf_gotpc_sect + 1 || wrt == elf_gotoff_sect + 1 || wrt == elf_got_sect + 1) { diff --git a/output/outelfx32.c b/output/outelfx32.c index a95d04d..e601d35 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -557,7 +557,7 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, } static void elf_add_reloc(struct elf_section *sect, int32_t segment, - int32_t offset, int type) + int64_t offset, int type) { struct elf_reloc *r; |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:19
|
Commit-ID: e03bac6dbf58e4d4bba29f3c3d4f69ae6dfafb6f Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=e03bac6dbf58e4d4bba29f3c3d4f69ae6dfafb6f Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 00:57:11 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +0300 out: Elf32 -- Add missing comment Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 1 + 1 file changed, 1 insertion(+) diff --git a/output/outelf32.c b/output/outelf32.c index 3083b10..a0c5e83 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -240,6 +240,7 @@ static void elf_cleanup(void) dfmt->cleanup(); } +/* add entry to the elf .shstrtab section */ static void add_sectname(char *firsthalf, char *secondhalf) { int len = strlen(firsthalf) + strlen(secondhalf); |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:19
|
Commit-ID: caa18da2309a9b8ca42d704412b194358e0b179d Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=caa18da2309a9b8ca42d704412b194358e0b179d Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 10:24:33 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +0300 out: Elf32 -- Reuse TY_DEBUGSYMLIN Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf.h | 5 +---- output/outelf32.c | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/output/outelf.h b/output/outelf.h index 4d6db5d..909ea88 100644 --- a/output/outelf.h +++ b/output/outelf.h @@ -50,10 +50,7 @@ /* alignment of sections in file */ #define SEC_FILEALIGN 16 -/* this stuff is needed for the stabs debugging format */ -#define TY_STABSSYMLIN 0x40 /* ouch */ - -/* this stuff is needed for the dwarf debugging format */ +/* this stuff is needed for the dwarf/stabs debugging format */ #define TY_DEBUGSYMLIN 0x40 /* internal call to debug_out */ /* Known sections with nonstandard defaults */ diff --git a/output/outelf32.c b/output/outelf32.c index c9d4af6..961c883 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -692,7 +692,7 @@ static void elf_out(int32_t segto, const void *data, sinfo.section = i; sinfo.segto = segto; sinfo.name = s->name; - dfmt->debug_output(TY_STABSSYMLIN, &sinfo); + dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); /* end of debugging stuff */ if (s->type == SHT_NOBITS && type != OUT_RESERVE) { @@ -1471,7 +1471,7 @@ static void stabs_output(int type, void *param) { struct symlininfo *s; struct linelist *el; - if (type == TY_STABSSYMLIN) { + if (type == TY_DEBUGSYMLIN) { if (debug_immcall) { s = (struct symlininfo *)param; if (!(sects[s->section]->flags & SHF_EXECINSTR)) |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:19
|
Commit-ID: 583f505155b0baa48ab4e5a4b022af73fa2dd06b Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=583f505155b0baa48ab4e5a4b022af73fa2dd06b Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 01:04:55 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +0300 out: Elf64, Elf32, Elfx32 -- Style merge Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- 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 0e680c7..ab62b6e 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 1f8247a..7aed5a2 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;indx<dwarf_numfiles;indx++) - { + for (indx = 0; indx < dwarf_numfiles; indx++) { saa_wbytes(plines, ftentry->filename, (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 ed94942..37d5dca 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;indx<dwarf_numfiles;indx++) - { + for (indx = 0; indx < dwarf_numfiles; indx++) { saa_wbytes(plines, ftentry->filename, (int32_t)(strlen(ftentry->filename) + 1)); saa_write8(plines,0); /* directory LEB128u */ saa_write8(plines,0); /* time LEB128u */ |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:19
|
Commit-ID: 2bb791956e040a35122926cc4da86d97b824d901 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=2bb791956e040a35122926cc4da86d97b824d901 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 01:02:04 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +0300 out: Elf32, Elfx32, Elf64 -- Use ofmt->maxbits Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 5 +---- output/outelf64.c | 5 +---- output/outelfx32.c | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index a0c5e83..0e680c7 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -285,11 +285,8 @@ static int32_t elf_section_names(char *name, int pass, int *bits) uint64_t align; int type, i; - /* - * Default is 32 bits. - */ if (!name) { - *bits = 32; + *bits = ofmt->maxbits; return def_seg; } diff --git a/output/outelf64.c b/output/outelf64.c index 5a177cb..1f8247a 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -289,11 +289,8 @@ static int32_t elf_section_names(char *name, int pass, int *bits) uint64_t align; int type, i; - /* - * Default is 64 bits. - */ if (!name) { - *bits = 64; + *bits = ofmt->maxbits; return def_seg; } diff --git a/output/outelfx32.c b/output/outelfx32.c index e601d35..ed94942 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -289,11 +289,8 @@ static int32_t elf_section_names(char *name, int pass, int *bits) uint64_t align; int type, i; - /* - * Default is 64 bits. - */ if (!name) { - *bits = 64; + *bits = ofmt->maxbits; return def_seg; } |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-04-22 01:12:22
|
Commit-ID: 6a83cb93b39b916c2b27aa6f33598adfff9bad9c Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=6a83cb93b39b916c2b27aa6f33598adfff9bad9c Author: H. Peter Anvin <hp...@li...> AuthorDate: Thu, 21 Apr 2016 18:10:10 -0700 Committer: H. Peter Anvin <hp...@li...> CommitDate: Thu, 21 Apr 2016 18:10:10 -0700 msvc.mak: change $(L) to $(A) Change $(L) to $(A) for consistency with Makefile.in. Signed-off-by: H. Peter Anvin <hp...@li...> --- Mkfiles/msvc.mak | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index b2886b5..ecd6c4b 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -39,10 +39,10 @@ PERL = perl -I$(srcdir)/perllib # Binary suffixes O = obj -L = lib +A = lib X = .exe -.SUFFIXES: .c .i .s .$(O) .1 .man +.SUFFIXES: .c .i .s .$(O) .$(A) .1 .man .c.obj: $(CC) /c $(ALL_CFLAGS) /Fo$@ $< @@ -82,13 +82,13 @@ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \ all: nasm$(X) ndisasm$(X) rem cd rdoff && $(MAKE) all -nasm$(X): $(NASM) nasm.$(L) - $(LD) $(LDFLAGS) /OUT:nasm$(X) $(NASM) $(LIBS) nasm.$(L) +nasm$(X): $(NASM) nasm.$(A) + $(LD) $(LDFLAGS) /OUT:nasm$(X) $(NASM) $(LIBS) nasm.$(A) -ndisasm$(X): $(NDISASM) nasm.$(L) - $(LD) $(LDFLAGS) /OUT:ndisasm$(X) $(NDISASM) $(LIBS) nasm.$(L) +ndisasm$(X): $(NDISASM) nasm.$(A) + $(LD) $(LDFLAGS) /OUT:ndisasm$(X) $(NDISASM) $(LIBS) nasm.$(A) -nasm.$(L): $(LIBOBJ) +nasm.$(A): $(LIBOBJ) $(AR) $(ARFLAGS) /OUT:$@ $** # These source files are automagically generated from a single @@ -200,7 +200,7 @@ clean: -del /f stdlib\*.pdb -del /f stdlib\*.s -del /f stdlib\*.i - -del /f nasm.$(L) + -del /f nasm.$(A) -del /f nasm$(X) -del /f ndisasm$(X) rem cd rdoff && $(MAKE) clean |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:54
|
Commit-ID: 4b9171ad123bf563d8be7465bc9f225832f0dba2 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=4b9171ad123bf563d8be7465bc9f225832f0dba2 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 10 Apr 2016 17:37:11 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elf -- Merge Elf32, Elfx32 and Elf64 into single file There is a bunch of common code here so merge them all into one file. Unmergable parts are wrapped with is_elf() helpers. Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- Makefile.in | 19 +- Mkfiles/msvc.mak | 16 +- Mkfiles/netware.mak | 16 +- Mkfiles/openwcom.mak | 19 +- Mkfiles/owlinux.mak | 16 +- output/outelf.c | 3154 +++++++++++++++++++++++++++++++++++++++++++++++++- output/outelf32.c | 2066 --------------------------------- output/outelf64.c | 2141 ---------------------------------- output/outelfx32.c | 2100 --------------------------------- 9 files changed, 3163 insertions(+), 6384 deletions(-) diff --git a/Makefile.in b/Makefile.in index 06face8..feff0c6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -87,8 +87,7 @@ NASM = nasm.$(O) \ output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) \ output/nullout.$(O) \ output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \ - output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) \ - output/outelfx32.$(O) \ + output/outelf.$(O) \ output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \ output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \ output/codeview.$(O) \ @@ -412,21 +411,7 @@ output/outcoff.$(O): output/outcoff.c compiler.h config.h directiv.h eval.h \ output/outdbg.$(O): output/outdbg.c compiler.h config.h directiv.h insnsi.h \ nasm.h nasmint.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h \ regs.h tables.h -output/outelf.$(O): output/outelf.c compiler.h config.h directiv.h insnsi.h \ - nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \ - output/outelf.h output/outform.h pptok.h preproc.h rbtree.h regs.h saa.h \ - tables.h -output/outelf32.$(O): output/outelf32.c compiler.h config.h directiv.h \ - eval.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h \ - output/elf.h output/outelf.h output/outform.h output/outlib.h \ - output/stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h \ - tables.h ver.h -output/outelf64.$(O): output/outelf64.c compiler.h config.h directiv.h \ - eval.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h \ - output/elf.h output/outelf.h output/outform.h output/outlib.h \ - output/stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h \ - tables.h ver.h -output/outelfx32.$(O): output/outelfx32.c compiler.h config.h directiv.h \ +output/outelf.$(O): output/outelf.c compiler.h config.h directiv.h \ eval.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h \ output/elf.h output/outelf.h output/outform.h output/outlib.h \ output/stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h \ diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index df7df39..fff3779 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -54,8 +54,7 @@ NASM = nasm.$(O) \ output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) \ output/nullout.$(O) \ output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \ - output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) \ - output/outelfx32.$(O) \ + output/outelf.$(O) \ output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \ output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \ output/codeview.$(O) \ @@ -306,18 +305,7 @@ output/outcoff.$(O): output/outcoff.c compiler.h directiv.h eval.h insnsi.h \ output/outdbg.$(O): output/outdbg.c compiler.h directiv.h insnsi.h nasm.h \ nasmint.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h \ tables.h -output/outelf.$(O): output/outelf.c compiler.h directiv.h insnsi.h nasm.h \ - nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h output/outelf.h \ - output/outform.h pptok.h preproc.h rbtree.h regs.h saa.h tables.h -output/outelf32.$(O): output/outelf32.c compiler.h directiv.h eval.h \ - insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \ - output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \ - preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h -output/outelf64.$(O): output/outelf64.c compiler.h directiv.h eval.h \ - insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \ - output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \ - preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h -output/outelfx32.$(O): output/outelfx32.c compiler.h directiv.h eval.h \ +output/outelf.$(O): output/outelf.c compiler.h directiv.h eval.h \ insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \ output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \ preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h diff --git a/Mkfiles/netware.mak b/Mkfiles/netware.mak index 45728a2..7cf5cc3 100644 --- a/Mkfiles/netware.mak +++ b/Mkfiles/netware.mak @@ -38,8 +38,7 @@ NASM = nasm.o \ outform.o outlib.o nulldbg.o \ nullout.o \ outbin.o outaout.o outcoff.o \ - outelf.o outelf32.o outelf64.o \ - outelfx32.o \ + outelf.o \ outobj.o outas86.o outrdf2.o \ outdbg.o outieee.o outmacho.o \ codeview.o \ @@ -209,21 +208,10 @@ outcoff.o: outcoff.c compiler.h config.h directiv.h eval.h insnsi.h nasm.h \ raa.h regs.h saa.h tables.h outdbg.o: outdbg.c compiler.h config.h directiv.h insnsi.h nasm.h nasmint.h \ nasmlib.h opflags.h outform.h pptok.h preproc.h regs.h tables.h -outelf.o: outelf.c compiler.h config.h directiv.h insnsi.h nasm.h nasmint.h \ - nasmlib.h opflags.h dwarf.h elf.h outelf.h outform.h pptok.h preproc.h \ - rbtree.h regs.h saa.h tables.h -outelf32.o: outelf32.c compiler.h config.h directiv.h eval.h insnsi.h nasm.h \ +outelf.o: outelf.c compiler.h config.h directiv.h eval.h insnsi.h nasm.h \ nasmint.h nasmlib.h opflags.h dwarf.h elf.h outelf.h outform.h outlib.h \ stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h \ ver.h -outelf64.o: outelf64.c compiler.h config.h directiv.h eval.h insnsi.h nasm.h \ - nasmint.h nasmlib.h opflags.h dwarf.h elf.h outelf.h outform.h outlib.h \ - stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h \ - ver.h -outelfx32.o: outelfx32.c compiler.h config.h directiv.h eval.h insnsi.h \ - nasm.h nasmint.h nasmlib.h opflags.h dwarf.h elf.h outelf.h outform.h \ - outlib.h stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h \ - tables.h ver.h outform.o: outform.c compiler.h config.h directiv.h insnsi.h nasm.h \ nasmint.h nasmlib.h opflags.h outform.h pptok.h preproc.h regs.h tables.h outieee.o: outieee.c compiler.h config.h directiv.h insnsi.h nasm.h \ diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak index 4382536..9eda33e 100644 --- a/Mkfiles/openwcom.mak +++ b/Mkfiles/openwcom.mak @@ -54,8 +54,7 @@ NASM = nasm.$(O) & output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) & output/nullout.$(O) & output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) & - output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) & - output/outelfx32.$(O) & + output/outelf.$(O) & output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) & output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) & output/codeview.$(O) & @@ -353,21 +352,7 @@ output/outcoff.$(O): output/outcoff.c compiler.h config.h directiv.h eval.h & output/outdbg.$(O): output/outdbg.c compiler.h config.h directiv.h insnsi.h & nasm.h nasmint.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h & regs.h tables.h -output/outelf.$(O): output/outelf.c compiler.h config.h directiv.h insnsi.h & - nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h & - output/outelf.h output/outform.h pptok.h preproc.h rbtree.h regs.h saa.h & - tables.h -output/outelf32.$(O): output/outelf32.c compiler.h config.h directiv.h & - eval.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h & - output/elf.h output/outelf.h output/outform.h output/outlib.h & - output/stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h & - tables.h ver.h -output/outelf64.$(O): output/outelf64.c compiler.h config.h directiv.h & - eval.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h & - output/elf.h output/outelf.h output/outform.h output/outlib.h & - output/stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h & - tables.h ver.h -output/outelfx32.$(O): output/outelfx32.c compiler.h config.h directiv.h & +output/outelf.$(O): output/outelf.c compiler.h config.h directiv.h & eval.h insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h & output/elf.h output/outelf.h output/outform.h output/outlib.h & output/stabs.h pptok.h preproc.h raa.h rbtree.h regs.h saa.h stdscan.h & diff --git a/Mkfiles/owlinux.mak b/Mkfiles/owlinux.mak index 3949481..312812e 100644 --- a/Mkfiles/owlinux.mak +++ b/Mkfiles/owlinux.mak @@ -65,8 +65,7 @@ NASM = nasm.$(O) \ output/outform.$(O) output/outlib.$(O) output/nulldbg.$(O) \ output/nullout.$(O) \ output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \ - output/outelf.$(O) output/outelf32.$(O) output/outelf64.$(O) \ - output/outelfx32.$(O) \ + output/outelf.$(O) \ output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \ output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \ output/codeview.$(O) \ @@ -317,18 +316,7 @@ output/outcoff.$(O): output/outcoff.c compiler.h directiv.h eval.h insnsi.h \ output/outdbg.$(O): output/outdbg.c compiler.h directiv.h insnsi.h nasm.h \ nasmint.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h \ tables.h -output/outelf.$(O): output/outelf.c compiler.h directiv.h insnsi.h nasm.h \ - nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h output/outelf.h \ - output/outform.h pptok.h preproc.h rbtree.h regs.h saa.h tables.h -output/outelf32.$(O): output/outelf32.c compiler.h directiv.h eval.h \ - insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \ - output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \ - preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h -output/outelf64.$(O): output/outelf64.c compiler.h directiv.h eval.h \ - insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \ - output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \ - preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h -output/outelfx32.$(O): output/outelfx32.c compiler.h directiv.h eval.h \ +output/outelf.$(O): output/outelf.c compiler.h directiv.h eval.h \ insnsi.h nasm.h nasmint.h nasmlib.h opflags.h output/dwarf.h output/elf.h \ output/outelf.h output/outform.h output/outlib.h output/stabs.h pptok.h \ preproc.h raa.h rbtree.h regs.h saa.h stdscan.h tables.h ver.h diff --git a/output/outelf.c b/output/outelf.c index 59c4f50..72eb7ea 100644 --- a/output/outelf.c +++ b/output/outelf.c @@ -41,14 +41,154 @@ #include <stdlib.h> #include "nasm.h" +#include "nasmlib.h" +#include "saa.h" +#include "raa.h" +#include "stdscan.h" +#include "eval.h" #include "output/outform.h" +#include "output/outlib.h" +#include "rbtree.h" +#include "ver.h" #include "output/dwarf.h" -#include "output/elf.h" +#include "output/stabs.h" #include "output/outelf.h" +#include "output/elf.h" #if defined(OF_ELF32) || defined(OF_ELF64) || defined(OF_ELFX32) +#define SECT_DELTA 32 +static struct elf_section **sects; +static int nsects, sectlen; + +#define SHSTR_DELTA 256 +static char *shstrtab; +static int shstrtablen, shstrtabsize; + +static struct SAA *syms; +static uint32_t nlocals, nglobs, ndebugs; /* Symbol counts */ + +static int32_t def_seg; + +static struct RAA *bsym; + +static struct SAA *strs; +static uint32_t strslen; + +static struct elf_symbol *fwds; + +static char elf_module[FILENAME_MAX]; + +extern const struct ofmt of_elf32; +extern const struct ofmt of_elf64; +extern const struct ofmt of_elfx32; + +static struct ELF_SECTDATA { + void *data; + int64_t len; + bool is_saa; +} *elf_sects; + +static int elf_nsect, nsections; +static int64_t elf_foffs; + +static void elf_write(void); +static void elf_sect_write(struct elf_section *, const void *, size_t); +static void elf_sect_writeaddr(struct elf_section *, int64_t, size_t); +static void elf_section_header(int, int, uint64_t, void *, bool, uint64_t, int, int, + int, int); +static void elf_write_sections(void); +static struct SAA *elf_build_symtab(int32_t *, int32_t *); +static struct SAA *elf_build_reltab(uint64_t *, struct elf_reloc *); +static void add_sectname(char *, char *); + +struct erel { + int offset; + int info; +}; + +struct symlininfo { + int offset; + int section; /* index into sects[] */ + int segto; /* internal section number */ + char *name; /* shallow-copied pointer of section name */ +}; + +struct linelist { + struct linelist *next; + struct linelist *last; + struct symlininfo info; + char *filename; + int line; +}; + +struct sectlist { + struct SAA *psaa; + int section; + int line; + int offset; + int file; + struct sectlist *next; + struct sectlist *last; +}; + +/* common debug variables */ +static int currentline = 1; +static int debug_immcall = 0; + +/* stabs debug variables */ +static struct linelist *stabslines = 0; +static int numlinestabs = 0; +static char *stabs_filename = 0; +static uint8_t *stabbuf = 0, *stabstrbuf = 0, *stabrelbuf = 0; +static int stablen, stabstrlen, stabrellen; + +/* dwarf debug variables */ +static struct linelist *dwarf_flist = 0, *dwarf_clist = 0, *dwarf_elist = 0; +static struct sectlist *dwarf_fsect = 0, *dwarf_csect = 0, *dwarf_esect = 0; +static int dwarf_numfiles = 0, dwarf_nsections; +static uint8_t *arangesbuf = 0, *arangesrelbuf = 0, *pubnamesbuf = 0, *infobuf = 0, *inforelbuf = 0, + *abbrevbuf = 0, *linebuf = 0, *linerelbuf = 0, *framebuf = 0, *locbuf = 0; +static int8_t line_base = -5, line_range = 14, opcode_base = 13; +static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, + abbrevlen, linelen, linerellen, framelen, loclen; +static int64_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; + +static const struct dfmt df_dwarf; +static const struct dfmt df_stabs; +static struct elf_symbol *lastsym; + +/* common debugging routines */ +static void debug_typevalue(int32_t); + +/* stabs debugging routines */ +static void stabs_linenum(const char *filename, int32_t linenumber, int32_t); +static void stabs_output(int, void *); +static void stabs_generate(void); +static void stabs_cleanup(void); + +/* dwarf debugging routines */ +static void dwarf_init(void); +static void dwarf_linenum(const char *filename, int32_t linenumber, int32_t); +static void dwarf_output(int, void *); +static void dwarf_generate(void); +static void dwarf_cleanup(void); +static void dwarf_findfile(const char *); +static void dwarf_findsect(const int); + +static bool is_elf64(void); +static bool is_elf32(void); +static bool is_elfx32(void); + +/* + * Special NASM section numbers which are used to define ELF special + * symbols. + */ +static int32_t elf_gotpc_sect, elf_gotoff_sect; +static int32_t elf_got_sect, elf_plt_sect; +static int32_t elf_sym_sect, elf_gottpoff_sect, elf_tlsie_sect; + uint8_t elf_osabi = 0; /* Default OSABI = 0 (System V or Linux) */ uint8_t elf_abiver = 0; /* Current ABI version */ @@ -170,4 +310,3016 @@ int elf_directive(enum directives directive, char *value, int pass) } } +static void elf_init(void) +{ + sects = NULL; + nsects = sectlen = 0; + syms = saa_init((int32_t)sizeof(struct elf_symbol)); + nlocals = nglobs = ndebugs = 0; + bsym = raa_init(); + strs = saa_init(1L); + saa_wbytes(strs, "\0", 1L); + saa_wbytes(strs, elf_module, strlen(elf_module)+1); + strslen = 2 + strlen(elf_module); + shstrtab = NULL; + shstrtablen = shstrtabsize = 0;; + add_sectname("", ""); + + fwds = NULL; + + /* + * FIXME: tlsie is Elf32 only and + * gottpoff is Elfx32|64 only. + */ + + elf_gotpc_sect = seg_alloc(); + define_label("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false); + elf_gotoff_sect = seg_alloc(); + define_label("..gotoff", elf_gotoff_sect + 1, 0L, NULL, false, false); + elf_got_sect = seg_alloc(); + define_label("..got", elf_got_sect + 1, 0L, NULL, false, false); + elf_plt_sect = seg_alloc(); + define_label("..plt", elf_plt_sect + 1, 0L, NULL, false, false); + elf_sym_sect = seg_alloc(); + define_label("..sym", elf_sym_sect + 1, 0L, NULL, false, false); + elf_gottpoff_sect = seg_alloc(); + define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false); + elf_tlsie_sect = seg_alloc(); + define_label("..tlsie", elf_tlsie_sect + 1, 0L, NULL, false, false); + + def_seg = seg_alloc(); +} + +static void elf_cleanup(void) +{ + struct elf_reloc *r; + int i; + + elf_write(); + for (i = 0; i < nsects; i++) { + if (sects[i]->type != SHT_NOBITS) + saa_free(sects[i]->data); + if (sects[i]->head) + saa_free(sects[i]->rel); + while (sects[i]->head) { + r = sects[i]->head; + sects[i]->head = sects[i]->head->next; + nasm_free(r); + } + } + nasm_free(sects); + saa_free(syms); + raa_free(bsym); + saa_free(strs); + dfmt->cleanup(); +} + +/* add entry to the elf .shstrtab section */ +static void add_sectname(char *firsthalf, char *secondhalf) +{ + int len = strlen(firsthalf) + strlen(secondhalf); + while (shstrtablen + len + 1 > shstrtabsize) + shstrtab = nasm_realloc(shstrtab, (shstrtabsize += SHSTR_DELTA)); + strcpy(shstrtab + shstrtablen, firsthalf); + strcat(shstrtab + shstrtablen, secondhalf); + shstrtablen += len + 1; +} + +static int elf_make_section(char *name, int type, int flags, int align) +{ + struct elf_section *s; + + s = nasm_zalloc(sizeof(*s)); + + if (type != SHT_NOBITS) + s->data = saa_init(1L); + s->tail = &s->head; + if (!strcmp(name, ".text")) + s->index = def_seg; + else + s->index = seg_alloc(); + add_sectname("", name); + + s->name = nasm_strdup(name); + s->type = type; + s->flags = flags; + s->align = align; + + if (nsects >= sectlen) + sects = nasm_realloc(sects, (sectlen += SECT_DELTA) * sizeof(*sects)); + sects[nsects++] = s; + + return nsects - 1; +} + +static int32_t elf_section_names(char *name, int pass, int *bits) +{ + char *p; + uint32_t flags, flags_and, flags_or; + uint64_t align; + int type, i; + + if (!name) { + *bits = ofmt->maxbits; + return def_seg; + } + + p = nasm_skip_word(name); + if (*p) + *p++ = '\0'; + flags_and = flags_or = type = align = 0; + + elf_section_attrib(name, p, pass, &flags_and, + &flags_or, &align, &type); + + if (!strcmp(name, ".shstrtab") || + !strcmp(name, ".symtab") || + !strcmp(name, ".strtab")) { + nasm_error(ERR_NONFATAL, "attempt to redefine reserved section" + "name `%s'", name); + return NO_SEG; + } + + for (i = 0; i < nsects; i++) + if (!strcmp(name, sects[i]->name)) + break; + if (i == nsects) { + const struct elf_known_section *ks = elf_known_sections; + + while (ks->name) { + if (!strcmp(name, ks->name)) + break; + ks++; + } + + type = type ? type : ks->type; + align = align ? align : ks->align; + flags = (ks->flags & ~flags_and) | flags_or; + + i = elf_make_section(name, type, flags, align); + } else if (pass == 1) { + if ((type && sects[i]->type != type) + || (align && sects[i]->align != align) + || (flags_and && ((sects[i]->flags & flags_and) != flags_or))) + nasm_error(ERR_WARNING, "incompatible section attributes ignored on" + " redeclaration of section `%s'", name); + } + + return sects[i]->index; +} + +static void elf_deflabel(char *name, int32_t segment, int64_t offset, + int is_global, char *special) +{ + int pos = strslen; + struct elf_symbol *sym; + bool special_used = false; + +#if defined(DEBUG) && DEBUG>2 + nasm_error(ERR_DEBUG, + " elf_deflabel: %s, seg=%"PRIx32", off=%"PRIx64", is_global=%d, %s\n", + name, segment, offset, is_global, special); +#endif + if (name[0] == '.' && name[1] == '.' && name[2] != '@') { + /* + * This is a NASM special symbol. We never allow it into + * the ELF symbol table, even if it's a valid one. If it + * _isn't_ a valid one, we should barf immediately. + * + * FIXME: tlsie is Elf32 only, and gottpoff is Elfx32|64 only. + */ + if (strcmp(name, "..gotpc") && strcmp(name, "..gotoff") && + strcmp(name, "..got") && strcmp(name, "..plt") && + strcmp(name, "..sym") && strcmp(name, "..gottpoff") && + strcmp(name, "..tlsie")) + nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name); + return; + } + + if (is_global == 3) { + struct elf_symbol **s; + /* + * Fix up a forward-reference symbol size from the first + * pass. + */ + for (s = &fwds; *s; s = &(*s)->nextfwd) + if (!strcmp((*s)->name, name)) { + struct tokenval tokval; + expr *e; + char *p = nasm_skip_spaces(nasm_skip_word(special)); + + stdscan_reset(); + stdscan_set(p); + tokval.t_type = TOKEN_INVALID; + e = evaluate(stdscan, NULL, &tokval, NULL, 1, NULL); + if (e) { + if (!is_simple(e)) + nasm_error(ERR_NONFATAL, "cannot use relocatable" + " expression as symbol size"); + else + (*s)->size = reloc_value(e); + } + + /* + * Remove it from the list of unresolved sizes. + */ + nasm_free((*s)->name); + *s = (*s)->nextfwd; + return; + } + return; /* it wasn't an important one */ + } + + saa_wbytes(strs, name, (int32_t)(1 + strlen(name))); + strslen += 1 + strlen(name); + + lastsym = sym = saa_wstruct(syms); + + memset(&sym->symv, 0, sizeof(struct rbtree)); + + sym->strpos = pos; + sym->type = is_global ? SYM_GLOBAL : SYM_LOCAL; + sym->other = STV_DEFAULT; + sym->size = 0; + if (segment == NO_SEG) + sym->section = SHN_ABS; + else { + int i; + sym->section = SHN_UNDEF; + if (segment == def_seg) { + /* we have to be sure at least text section is there */ + int tempint; + if (segment != elf_section_names(".text", 2, &tempint)) + nasm_panic(0, "strange segment conditions in ELF driver"); + } + for (i = 0; i < nsects; i++) { + if (segment == sects[i]->index) { + sym->section = i + 1; + break; + } + } + } + + if (is_global == 2) { + sym->size = offset; + sym->symv.key = 0; + sym->section = SHN_COMMON; + /* + * We have a common variable. Check the special text to see + * if it's a valid number and power of two; if so, store it + * as the alignment for the common variable. + */ + if (special) { + bool err; + sym->symv.key = readnum(special, &err); + if (err) + nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a" + " valid number", special); + else if ((sym->symv.key | (sym->symv.key - 1)) != 2 * sym->symv.key - 1) + nasm_error(ERR_NONFATAL, "alignment constraint `%s' is not a" + " power of two", special); + } + special_used = true; + } else + sym->symv.key = (sym->section == SHN_UNDEF ? 0 : offset); + + if (sym->type == SYM_GLOBAL) { + /* + * If sym->section == SHN_ABS, then the first line of the + * else section would cause a core dump, because its a reference + * beyond the end of the section array. + * This behaviour is exhibited by this code: + * GLOBAL crash_nasm + * crash_nasm equ 0 + * To avoid such a crash, such requests are silently discarded. + * This may not be the best solution. + */ + if (sym->section == SHN_UNDEF || sym->section == SHN_COMMON) { + bsym = raa_write(bsym, segment, nglobs); + } else if (sym->section != SHN_ABS) { + /* + * This is a global symbol; so we must add it to the rbtree + * of global symbols in its section. + * + * In addition, we check the special text for symbol + * type and size information. + */ + sects[sym->section-1]->gsyms = + rb_insert(sects[sym->section-1]->gsyms, &sym->symv); + + if (special) { + int n = strcspn(special, " \t"); + + if (!nasm_strnicmp(special, "function", n)) + sym->type |= STT_FUNC; + else if (!nasm_strnicmp(special, "data", n) || + !nasm_strnicmp(special, "object", n)) + sym->type |= STT_OBJECT; + else if (!nasm_strnicmp(special, "notype", n)) + sym->type |= STT_NOTYPE; + else + nasm_error(ERR_NONFATAL, "unrecognised symbol type `%.*s'", + n, special); + special += n; + + special = nasm_skip_spaces(special); + if (*special) { + n = strcspn(special, " \t"); + if (!nasm_strnicmp(special, "default", n)) + sym->other = STV_DEFAULT; + else if (!nasm_strnicmp(special, "internal", n)) + sym->other = STV_INTERNAL; + else if (!nasm_strnicmp(special, "hidden", n)) + sym->other = STV_HIDDEN; + else if (!nasm_strnicmp(special, "protected", n)) + sym->other = STV_PROTECTED; + else + n = 0; + special += n; + } + + if (*special) { + struct tokenval tokval; + expr *e; + int fwd = 0; + char *saveme = stdscan_get(); + + while (special[n] && nasm_isspace(special[n])) + n++; + /* + * We have a size expression; attempt to + * evaluate it. + */ + stdscan_reset(); + stdscan_set(special + n); + tokval.t_type = TOKEN_INVALID; + e = evaluate(stdscan, NULL, &tokval, &fwd, 0, NULL); + if (fwd) { + sym->nextfwd = fwds; + fwds = sym; + sym->name = nasm_strdup(name); + } else if (e) { + if (!is_simple(e)) + nasm_error(ERR_NONFATAL, "cannot use relocatable" + " expression as symbol size"); + else + sym->size = reloc_value(e); + } + stdscan_set(saveme); + } + special_used = true; + } + /* + * If TLS segment, mark symbol accordingly. + */ + if (sects[sym->section - 1]->flags & SHF_TLS) { + sym->type &= 0xf0; + sym->type |= STT_TLS; + } + } + sym->globnum = nglobs; + nglobs++; + } else + nlocals++; + + if (special && !special_used) + nasm_error(ERR_NONFATAL, "no special symbol features supported here"); +} + +static void elf_add_reloc(struct elf_section *sect, int32_t segment, + int64_t offset, int type) +{ + struct elf_reloc *r; + + r = *sect->tail = nasm_zalloc(sizeof(struct elf_reloc)); + sect->tail = &r->next; + + r->address = sect->len; + r->offset = offset; + + if (segment != NO_SEG) { + int i; + for (i = 0; i < nsects; i++) + if (segment == sects[i]->index) + r->symbol = i + 2; + if (!r->symbol) + r->symbol = GLOBAL_TEMP_BASE + raa_read(bsym, segment); + } + r->type = type; + + sect->nrelocs++; +} + +/* + * This routine deals with ..got and ..sym relocations: the more + * complicated kinds. In shared-library writing, some relocations + * with respect to global symbols must refer to the precise symbol + * rather than referring to an offset from the base of the section + * _containing_ the symbol. Such relocations call to this routine, + * which searches the symbol list for the symbol in question. + * + * R_386_GOT32 | R_X86_64_GOT32 references require the _exact_ symbol address to be + * used; R_386_32 | R_X86_64_32 references can be at an offset from the symbol. + * The boolean argument `exact' tells us this. + * + * Return value is the adjusted value of `addr', having become an + * offset from the symbol rather than the section. Should always be + * zero when returning from an exact call. + * + * Limitation: if you define two symbols at the same place, + * confusion will occur. + * + * Inefficiency: we search, currently, using a linked list which + * isn't even necessarily sorted. + */ +static int64_t elf_add_gsym_reloc(struct elf_section *sect, + int32_t segment, uint64_t offset, + int64_t pcrel, int type, bool exact) +{ + struct elf_reloc *r; + struct elf_section *s; + struct elf_symbol *sym; + struct rbtree *srb; + int i; + + /* + * First look up the segment/offset pair and find a global + * symbol corresponding to it. If it's not one of our segments, + * then it must be an external symbol, in which case we're fine + * doing a normal elf_add_reloc after first sanity-checking + * that the offset from the symbol is zero. + */ + s = NULL; + for (i = 0; i < nsects; i++) + if (segment == sects[i]->index) { + s = sects[i]; + break; + } + + if (!s) { + if (exact && offset) + nasm_error(ERR_NONFATAL, "invalid access to an external symbol"); + else + elf_add_reloc(sect, segment, offset - pcrel, type); + return 0; + } + + srb = rb_search(s->gsyms, offset); + if (!srb || (exact && srb->key != offset)) { + nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol" + " for this reference"); + return 0; + } + sym = container_of(srb, struct elf_symbol, symv); + + r = *sect->tail = nasm_malloc(sizeof(struct elf_reloc)); + sect->tail = &r->next; + + r->next = NULL; + r->address = sect->len; + r->offset = offset - pcrel - sym->symv.key; + r->symbol = GLOBAL_TEMP_BASE + sym->globnum; + r->type = type; + + sect->nrelocs++; + return r->offset; +} + +static void elf32_out(int32_t segto, const void *data, + enum out_type type, uint64_t size, + int32_t segment, int32_t wrt) +{ + struct elf_section *s; + int64_t addr; + int reltype, bytes; + int i; + static struct symlininfo sinfo; + + /* + * handle absolute-assembly (structure definitions) + */ + if (segto == NO_SEG) { + if (type != OUT_RESERVE) + nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]" + " space"); + return; + } + + s = NULL; + for (i = 0; i < nsects; i++) + if (segto == sects[i]->index) { + s = sects[i]; + break; + } + if (!s) { + int tempint; /* ignored */ + if (segto != elf_section_names(".text", 2, &tempint)) + nasm_panic(0, "strange segment conditions in ELF driver"); + else { + s = sects[nsects - 1]; + i = nsects - 1; + } + } + + /* again some stabs debugging stuff */ + sinfo.offset = s->len; + sinfo.section = i; + sinfo.segto = segto; + sinfo.name = s->name; + dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); + /* end of debugging stuff */ + + if (s->type == SHT_NOBITS && type != OUT_RESERVE) { + nasm_error(ERR_WARNING, "attempt to initialize memory in" + " BSS section `%s': ignored", s->name); + s->len += realsize(type, size); + return; + } + + switch (type) { + case OUT_RESERVE: + if (s->type == SHT_PROGBITS) { + nasm_error(ERR_WARNING, "uninitialized space declared in" + " non-BSS section `%s': zeroing", s->name); + elf_sect_write(s, NULL, size); + } else + s->len += size; + break; + + case OUT_RAWDATA: + if (segment != NO_SEG) + nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); + elf_sect_write(s, data, size); + break; + + case OUT_ADDRESS: + { + bool gnu16 = false; + int asize = abs((int)size); + + addr = *(int64_t *)data; + if (segment != NO_SEG) { + if (segment % 2) { + nasm_error(ERR_NONFATAL, "ELF format does not support" + " segment base references"); + } else { + if (wrt == NO_SEG) { + /* + * The if() is a hack to deal with compilers which + * don't handle switch() statements with 64-bit + * expressions. + */ + switch (asize) { + case 1: + gnu16 = true; + elf_add_reloc(s, segment, 0, R_386_8); + break; + case 2: + gnu16 = true; + elf_add_reloc(s, segment, 0, R_386_16); + break; + case 4: + elf_add_reloc(s, segment, 0, R_386_32); + break; + default: /* Error issued further down */ + break; + } + } else if (wrt == elf_gotpc_sect + 1) { + /* + * The user will supply GOT relative to $$. ELF + * will let us have GOT relative to $. So we + * need to fix up the data item by $-$$. + */ + addr += s->len; + elf_add_reloc(s, segment, 0, R_386_GOTPC); + } else if (wrt == elf_gotoff_sect + 1) { + elf_add_reloc(s, segment, 0, R_386_GOTOFF); + } else if (wrt == elf_tlsie_sect + 1) { + addr = elf_add_gsym_reloc(s, segment, addr, 0, + R_386_TLS_IE, true); + } else if (wrt == elf_got_sect + 1) { + addr = elf_add_gsym_reloc(s, segment, addr, 0, + R_386_GOT32, true); + } else if (wrt == elf_sym_sect + 1) { + switch (asize) { + case 1: + gnu16 = true; + addr = elf_add_gsym_reloc(s, segment, addr, 0, + R_386_8, false); + break; + case 2: + gnu16 = true; + addr = elf_add_gsym_reloc(s, segment, addr, 0, + R_386_16, false); + break; + case 4: + addr = elf_add_gsym_reloc(s, segment, addr, 0, + R_386_32, false); + break; + default: + break; + } + } else if (wrt == elf_plt_sect + 1) { + nasm_error(ERR_NONFATAL, "ELF format cannot produce non-PC-" + "relative PLT references"); + } else { + nasm_error(ERR_NONFATAL, "ELF format does not support this" + " use of WRT"); + wrt = NO_SEG; /* we can at least _try_ to continue */ + } + } + } + + if (gnu16) { + nasm_error(ERR_WARNING | ERR_WARN_GNUELF, + "8- or 16-bit relocations in ELF32 is a GNU extension"); + } else if (asize != 4 && segment != NO_SEG) { + nasm_error(ERR_NONFATAL, "Unsupported non-32-bit ELF relocation"); + } + elf_sect_writeaddr(s, addr, asize); + break; + } + + case OUT_REL1ADR: + reltype = R_386_PC8; + bytes = 1; + goto rel12adr; + case OUT_REL2ADR: + reltype = R_386_PC16; + bytes = 2; + goto rel12adr; + +rel12adr: + addr = *(int64_t *)data - size; + nasm_assert(segment != segto); + if (segment != NO_SEG && segment % 2) { + nasm_error(ERR_NONFATAL, "ELF format does not support" + " segment base references"); + } else { + if (wrt == NO_SEG) { + nasm_error(ERR_WARNING | ERR_WARN_GNUELF, + "8- or 16-bit relocations in ELF is a GNU extension"); + elf_add_reloc(s, segment, 0, reltype); + } else { + nasm_error(ERR_NONFATAL, + "Unsupported non-32-bit ELF relocation"); + } + } + elf_sect_writeaddr(s, addr, bytes); + break; + + case OUT_REL4ADR: + addr = *(int64_t *)data - size; + if (segment == segto) + nasm_panic(0, "intra-segment OUT_REL4ADR"); + if (segment != NO_SEG && segment % 2) { + nasm_error(ERR_NONFATAL, "ELF format does not support" + " segment base references"); + } else { + if (wrt == NO_SEG) { + elf_add_reloc(s, segment, 0, R_386_PC32); + } else if (wrt == elf_plt_sect + 1) { + elf_add_reloc(s, segment, 0, R_386_PLT32); + } else if (wrt == elf_gotpc_sect + 1 || + wrt == elf_gotoff_sect + 1 || + wrt == elf_got_sect + 1) { + nasm_error(ERR_NONFATAL, "ELF format cannot produce PC-" + "relative GOT references"); + } else { + nasm_error(ERR_NONFATAL, "ELF format does not support this" + " use of WRT"); + wrt = NO_SEG; /* we can at least _try_ to continue */ + } + } + elf_sect_writeaddr(s, addr, 4); + break; + + case OUT_REL8ADR: + nasm_error(ERR_NONFATAL, "32-bit ELF format does not support 64-bit relocations"); + addr = 0; + elf_sect_writeaddr(s, addr, 8); + break; + } +} +static void elf64_out(int32_t segto, const void *data, + enum out_type type, uint64_t size, + int32_t segment, int32_t wrt) +{ + struct elf_section *s; + int64_t addr; + int reltype, bytes; + int i; + static struct symlininfo sinfo; + + /* + * handle absolute-assembly (structure definitions) + */ + if (segto == NO_SEG) { + if (type != OUT_RESERVE) + nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]" + " space"); + return; + } + + s = NULL; + for (i = 0; i < nsects; i++) + if (segto == sects[i]->index) { + s = sects[i]; + break; + } + if (!s) { + int tempint; /* ignored */ + if (segto != elf_section_names(".text", 2, &tempint)) + nasm_panic(0, "strange segment conditions in ELF driver"); + else { + s = sects[nsects - 1]; + i = nsects - 1; + } + } + + /* again some stabs debugging stuff */ + sinfo.offset = s->len; + sinfo.section = i; + sinfo.segto = segto; + sinfo.name = s->name; + dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); + /* end of debugging stuff */ + + if (s->type == SHT_NOBITS && type != OUT_RESERVE) { + nasm_error(ERR_WARNING, "attempt to initialize memory in" + " BSS section `%s': ignored", s->name); + s->len += realsize(type, size); + return; + } + + switch (type) { + case OUT_RESERVE: + if (s->type == SHT_PROGBITS) { + nasm_error(ERR_WARNING, "uninitialized space declared in" + " non-BSS section `%s': zeroing", s->name); + elf_sect_write(s, NULL, size); + } else + s->len += size; + break; + + case OUT_RAWDATA: + if (segment != NO_SEG) + nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); + elf_sect_write(s, data, size); + break; + + case OUT_ADDRESS: + { + int isize = (int)size; + int asize = abs((int)size); + + addr = *(int64_t *)data; + if (segment == NO_SEG) { + /* Do nothing */ + } else if (segment % 2) { + nasm_error(ERR_NONFATAL, "ELF format does not support" + " segment base references"); + } else { + if (wrt == NO_SEG) { + switch (isize) { + case 1: + case -1: + elf_add_reloc(s, segment, addr, R_X86_64_8); + break; + case 2: + case -2: + elf_add_reloc(s, segment, addr, R_X86_64_16); + break; + case 4: + elf_add_reloc(s, segment, addr, R_X86_64_32); + break; + case -4: + elf_add_reloc(s, segment, addr, R_X86_64_32S); + break; + case 8: + case -8: + elf_add_reloc(s, segment, addr, R_X86_64_64); + break; + default: + nasm_panic(0, "internal error elf64-hpa-871"); + break; + } + addr = 0; + } else if (wrt == elf_gotpc_sect + 1) { + /* + * The user will supply GOT relative to $$. ELF + * will let us have GOT relative to $. So we + * need to fix up the data item by $-$$. + */ + addr += s->len; + elf_add_reloc(s, segment, addr, R_X86_64_GOTPC32); + addr = 0; + } else if (wrt == elf_gotoff_sect + 1) { + if (asize != 8) { + nasm_error(ERR_NONFATAL, "ELF64 requires ..gotoff " + "references to be qword"); + } else { + elf_add_reloc(s, segment, addr, R_X86_64_GOTOFF64); + addr = 0; + } + } else if (wrt == elf_got_sect + 1) { + switch (asize) { + case 4: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_GOT32, true); + addr = 0; + break; + case 8: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_GOT64, true); + addr = 0; + break; + default: + nasm_error(ERR_NONFATAL, "invalid ..got reference"); + break; + } + } else if (wrt == elf_sym_sect + 1) { + switch (isize) { + case 1: + case -1: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_8, false); + addr = 0; + break; + case 2: + case -2: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_16, false); + addr = 0; + break; + case 4: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_32, false); + addr = 0; + break; + case -4: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_32S, false); + addr = 0; + break; + case 8: + case -8: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_64, false); + addr = 0; + break; + default: + nasm_panic(0, "internal error elf64-hpa-903"); + break; + } + } else if (wrt == elf_plt_sect + 1) { + nasm_error(ERR_NONFATAL, "ELF format cannot produce non-PC-" + "relative PLT references"); + } else { + nasm_error(ERR_NONFATAL, "ELF format does not support this" + " use of WRT"); + } + } + elf_sect_writeaddr(s, addr, asize); + break; + } + + case OUT_REL1ADR: + reltype = R_X86_64_PC8; + bytes = 1; + goto rel12adr; + + case OUT_REL2ADR: + reltype = R_X86_64_PC16; + bytes = 2; + goto rel12adr; + +rel12adr: + addr = *(int64_t *)data - size; + if (segment == segto) + nasm_panic(0, "intra-segment OUT_REL1ADR"); + if (segment == NO_SEG) { + /* Do nothing */ + } else if (segment % 2) { + nasm_error(ERR_NONFATAL, "ELF format does not support" + " segment base references"); + } else { + if (wrt == NO_SEG) { + elf_add_reloc(s, segment, addr, reltype); + addr = 0; + } else { + nasm_error(ERR_NONFATAL, + "Unsupported non-32-bit ELF relocation"); + } + } + elf_sect_writeaddr(s, addr, bytes); + break; + + case OUT_REL4ADR: + addr = *(int64_t *)data - size; + if (segment == segto) + nasm_panic(0, "intra-segment OUT_REL4ADR"); + if (segment == NO_SEG) { + /* Do nothing */ + } else if (segment % 2) { + nasm_error(ERR_NONFATAL, "ELF64 format does not support" + " segment base references"); + } else { + if (wrt == NO_SEG) { + elf_add_reloc(s, segment, addr, R_X86_64_PC32); + addr = 0; + } else if (wrt == elf_plt_sect + 1) { + elf_add_gsym_reloc(s, segment, addr+size, size, + R_X86_64_PLT32, true); + addr = 0; + } else if (wrt == elf_gotpc_sect + 1 || + wrt == elf_got_sect + 1) { + elf_add_gsym_reloc(s, segment, addr+size, size, + R_X86_64_GOTPCREL, true); + addr = 0; + } else if (wrt == elf_gotoff_sect + 1 || + wrt == elf_got_sect + 1) { + nasm_error(ERR_NONFATAL, "ELF64 requires ..gotoff references to be " + "qword absolute"); + } else if (wrt == elf_gottpoff_sect + 1) { + elf_add_gsym_reloc(s, segment, addr+size, size, + R_X86_64_GOTTPOFF, true); + addr = 0; + } else { + nasm_error(ERR_NONFATAL, "ELF64 format does not support this" + " use of WRT"); + } + } + elf_sect_writeaddr(s, addr, 4); + break; + + case OUT_REL8ADR: + addr = *(int64_t *)data - size; + if (segment == segto) + nasm_panic(0, "intra-segment OUT_REL8ADR"); + if (segment == NO_SEG) { + /* Do nothing */ + } else if (segment % 2) { + nasm_error(ERR_NONFATAL, "ELF64 format does not support" + " segment base references"); + } else { + if (wrt == NO_SEG) { + elf_add_reloc(s, segment, addr, R_X86_64_PC64); + addr = 0; + } else if (wrt == elf_gotpc_sect + 1 || + wrt == elf_got_sect + 1) { + elf_add_gsym_reloc(s, segment, addr+size, size, + R_X86_64_GOTPCREL64, true); + addr = 0; + } else if (wrt == elf_gotoff_sect + 1 || + wrt == elf_got_sect + 1) { + nasm_error(ERR_NONFATAL, "ELF64 requires ..gotoff references to be " + "absolute"); + } else if (wrt == elf_gottpoff_sect + 1) { + nasm_error(ERR_NONFATAL, "ELF64 requires ..gottpoff references to be " + "dword"); + } else { + nasm_error(ERR_NONFATAL, "ELF64 format does not support this" + " use of WRT"); + } + } + elf_sect_writeaddr(s, addr, 8); + break; + } +} + +static void elfx32_out(int32_t segto, const void *data, + enum out_type type, uint64_t size, + int32_t segment, int32_t wrt) +{ + struct elf_section *s; + int64_t addr; + int reltype, bytes; + int i; + static struct symlininfo sinfo; + + /* + * handle absolute-assembly (structure definitions) + */ + if (segto == NO_SEG) { + if (type != OUT_RESERVE) + nasm_error(ERR_NONFATAL, "attempt to assemble code in [ABSOLUTE]" + " space"); + return; + } + + s = NULL; + for (i = 0; i < nsects; i++) + if (segto == sects[i]->index) { + s = sects[i]; + break; + } + if (!s) { + int tempint; /* ignored */ + if (segto != elf_section_names(".text", 2, &tempint)) + nasm_panic(0, "strange segment conditions in ELF driver"); + else { + s = sects[nsects - 1]; + i = nsects - 1; + } + } + + /* again some stabs debugging stuff */ + sinfo.offset = s->len; + sinfo.section = i; + sinfo.segto = segto; + sinfo.name = s->name; + dfmt->debug_output(TY_DEBUGSYMLIN, &sinfo); + /* end of debugging stuff */ + + if (s->type == SHT_NOBITS && type != OUT_RESERVE) { + nasm_error(ERR_WARNING, "attempt to initialize memory in" + " BSS section `%s': ignored", s->name); + s->len += realsize(type, size); + return; + } + + switch (type) { + case OUT_RESERVE: + if (s->type == SHT_PROGBITS) { + nasm_error(ERR_WARNING, "uninitialized space declared in" + " non-BSS section `%s': zeroing", s->name); + elf_sect_write(s, NULL, size); + } else + s->len += size; + break; + + case OUT_RAWDATA: + if (segment != NO_SEG) + nasm_panic(0, "OUT_RAWDATA with other than NO_SEG"); + elf_sect_write(s, data, size); + break; + + case OUT_ADDRESS: + { + int isize = (int)size; + int asize = abs((int)size); + + addr = *(int64_t *)data; + if (segment == NO_SEG) { + /* Do nothing */ + } else if (segment % 2) { + nasm_error(ERR_NONFATAL, "ELF format does not support" + " segment base references"); + } else { + if (wrt == NO_SEG) { + switch (isize) { + case 1: + case -1: + elf_add_reloc(s, segment, addr, R_X86_64_8); + break; + case 2: + case -2: + elf_add_reloc(s, segment, addr, R_X86_64_16); + break; + case 4: + elf_add_reloc(s, segment, addr, R_X86_64_32); + break; + case -4: + elf_add_reloc(s, segment, addr, R_X86_64_32S); + break; + case 8: + case -8: + elf_add_reloc(s, segment, addr, R_X86_64_64); + break; + default: + nasm_panic(0, "internal error elfx32-hpa-871"); + break; + } + addr = 0; + } else if (wrt == elf_gotpc_sect + 1) { + /* + * The user will supply GOT relative to $$. ELF + * will let us have GOT relative to $. So we + * need to fix up the data item by $-$$. + */ + addr += s->len; + elf_add_reloc(s, segment, addr, R_X86_64_GOTPC32); + addr = 0; + } else if (wrt == elf_gotoff_sect + 1) { + nasm_error(ERR_NONFATAL, "ELFX32 doesn't support " + "R_X86_64_GOTOFF64"); + } else if (wrt == elf_got_sect + 1) { + switch (asize) { + case 4: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_GOT32, true); + addr = 0; + break; + default: + nasm_error(ERR_NONFATAL, "invalid ..got reference"); + break; + } + } else if (wrt == elf_sym_sect + 1) { + switch (isize) { + case 1: + case -1: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_8, false); + addr = 0; + break; + case 2: + case -2: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_16, false); + addr = 0; + break; + case 4: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_32, false); + addr = 0; + break; + case -4: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_32S, false); + addr = 0; + break; + case 8: + case -8: + elf_add_gsym_reloc(s, segment, addr, 0, + R_X86_64_64, false); + addr = 0; + break; + default: + nasm_panic(0, "internal error elfx32-hpa-903"); + break; + } + } else if (wrt == elf_plt_sect + 1) { + nasm_error(ERR_NONFATAL, "ELF format cannot produce non-PC-" + "relative PLT references"); + } else { + nasm_error(ERR_NONFATAL, "ELF format does not support this" + " use of WRT"); + } + } + elf_sect_writeaddr(s, addr, asize); + break; + } + + case OUT_REL1ADR: + reltype = R_X86_64_PC8; + bytes = 1; + goto rel12adr; + + case OUT_REL2ADR: + reltype = R_X86_64_PC16; + bytes = 2; + goto rel12adr; + +rel12adr: + addr = *(int64_t *)data - size; + if (segment == segto) + nasm_panic(0, "intra-segment OUT_REL1ADR"); + if (segment == NO_SEG) { + /* Do nothing */ + } else if (segment % 2) { + nasm_error(ERR_NONFATAL, "ELF format does not support" + " segment base references"); + } else { + if (wrt == NO_SEG) { + elf_add_reloc(s, segment, addr, reltype); + addr = 0; + } else { + nasm_error(ERR_NONFATAL, + "Unsupported non-32-bit ELF relocation"); + } + } + elf_sect_writeaddr(s, addr, bytes); + break; + + case OUT_REL4ADR: + addr = *(int64_t *)data - size; + if (segment == segto) + nasm_panic(0, "intra-segment OUT_REL4ADR"); + if (segment == NO_SEG) { + /* Do nothing */ + } else if (segment % 2) { + nasm_error(ERR_NONFATAL, "ELFX32 format does not support" + " segment base references"); + } else { + if (wrt == NO_SEG) { + elf_add_reloc(s, segment, addr, R_X86_64_PC32); + addr = 0; + } else if (wrt == elf_plt_sect + 1) { + elf_add_gsym_reloc(s, segment, addr+size, size, + R_X86_64_PLT32, true); + addr = 0; + } else if (wrt == elf_gotpc_sect + 1 || + wrt == elf_got_sect + 1) { + elf_add_gsym_reloc(s, segment, addr+size, size, + R_X86_64_GOTPCREL, true); + addr = 0; + } else if (wrt == elf_gotoff_sect + 1 || + wrt == elf_got_sect + 1) { + nasm_error(ERR_NONFATAL, "invalid ..gotoff reference"); + } else if (wrt == elf_gottpoff_sect + 1) { + elf_add_gsym_reloc(s, segment, addr+size, size, + R_X86_64_GOTTPOFF, true); + addr = 0; + } else { + nasm_error(ERR_NONFATAL, "ELFX32 format does not support this" + " use of WRT"); + } + } + elf_sect_writeaddr(s, addr, 4); + break; + + case OUT_REL8ADR: + nasm_error(ERR_NONFATAL, "32-bit ELF format does not support 64-bit relocations"); + addr = 0; + elf_sect_writeaddr(s, addr, 8); + break; + } +} + +static void elf_write(void) +{ + int align; + char *p; + int i; + + struct SAA *symtab; + int32_t symtablen, symtablocal; + + /* + * Work out how many sections we will have. We have SHN_UNDEF, + * then the flexible user sections, then the fixed sections + * `.shstrtab', `.symtab' and `.strtab', then optionally + * relocation sections for the user sections. + */ + nsections = sec_numspecial + 1; + if (dfmt == &df_stabs) + nsections += 3; + else if (dfmt == &df_dwarf) + nsections += 10; + + add_sectname("", ".shstrtab"); + add_sectname("", ".symtab"); + add_sectname("", ".strtab"); + for (i = 0; i < nsects; i++) { + nsections++; /* for the section itself */ + if (sects[i]->head) { + nsections++; /* for its relocations */ + add_sectname(is_elf32() ? ".rel" : "rela", sects[i]->name); + } + } + + if (dfmt == &df_stabs) { + /* in case the debug information is wanted, just add these three sections... */ + add_sectname("", ".stab"); + add_sectname("", ".stabstr"); + add_sectname(".rel", ".stab"); + } else if (dfm... [truncated message content] |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:30
|
Commit-ID: 2f5dca5b44de67643729d14c0001707706affa26 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=2f5dca5b44de67643729d14c0001707706affa26 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Fri, 8 Apr 2016 00:44:22 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 output: Elf32 -- Shuffle few lines to make it close to other code Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 494710e..ace4630 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -819,12 +819,12 @@ static void elf_out(int32_t segto, const void *data, } case OUT_REL1ADR: - bytes = 1; reltype = R_386_PC8; + bytes = 1; goto rel12adr; case OUT_REL2ADR: - bytes = 2; reltype = R_386_PC16; + bytes = 2; goto rel12adr; rel12adr: |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:28
|
Commit-ID: bf67680049353e5c295c2de9e742211ccd9357bd Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=bf67680049353e5c295c2de9e742211ccd9357bd Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 10 Apr 2016 17:25:45 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elf32, Elfx32, Elf64 -- Rename unmergable routines Keep them separate for a while, and merge later. Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 8 ++++---- output/outelf64.c | 8 ++++---- output/outelfx32.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 9ad4869..d1cdf23 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -660,9 +660,9 @@ static int64_t elf_add_gsym_reloc(struct elf_section *sect, return r->offset; } -static void elf_out(int32_t segto, const void *data, - enum out_type type, uint64_t size, - int32_t segment, int32_t wrt) +static void elf32_out(int32_t segto, const void *data, + enum out_type type, uint64_t size, + int32_t segment, int32_t wrt) { struct elf_section *s; int64_t addr; @@ -1374,7 +1374,7 @@ const struct ofmt of_elf32 = { elf_stdmac, elf_init, elf_set_info, - elf_out, + elf32_out, elf_deflabel, elf_section_names, elf_sectalign, diff --git a/output/outelf64.c b/output/outelf64.c index e05a849..db3ae2a 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -660,9 +660,9 @@ static int64_t elf_add_gsym_reloc(struct elf_section *sect, return r->offset; } -static void elf_out(int32_t segto, const void *data, - enum out_type type, uint64_t size, - int32_t segment, int32_t wrt) +static void elf64_out(int32_t segto, const void *data, + enum out_type type, uint64_t size, + int32_t segment, int32_t wrt) { struct elf_section *s; int64_t addr; @@ -1445,7 +1445,7 @@ const struct ofmt of_elf64 = { elf_stdmac, elf_init, elf_set_info, - elf_out, + elf64_out, elf_deflabel, elf_section_names, elf_sectalign, diff --git a/output/outelfx32.c b/output/outelfx32.c index eea9b7f..711a73b 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -660,9 +660,9 @@ static int64_t elf_add_gsym_reloc(struct elf_section *sect, return r->offset; } -static void elf_out(int32_t segto, const void *data, - enum out_type type, uint64_t size, - int32_t segment, int32_t wrt) +static void elfx32_out(int32_t segto, const void *data, + enum out_type type, uint64_t size, + int32_t segment, int32_t wrt) { struct elf_section *s; int64_t addr; @@ -1406,7 +1406,7 @@ const struct ofmt of_elfx32 = { elf_stdmac, elf_init, elf_set_info, - elf_out, + elfx32_out, elf_deflabel, elf_section_names, elf_sectalign, |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:27
|
Commit-ID: 73a8662987dabdce8028da468eb02f251540f496 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=73a8662987dabdce8028da468eb02f251540f496 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Fri, 8 Apr 2016 01:11:39 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 output: Elf32, Elfx32 -- Use 64 bit address Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 26 ++++++++++---------------- output/outelfx32.c | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index ace4630..9ad4869 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -665,8 +665,7 @@ static void elf_out(int32_t segto, const void *data, int32_t segment, int32_t wrt) { struct elf_section *s; - int32_t addr; - uint8_t mydata[8], *p; + int64_t addr; int reltype, bytes; int i; static struct symlininfo sinfo; @@ -712,8 +711,6 @@ static void elf_out(int32_t segto, const void *data, return; } - memset(mydata, 0, sizeof(mydata)); - switch (type) { case OUT_RESERVE: if (s->type == SHT_PROGBITS) { @@ -734,6 +731,7 @@ static void elf_out(int32_t segto, const void *data, { bool gnu16 = false; int asize = abs((int)size); + addr = *(int64_t *)data; if (segment != NO_SEG) { if (segment % 2) { @@ -806,15 +804,14 @@ static void elf_out(int32_t segto, const void *data, } } } - p = mydata; + if (gnu16) { nasm_error(ERR_WARNING | ERR_WARN_GNUELF, "8- or 16-bit relocations in ELF32 is a GNU extension"); } else if (asize != 4 && segment != NO_SEG) { nasm_error(ERR_NONFATAL, "Unsupported non-32-bit ELF relocation"); } - WRITEADDR(p, addr, asize); - elf_sect_write(s, mydata, asize); + elf_sect_writeaddr(s, addr, asize); break; } @@ -828,6 +825,7 @@ static void elf_out(int32_t segto, const void *data, goto rel12adr; rel12adr: + addr = *(int64_t *)data - size; nasm_assert(segment != segto); if (segment != NO_SEG && segment % 2) { nasm_error(ERR_NONFATAL, "ELF format does not support" @@ -842,12 +840,11 @@ static void elf_out(int32_t segto, const void *data, "Unsupported non-32-bit ELF relocation"); } } - p = mydata; - WRITESHORT(p, *(int64_t *)data - size); - elf_sect_write(s, mydata, bytes); + elf_sect_writeaddr(s, addr, bytes); break; case OUT_REL4ADR: + addr = *(int64_t *)data - size; if (segment == segto) nasm_panic(0, "intra-segment OUT_REL4ADR"); if (segment != NO_SEG && segment % 2) { @@ -869,17 +866,14 @@ static void elf_out(int32_t segto, const void *data, wrt = NO_SEG; /* we can at least _try_ to continue */ } } - p = mydata; - WRITELONG(p, *(int64_t *)data - size); - elf_sect_write(s, mydata, 4L); + elf_sect_writeaddr(s, addr, 4); break; case OUT_REL8ADR: nasm_error(ERR_NONFATAL, "32-bit ELF format does not support 64-bit relocations"); - p = mydata; - WRITEDLONG(p, 0); - elf_sect_write(s, mydata, 8L); + addr = 0; + elf_sect_writeaddr(s, addr, 8); break; } } diff --git a/output/outelfx32.c b/output/outelfx32.c index 45a949b..5e16561 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -666,7 +666,7 @@ static void elf_out(int32_t segto, const void *data, int32_t segment, int32_t wrt) { struct elf_section *s; - int32_t addr; + int64_t addr; int reltype, bytes; int i; static struct symlininfo sinfo; |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:27
|
Commit-ID: 2fd62aaff6c7dc77992ea0abead40fbf4ed5d38b Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=2fd62aaff6c7dc77992ea0abead40fbf4ed5d38b Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 10 Apr 2016 17:22:49 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elfx32 -- Unify dwarf_ types Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelfx32.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/output/outelfx32.c b/output/outelfx32.c index 5e16561..eea9b7f 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -153,8 +153,7 @@ static uint8_t *arangesbuf = 0, *arangesrelbuf = 0, *pubnamesbuf = 0, *infobuf = static int8_t line_base = -5, line_range = 14, opcode_base = 13; static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, abbrevlen, linelen, linerellen, framelen, loclen; -static int32_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; - +static int64_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; static const struct dfmt df_dwarf; static const struct dfmt df_stabs; |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:27
|
Commit-ID: dbcaefc98c1dc6fcf8ea5aa555d3358b4425d9a5 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=dbcaefc98c1dc6fcf8ea5aa555d3358b4425d9a5 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 22:43:56 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elf32, Elfx32, Elf64 -- Unify elf_init and elf_deflabel Note FIXMEs for address later. Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 12 +++++++++++- output/outelf64.c | 12 +++++++++++- output/outelfx32.c | 20 ++++++++++++++------ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index afd9438..67c0907 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -200,6 +200,11 @@ static void elf_init(void) fwds = NULL; + /* + * FIXME: tlsie is Elf32 only and + * gottpoff is Elfx32|64 only. + */ + elf_gotpc_sect = seg_alloc(); define_label("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false); elf_gotoff_sect = seg_alloc(); @@ -210,6 +215,8 @@ static void elf_init(void) define_label("..plt", elf_plt_sect + 1, 0L, NULL, false, false); elf_sym_sect = seg_alloc(); define_label("..sym", elf_sym_sect + 1, 0L, NULL, false, false); + elf_gottpoff_sect = seg_alloc(); + define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false); elf_tlsie_sect = seg_alloc(); define_label("..tlsie", elf_tlsie_sect + 1, 0L, NULL, false, false); @@ -351,10 +358,13 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, * This is a NASM special symbol. We never allow it into * the ELF symbol table, even if it's a valid one. If it * _isn't_ a valid one, we should barf immediately. + * + * FIXME: tlsie is Elf32 only, and gottpoff is Elfx32|64 only. */ if (strcmp(name, "..gotpc") && strcmp(name, "..gotoff") && strcmp(name, "..got") && strcmp(name, "..plt") && - strcmp(name, "..sym") && strcmp(name, "..tlsie")) + strcmp(name, "..sym") && strcmp(name, "..gottpoff") && + strcmp(name, "..tlsie")) nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name); return; } diff --git a/output/outelf64.c b/output/outelf64.c index 93696b1..460dc01 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -200,6 +200,11 @@ static void elf_init(void) fwds = NULL; + /* + * FIXME: tlsie is Elf32 only and + * gottpoff is Elfx32|64 only. + */ + elf_gotpc_sect = seg_alloc(); define_label("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false); elf_gotoff_sect = seg_alloc(); @@ -212,6 +217,8 @@ static void elf_init(void) define_label("..sym", elf_sym_sect + 1, 0L, NULL, false, false); elf_gottpoff_sect = seg_alloc(); define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false); + elf_tlsie_sect = seg_alloc(); + define_label("..tlsie", elf_tlsie_sect + 1, 0L, NULL, false, false); def_seg = seg_alloc(); } @@ -351,10 +358,13 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, * This is a NASM special symbol. We never allow it into * the ELF symbol table, even if it's a valid one. If it * _isn't_ a valid one, we should barf immediately. + * + * FIXME: tlsie is Elf32 only, and gottpoff is Elfx32|64 only. */ if (strcmp(name, "..gotpc") && strcmp(name, "..gotoff") && strcmp(name, "..got") && strcmp(name, "..plt") && - strcmp(name, "..sym") && strcmp(name, "..gottpoff")) + strcmp(name, "..sym") && strcmp(name, "..gottpoff") && + strcmp(name, "..tlsie")) nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name); return; } diff --git a/output/outelfx32.c b/output/outelfx32.c index 2df8607..ed1a99e 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -177,14 +177,12 @@ static void dwarf_findfile(const char *); static void dwarf_findsect(const int); /* - * Special section numbers which are used to define ELF special - * symbols, which can be used with WRT to provide PIC relocation - * types. + * Special NASM section numbers which are used to define ELF special + * symbols. */ static int32_t elf_gotpc_sect, elf_gotoff_sect; static int32_t elf_got_sect, elf_plt_sect; -static int32_t elf_sym_sect; -static int32_t elf_gottpoff_sect; +static int32_t elf_sym_sect, elf_gottpoff_sect, elf_tlsie_sect; static void elf_init(void) { @@ -203,6 +201,11 @@ static void elf_init(void) fwds = NULL; + /* + * FIXME: tlsie is Elf32 only and + * gottpoff is Elfx32|64 only. + */ + elf_gotpc_sect = seg_alloc(); define_label("..gotpc", elf_gotpc_sect + 1, 0L, NULL, false, false); elf_gotoff_sect = seg_alloc(); @@ -215,6 +218,8 @@ static void elf_init(void) define_label("..sym", elf_sym_sect + 1, 0L, NULL, false, false); elf_gottpoff_sect = seg_alloc(); define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false); + elf_tlsie_sect = seg_alloc(); + define_label("..tlsie", elf_tlsie_sect + 1, 0L, NULL, false, false); def_seg = seg_alloc(); } @@ -354,10 +359,13 @@ static void elf_deflabel(char *name, int32_t segment, int64_t offset, * This is a NASM special symbol. We never allow it into * the ELF symbol table, even if it's a valid one. If it * _isn't_ a valid one, we should barf immediately. + * + * FIXME: tlsie is Elf32 only, and gottpoff is Elfx32|64 only. */ if (strcmp(name, "..gotpc") && strcmp(name, "..gotoff") && strcmp(name, "..got") && strcmp(name, "..plt") && - strcmp(name, "..sym") && strcmp(name, "..gottpoff")) + strcmp(name, "..sym") && strcmp(name, "..gottpoff") && + strcmp(name, "..tlsie")) nasm_error(ERR_NONFATAL, "unrecognised special symbol `%s'", name); return; } |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:26
|
Commit-ID: 5ae676ebd1d29b6800c4f2161fd4f218afd32b42 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=5ae676ebd1d29b6800c4f2161fd4f218afd32b42 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Thu, 7 Apr 2016 00:15:44 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 output: Elf32, Elfx32 -- Unify elf_add_gsym_reloc Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 37 ++++++++++++++++++------------------- output/outelf64.c | 13 +++++++------ output/outelfx32.c | 13 +++++++------ 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 4f959cd..494710e 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -607,9 +607,9 @@ static void elf_add_reloc(struct elf_section *sect, int32_t segment, * Inefficiency: we search, currently, using a linked list which * isn't even necessarily sorted. */ -static int32_t elf_add_gsym_reloc(struct elf_section *sect, - int32_t segment, uint32_t offset, - int type, bool exact) +static int64_t elf_add_gsym_reloc(struct elf_section *sect, + int32_t segment, uint64_t offset, int64_t pcrel, + int type, bool exact) { struct elf_reloc *r; struct elf_section *s; @@ -633,11 +633,10 @@ static int32_t elf_add_gsym_reloc(struct elf_section *sect, if (!s) { if (exact && offset) - nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol" - " for this reference"); + nasm_error(ERR_NONFATAL, "invalid access to an external symbol"); else - elf_add_reloc(sect, segment, 0, type); - return offset; + elf_add_reloc(sect, segment, offset - pcrel, type); + return 0; } srb = rb_search(s->gsyms, offset); @@ -653,12 +652,12 @@ static int32_t elf_add_gsym_reloc(struct elf_section *sect, r->next = NULL; r->address = sect->len; + r->offset = offset - pcrel - sym->symv.key; r->symbol = GLOBAL_TEMP_BASE + sym->globnum; r->type = type; sect->nrelocs++; - - return offset - sym->symv.key; + return r->offset; } static void elf_out(int32_t segto, const void *data, @@ -773,26 +772,26 @@ static void elf_out(int32_t segto, const void *data, } else if (wrt == elf_gotoff_sect + 1) { elf_add_reloc(s, segment, 0, R_386_GOTOFF); } else if (wrt == elf_tlsie_sect + 1) { - addr = elf_add_gsym_reloc(s, segment, addr, - R_386_TLS_IE, true); + addr = elf_add_gsym_reloc(s, segment, addr, 0, + R_386_TLS_IE, true); } else if (wrt == elf_got_sect + 1) { - addr = elf_add_gsym_reloc(s, segment, addr, - R_386_GOT32, true); + addr = elf_add_gsym_reloc(s, segment, addr, 0, + R_386_GOT32, true); } else if (wrt == elf_sym_sect + 1) { switch (asize) { case 1: gnu16 = true; - addr = elf_add_gsym_reloc(s, segment, addr, - R_386_8, false); + addr = elf_add_gsym_reloc(s, segment, addr, 0, + R_386_8, false); break; case 2: gnu16 = true; - addr = elf_add_gsym_reloc(s, segment, addr, - R_386_16, false); + addr = elf_add_gsym_reloc(s, segment, addr, 0, + R_386_16, false); break; case 4: - addr = elf_add_gsym_reloc(s, segment, addr, - R_386_32, false); + addr = elf_add_gsym_reloc(s, segment, addr, 0, + R_386_32, false); break; default: break; diff --git a/output/outelf64.c b/output/outelf64.c index 4730bf6..e05a849 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -607,9 +607,9 @@ static void elf_add_reloc(struct elf_section *sect, int32_t segment, * Inefficiency: we search, currently, using a linked list which * isn't even necessarily sorted. */ -static void elf_add_gsym_reloc(struct elf_section *sect, - int32_t segment, uint64_t offset, int64_t pcrel, - int type, bool exact) +static int64_t elf_add_gsym_reloc(struct elf_section *sect, + int32_t segment, uint64_t offset, int64_t pcrel, + int type, bool exact) { struct elf_reloc *r; struct elf_section *s; @@ -636,27 +636,28 @@ static void elf_add_gsym_reloc(struct elf_section *sect, nasm_error(ERR_NONFATAL, "invalid access to an external symbol"); else elf_add_reloc(sect, segment, offset - pcrel, type); - return; + return 0; } srb = rb_search(s->gsyms, offset); if (!srb || (exact && srb->key != offset)) { nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol" " for this reference"); - return; + return 0; } sym = container_of(srb, struct elf_symbol, symv); r = *sect->tail = nasm_malloc(sizeof(struct elf_reloc)); sect->tail = &r->next; - r->next = NULL; + r->next = NULL; r->address = sect->len; r->offset = offset - pcrel - sym->symv.key; r->symbol = GLOBAL_TEMP_BASE + sym->globnum; r->type = type; sect->nrelocs++; + return r->offset; } static void elf_out(int32_t segto, const void *data, diff --git a/output/outelfx32.c b/output/outelfx32.c index 99d92a7..45a949b 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -608,9 +608,9 @@ static void elf_add_reloc(struct elf_section *sect, int32_t segment, * Inefficiency: we search, currently, using a linked list which * isn't even necessarily sorted. */ -static void elf_add_gsym_reloc(struct elf_section *sect, - int32_t segment, uint32_t offset, int32_t pcrel, - int type, bool exact) +static int64_t elf_add_gsym_reloc(struct elf_section *sect, + int32_t segment, uint64_t offset, int64_t pcrel, + int type, bool exact) { struct elf_reloc *r; struct elf_section *s; @@ -637,27 +637,28 @@ static void elf_add_gsym_reloc(struct elf_section *sect, nasm_error(ERR_NONFATAL, "invalid access to an external symbol"); else elf_add_reloc(sect, segment, offset - pcrel, type); - return; + return 0; } srb = rb_search(s->gsyms, offset); if (!srb || (exact && srb->key != offset)) { nasm_error(ERR_NONFATAL, "unable to find a suitable global symbol" " for this reference"); - return; + return 0; } sym = container_of(srb, struct elf_symbol, symv); r = *sect->tail = nasm_malloc(sizeof(struct elf_reloc)); sect->tail = &r->next; - r->next = NULL; + r->next = NULL; r->address = sect->len; r->offset = offset - pcrel - sym->symv.key; r->symbol = GLOBAL_TEMP_BASE + sym->globnum; r->type = type; sect->nrelocs++; + return r->offset; } static void elf_out(int32_t segto, const void *data, |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:25
|
Commit-ID: 5416e3981142c5794801f5be6dbd3ff0816c8142 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=5416e3981142c5794801f5be6dbd3ff0816c8142 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Wed, 16 Mar 2016 01:54:15 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elf32 -- A few more constants usage Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 12255fd..4f959cd 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -945,8 +945,8 @@ static void elf_write(void) fputc(elf_osabi, ofile); fputc(elf_abiver, ofile); fwritezero(7, ofile); - fwriteint16_t(1, ofile); /* ET_REL relocatable file */ - fwriteint16_t(3, ofile); /* EM_386 processor ID */ + fwriteint16_t(ET_REL, ofile); /* relocatable file */ + fwriteint16_t(EM_386, ofile); /* processor ID */ fwriteint32_t(1L, ofile); /* EV_CURRENT file format version */ fwriteint32_t(0L, ofile); /* no entry point */ fwriteint32_t(0L, ofile); /* no program header table */ @@ -956,7 +956,7 @@ static void elf_write(void) fwriteint16_t(0x34, ofile); /* size of ELF header */ fwriteint16_t(0, ofile); /* no program header table, again */ fwriteint16_t(0, ofile); /* still no program header table */ - fwriteint16_t(0x28, ofile); /* size of section header */ + fwriteint16_t(sizeof(Elf32_Shdr), ofile); /* size of section header */ fwriteint16_t(nsections, ofile); /* number of sections */ fwriteint16_t(sec_shstrtab, ofile); /* string table section index for * section header table */ |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:24
|
Commit-ID: 5941092b061e1823f2d3953ddb7e850d495854d0 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=5941092b061e1823f2d3953ddb7e850d495854d0 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 22:47:36 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elf64, Elfx32 -- Drop useless DEBUG We rather need a trace engine. Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf64.c | 11 ----------- output/outelfx32.c | 11 ----------- 2 files changed, 22 deletions(-) diff --git a/output/outelf64.c b/output/outelf64.c index 460dc01..91d50e8 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -667,17 +667,6 @@ static void elf_out(int32_t segto, const void *data, int i; static struct symlininfo sinfo; -#if defined(DEBUG) && DEBUG>2 - if (data) - nasm_error(ERR_DEBUG, - " elf_out line: %d type: %x seg: %"PRIx32" segto: %"PRIx32" bytes: %"PRIx64" data: %"PRIx64"\n", - currentline, type, segment, segto, size, *(int64_t *)data); - else - nasm_error(ERR_DEBUG, - " elf_out line: %d type: %x seg: %"PRIx32" segto: %"PRIx32" bytes: %"PRIx64"\n", - currentline, type, segment, segto, size); -#endif - /* * handle absolute-assembly (structure definitions) */ diff --git a/output/outelfx32.c b/output/outelfx32.c index ed1a99e..b5f62a6 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -668,17 +668,6 @@ static void elf_out(int32_t segto, const void *data, int i; static struct symlininfo sinfo; -#if defined(DEBUG) && DEBUG>2 - if (data) - nasm_error(ERR_DEBUG, - " elf_out line: %d type: %x seg: %"PRIx32" segto: %"PRIx32" bytes: %"PRIx64" data: %"PRIx64"\n", - currentline, type, segment, segto, size, *(int64_t *)data); - else - nasm_error(ERR_DEBUG, - " elf_out line: %d type: %x seg: %"PRIx32" segto: %"PRIx32" bytes: %"PRIx64"\n", - currentline, type, segment, segto, size); -#endif - /* * handle absolute-assembly (structure definitions) */ |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:24
|
Commit-ID: 17823c3129fbeede7b483247646707d7c446f220 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=17823c3129fbeede7b483247646707d7c446f220 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Wed, 16 Mar 2016 00:36:01 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 output: Elf32, Elfx32, Elf64 -- Declare ofmt for all Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 2 ++ output/outelf64.c | 2 ++ output/outelfx32.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/output/outelf32.c b/output/outelf32.c index 67c0907..12255fd 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -83,6 +83,8 @@ static struct elf_symbol *fwds; static char elf_module[FILENAME_MAX]; extern const struct ofmt of_elf32; +extern const struct ofmt of_elf64; +extern const struct ofmt of_elfx32; static struct ELF_SECTDATA { void *data; diff --git a/output/outelf64.c b/output/outelf64.c index 91d50e8..4730bf6 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -82,7 +82,9 @@ static struct elf_symbol *fwds; static char elf_module[FILENAME_MAX]; +extern const struct ofmt of_elf32; extern const struct ofmt of_elf64; +extern const struct ofmt of_elfx32; static struct ELF_SECTDATA { void *data; diff --git a/output/outelfx32.c b/output/outelfx32.c index b5f62a6..99d92a7 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -82,6 +82,8 @@ static struct elf_symbol *fwds; static char elf_module[FILENAME_MAX]; +extern const struct ofmt of_elf32; +extern const struct ofmt of_elf64; extern const struct ofmt of_elfx32; static struct ELF_SECTDATA { |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:22
|
Commit-ID: 23a80d399e575388084ece05a87f409e5585c4cd Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=23a80d399e575388084ece05a87f409e5585c4cd Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 13:45:03 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elf32 -- Unify dwarf_ nums Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 2 +- output/outelf64.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 2868090..afd9438 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -151,7 +151,7 @@ static uint8_t *arangesbuf = 0, *arangesrelbuf = 0, *pubnamesbuf = 0, *infobuf = static int8_t line_base = -5, line_range = 14, opcode_base = 13; static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, abbrevlen, linelen, linerellen, framelen, loclen; -static int32_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; +static int64_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; static const struct dfmt df_dwarf; static const struct dfmt df_stabs; diff --git a/output/outelf64.c b/output/outelf64.c index fd23502..93696b1 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -153,7 +153,6 @@ static int arangeslen, arangesrellen, pubnameslen, infolen, inforellen, abbrevlen, linelen, linerellen, framelen, loclen; static int64_t dwarf_infosym, dwarf_abbrevsym, dwarf_linesym; - static const struct dfmt df_dwarf; static const struct dfmt df_stabs; static struct elf_symbol *lastsym; |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:22
|
Commit-ID: ca40da311b81f976828cd23843499c5a551bfb23 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=ca40da311b81f976828cd23843499c5a551bfb23 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 13:43:14 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elf32, Elfx32, Elf64 -- more unifications Some elf_ section numbers may be unused. Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 7 +++---- output/outelf64.c | 12 +++++------- output/outelfx32.c | 6 +++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 3d72f6c..2868090 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -177,12 +177,11 @@ static void dwarf_findsect(const int); /* * Special NASM section numbers which are used to define ELF special - * symbols, which can be used with WRT to provide PIC and TLS - * relocation types. + * symbols. */ static int32_t elf_gotpc_sect, elf_gotoff_sect; static int32_t elf_got_sect, elf_plt_sect; -static int32_t elf_sym_sect, elf_tlsie_sect; +static int32_t elf_sym_sect, elf_gottpoff_sect, elf_tlsie_sect; static void elf_init(void) { @@ -297,7 +296,7 @@ static int32_t elf_section_names(char *name, int pass, int *bits) flags_and = flags_or = type = align = 0; elf_section_attrib(name, p, pass, &flags_and, - &flags_or, &align, &type); + &flags_or, &align, &type); if (!strcmp(name, ".shstrtab") || !strcmp(name, ".symtab") || diff --git a/output/outelf64.c b/output/outelf64.c index cfb6e57..fd23502 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -177,14 +177,12 @@ static void dwarf_findfile(const char *); static void dwarf_findsect(const int); /* - * Special section numbers which are used to define ELF special - * symbols, which can be used with WRT to provide PIC relocation - * types. + * Special NASM section numbers which are used to define ELF special + * symbols. */ static int32_t elf_gotpc_sect, elf_gotoff_sect; static int32_t elf_got_sect, elf_plt_sect; -static int32_t elf_sym_sect; -static int32_t elf_gottpoff_sect; +static int32_t elf_sym_sect, elf_gottpoff_sect, elf_tlsie_sect; static void elf_init(void) { @@ -328,8 +326,8 @@ static int32_t elf_section_names(char *name, int pass, int *bits) i = elf_make_section(name, type, flags, align); } else if (pass == 1) { if ((type && sects[i]->type != type) - || (align && sects[i]->align != align) - || (flags_and && ((sects[i]->flags & flags_and) != flags_or))) + || (align && sects[i]->align != align) + || (flags_and && ((sects[i]->flags & flags_and) != flags_or))) nasm_error(ERR_WARNING, "incompatible section attributes ignored on" " redeclaration of section `%s'", name); } diff --git a/output/outelfx32.c b/output/outelfx32.c index 3a0bac8..2df8607 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -299,7 +299,7 @@ static int32_t elf_section_names(char *name, int pass, int *bits) flags_and = flags_or = type = align = 0; elf_section_attrib(name, p, pass, &flags_and, - &flags_or, &align, &type); + &flags_or, &align, &type); if (!strcmp(name, ".shstrtab") || !strcmp(name, ".symtab") || @@ -328,8 +328,8 @@ static int32_t elf_section_names(char *name, int pass, int *bits) i = elf_make_section(name, type, flags, align); } else if (pass == 1) { if ((type && sects[i]->type != type) - || (align && sects[i]->align != align) - || (flags_and && ((sects[i]->flags & flags_and) != flags_or))) + || (align && sects[i]->align != align) + || (flags_and && ((sects[i]->flags & flags_and) != flags_or))) nasm_error(ERR_WARNING, "incompatible section attributes ignored on" " redeclaration of section `%s'", name); } |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:22
|
Commit-ID: c154d94a2c3b801f2b23bb2ba920decb6e78abbc Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=c154d94a2c3b801f2b23bb2ba920decb6e78abbc Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 11:12:06 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elf64, Elfx32 -- Style fix Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf64.c | 4 +--- output/outelfx32.c | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/output/outelf64.c b/output/outelf64.c index 7aed5a2..cfb6e57 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -217,7 +217,6 @@ static void elf_init(void) define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false); def_seg = seg_alloc(); - } static void elf_cleanup(void) @@ -1835,8 +1834,7 @@ static void dwarf_generate(void) psect = dwarf_fsect; totlen = 0; highaddr = 0; - for (indx = 0; indx < dwarf_nsections; indx++) - { + for (indx = 0; indx < dwarf_nsections; indx++) { plinep = psect->psaa; /* Line Number Program Epilogue */ saa_write8(plinep,2); /* std op 2 */ diff --git a/output/outelfx32.c b/output/outelfx32.c index 1c504db..5e83239 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -217,7 +217,6 @@ static void elf_init(void) define_label("..gottpoff", elf_gottpoff_sect + 1, 0L, NULL, false, false); def_seg = seg_alloc(); - } static void elf_cleanup(void) |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:22
|
Commit-ID: adbdf0215612790dd4c87b40c22a646b2f03785a Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=adbdf0215612790dd4c87b40c22a646b2f03785a Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 11:27:12 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elf32, Elfx32 -- Unify elf_sect_write, elf_section_header and add elf_sect_writeaddr elf_sect_writeaddr is unused by now. Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 19 ++++++++++++------- output/outelfx32.c | 11 ++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 67cdaa3..3d72f6c 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -93,9 +93,9 @@ static int elf_nsect, nsections; static int64_t elf_foffs; static void elf_write(void); -static void elf_sect_write(struct elf_section *, const uint8_t *, - uint32_t); -static void elf_section_header(int, int, int, void *, bool, int32_t, int, int, +static void elf_sect_write(struct elf_section *, const void *, size_t); +static void elf_sect_writeaddr(struct elf_section *, int64_t, size_t); +static void elf_section_header(int, int, uint64_t, void *, bool, uint64_t, int, int, int, int); static void elf_write_sections(void); static struct SAA *elf_build_symtab(int32_t *, int32_t *); @@ -1246,8 +1246,8 @@ static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r) return s; } -static void elf_section_header(int name, int type, int flags, - void *data, bool is_saa, int32_t datalen, +static void elf_section_header(int name, int type, uint64_t flags, + void *data, bool is_saa, uint64_t datalen, int link, int info, int align, int eltsize) { elf_sects[elf_nsect].data = data; @@ -1285,13 +1285,18 @@ static void elf_write_sections(void) } } -static void elf_sect_write(struct elf_section *sect, - const uint8_t *data, uint32_t len) +static void elf_sect_write(struct elf_section *sect, const void *data, size_t len) { saa_wbytes(sect->data, data, len); sect->len += len; } +static void elf_sect_writeaddr(struct elf_section *sect, int64_t data, size_t len) +{ + saa_writeaddr(sect->data, data, len); + sect->len += len; +} + static void elf_sectalign(int32_t seg, unsigned int value) { struct elf_section *s = NULL; diff --git a/output/outelfx32.c b/output/outelfx32.c index 5e83239..3a0bac8 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -94,8 +94,8 @@ static int64_t elf_foffs; static void elf_write(void); static void elf_sect_write(struct elf_section *, const void *, size_t); -static void elf_sect_writeaddr(struct elf_section *, int32_t, size_t); -static void elf_section_header(int, int, uint32_t, void *, bool, uint32_t, int, int, +static void elf_sect_writeaddr(struct elf_section *, int64_t, size_t); +static void elf_section_header(int, int, uint64_t, void *, bool, uint64_t, int, int, int, int); static void elf_write_sections(void); static struct SAA *elf_build_symtab(int32_t *, int32_t *); @@ -1283,8 +1283,8 @@ static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r) return s; } -static void elf_section_header(int name, int type, uint32_t flags, - void *data, bool is_saa, uint32_t datalen, +static void elf_section_header(int name, int type, uint64_t flags, + void *data, bool is_saa, uint64_t datalen, int link, int info, int align, int eltsize) { elf_sects[elf_nsect].data = data; @@ -1327,7 +1327,8 @@ static void elf_sect_write(struct elf_section *sect, const void *data, size_t le saa_wbytes(sect->data, data, len); sect->len += len; } -static void elf_sect_writeaddr(struct elf_section *sect, int32_t data, size_t len) + +static void elf_sect_writeaddr(struct elf_section *sect, int64_t data, size_t len) { saa_writeaddr(sect->data, data, len); sect->len += len; |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-21 06:18:21
|
Commit-ID: 81bd70049524f8eeccac12e005001f8606203240 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=81bd70049524f8eeccac12e005001f8606203240 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 10:27:50 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Mon, 11 Apr 2016 00:07:14 +0300 out: Elf32, Elfx32 -- Unify struct ELF_SECTDATA and @elf_foffs Use int64_t. Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf32.c | 4 ++-- output/outelfx32.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/output/outelf32.c b/output/outelf32.c index 961c883..67cdaa3 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -86,11 +86,11 @@ extern const struct ofmt of_elf32; static struct ELF_SECTDATA { void *data; - int32_t len; + int64_t len; bool is_saa; } *elf_sects; static int elf_nsect, nsections; -static int32_t elf_foffs; +static int64_t elf_foffs; static void elf_write(void); static void elf_sect_write(struct elf_section *, const uint8_t *, diff --git a/output/outelfx32.c b/output/outelfx32.c index 37d5dca..1c504db 100644 --- a/output/outelfx32.c +++ b/output/outelfx32.c @@ -86,11 +86,11 @@ extern const struct ofmt of_elfx32; static struct ELF_SECTDATA { void *data; - int32_t len; + int64_t len; bool is_saa; } *elf_sects; static int elf_nsect, nsections; -static int32_t elf_foffs; +static int64_t elf_foffs; static void elf_write(void); static void elf_sect_write(struct elf_section *, const void *, size_t); |