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. H. P. A. <hp...@li...> - 2016-05-09 21:15:18
|
Commit-ID: 3736895c07537856b3ce035258485dd5cfd8af9a Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=3736895c07537856b3ce035258485dd5cfd8af9a Author: H. Peter Anvin <hp...@li...> AuthorDate: Mon, 9 May 2016 14:10:32 -0700 Committer: H. Peter Anvin <hp...@li...> CommitDate: Mon, 9 May 2016 14:10:32 -0700 Fix and clean up listing of macro expansion Fix the printing of the macro stack: we need to follow the mstk->next_active list, not mstk->next, and we need to reverse the order so that the highest-level inclusion comes first. Since this should be a rare or at least performance-insensitive operation, do it using simple function recursion. Finally, add an ellipsis before the "from macro" message; it greatly enhances readability. Signed-off-by: H. Peter Anvin <hp...@li...> --- preproc.c | 24 ++++++++++++++++-------- test/macroerr.asm | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/preproc.c b/preproc.c index fa2dcaf..e33a6d7 100644 --- a/preproc.c +++ b/preproc.c @@ -5243,9 +5243,23 @@ static void make_tok_num(Token * tok, int64_t val) tok->type = TOK_NUMBER; } +static void pp_list_one_macro(MMacro *m, int severity) +{ + if (!m) + return; + + /* We need to print the next_active list in reverse order */ + pp_list_one_macro(m->next_active, severity); + + if (m->name && !m->nolist) { + src_set_linnum(m->xline + m->lineno); + src_set_fname(m->fname); + nasm_error(severity, "... from macro `%s' defined here", m->name); + } +} + static void pp_error_list_macros(int severity) { - MMacro *m; int32_t saved_line; const char *saved_fname = NULL; @@ -5253,13 +5267,7 @@ static void pp_error_list_macros(int severity) saved_line = src_get_linnum(); saved_fname = src_get_fname(); - list_for_each(m, istk->mstk) { - if (m->name && !m->nolist) { - src_set_linnum(m->xline + m->lineno); - src_set_fname(m->fname); - nasm_error(severity, "from macro `%s' defined here", m->name); - } - } + pp_list_one_macro(istk->mstk, severity); src_set_fname((char *)saved_fname); src_set_linnum(saved_line); diff --git a/test/macroerr.asm b/test/macroerr.asm index 5f1c93e..d1be751 100644 --- a/test/macroerr.asm +++ b/test/macroerr.asm @@ -2,6 +2,7 @@ %macro bluttan 1 mov eax,%1 + blej %1 %endmacro bluttan ptr |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-05-09 19:15:16
|
Commit-ID: b4f734fb844dbc4cc29304e952b33aa9fc96e398 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=b4f734fb844dbc4cc29304e952b33aa9fc96e398 Author: H. Peter Anvin <hp...@li...> AuthorDate: Mon, 9 May 2016 12:13:08 -0700 Committer: H. Peter Anvin <hp...@li...> CommitDate: Mon, 9 May 2016 12:13:08 -0700 Ignore unrecognized warning names If we get an invalid warning name passed to the -w/-W option or the [warning] directive, ignore it. This may be a warning name enabled in a future version of NASM, and it is rather pointless to error out on it. Signed-off-by: H. Peter Anvin <hp...@li...> --- nasm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nasm.c b/nasm.c index 2c7b22a..f46cf4f 100644 --- a/nasm.c +++ b/nasm.c @@ -893,8 +893,7 @@ set_warning: for (i = 1; i <= ERR_WARN_MAX; i++) warning_on_global[i] = !do_warn; } else { - nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE, - "invalid warning `%s'", param); + /* Ignore invalid warning names; forward compatibility */ } break; @@ -1518,9 +1517,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) warning_on[i] = warning_on_global[i]; break; } - } else - nasm_error(ERR_NONFATAL, - "invalid warning id in WARNING directive"); + } break; case D_CPU: /* [CPU] */ cpu = get_cpu(value); |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-05-09 19:12:17
|
Commit-ID: 19bc9de9d083af623cc97289b4bda523fa471a8b Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=19bc9de9d083af623cc97289b4bda523fa471a8b Author: H. Peter Anvin <hp...@li...> AuthorDate: Mon, 9 May 2016 12:09:04 -0700 Committer: H. Peter Anvin <hp...@li...> CommitDate: Mon, 9 May 2016 12:09:04 -0700 doc/changes.src: document PTR warning Signed-off-by: H. Peter Anvin <hp...@li...> --- doc/changes.src | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/changes.src b/doc/changes.src index 1010409..ab43d60 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -17,6 +17,10 @@ since 2007. \b More Codeview debug format fixes. +\b If the MASM PTR keyword is encountered, issue a warning. This is + much more likely to indicate a MASM-ism encountered in NASM than it + is a valid label. This warning can be suppressed with -w-ptr. + \S{cl-2.12.01} Version 2.12.01 |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-05-09 19:09:18
|
Commit-ID: 69550eac55056ab1fac7bdc1b01da0e68418cd6f Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=69550eac55056ab1fac7bdc1b01da0e68418cd6f Author: H. Peter Anvin <hp...@li...> AuthorDate: Mon, 9 May 2016 12:05:56 -0700 Committer: H. Peter Anvin <hp...@li...> CommitDate: Mon, 9 May 2016 12:05:56 -0700 Specifically if we encounter the PTR keyword Issue a specific suppressible warning if we encounter the PTR keyword. This usually indicates someone mistakenly using MASM syntax in NASM. This introduces a generic infrastructure for issuing warnings for such keywords. Signed-off-by: H. Peter Anvin <hp...@li...> --- nasm.c | 2 +- nasm.h | 1 + nasmlib.h | 3 ++- stdscan.c | 7 ++++++- test/ptr.asm | 4 ++++ tokens.dat | 5 ++++- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/nasm.c b/nasm.c index bb9e206..2c7b22a 100644 --- a/nasm.c +++ b/nasm.c @@ -171,6 +171,7 @@ static const struct warning { {"hle", "invalid hle prefixes", true}, {"bnd", "invalid bnd prefixes", true}, {"zext-reloc", "relocation zero-extended to match output format", true}, + {"ptr", "non-NASM keyword used in other assemblers", true}, }; static bool want_usage; @@ -1958,7 +1959,6 @@ static bool skip_this_pass(int severity) if ((severity & ERR_MASK) > ERR_WARNING) return false; - /* * passn is 1 on the very first pass only. * pass0 is 2 on the code-generation (final) pass only. diff --git a/nasm.h b/nasm.h index 9393e51..aa2409b 100644 --- a/nasm.h +++ b/nasm.h @@ -421,6 +421,7 @@ enum ccode { /* condition code names */ #define TFLAG_BRC_OPT (1 << 1) /* may or may not have braces. opmasks {k1} */ #define TFLAG_BRC_ANY (TFLAG_BRC | TFLAG_BRC_OPT) #define TFLAG_BRDCAST (1 << 2) /* broadcasting decorator */ +#define TFLAG_WARN (1 << 3) /* warning only, treat as ID */ static inline uint8_t get_cond_opcode(enum ccode c) { diff --git a/nasmlib.h b/nasmlib.h index 96c488a..d307f77 100644 --- a/nasmlib.h +++ b/nasmlib.h @@ -135,7 +135,8 @@ static inline vefunc nasm_set_verror(vefunc ve) #define ERR_WARN_HLE WARN(13) /* bad HLE prefixes */ #define ERR_WARN_BND WARN(14) /* bad BND prefixes */ #define ERR_WARN_ZEXTRELOC WARN(15) /* relocation zero-extended */ -#define ERR_WARN_MAX 15 /* the highest numbered one */ +#define ERR_WARN_PTR WARN(16) /* not a NASM keyword */ +#define ERR_WARN_MAX 16 /* the highest numbered one */ /* * Wrappers around malloc, realloc and free. nasm_malloc will diff --git a/stdscan.c b/stdscan.c index ea7537d..d6cf5d5 100644 --- a/stdscan.c +++ b/stdscan.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2009 The NASM Authors - All Rights Reserved + * Copyright 1996-2016 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -167,6 +167,11 @@ int stdscan(void *private_data, struct tokenval *tv) * is it actually a register or instruction name, or what? */ token_type = nasm_token_hash(ourcopy, tv); + if (unlikely(tv->t_flag & TFLAG_WARN)) { + nasm_error(ERR_WARNING|ERR_PASS1|ERR_WARN_PTR, + "%s is not a NASM keyword", tv->t_charptr); + } + if (likely(!(tv->t_flag & TFLAG_BRC))) { /* most of the tokens fall into this case */ return token_type; diff --git a/test/ptr.asm b/test/ptr.asm new file mode 100644 index 0000000..bad3295 --- /dev/null +++ b/test/ptr.asm @@ -0,0 +1,4 @@ + ;; This should warn but still assemble, as the code is correct + + mov eax,dword ptr +ptr: diff --git a/tokens.dat b/tokens.dat index 36b17e2..528f243 100644 --- a/tokens.dat +++ b/tokens.dat @@ -1,6 +1,6 @@ ## -------------------------------------------------------------------------- ## -## Copyright 1996-2013 The NASM Authors - All Rights Reserved +## Copyright 1996-2016 The NASM Authors - All Rights Reserved ## See the file AUTHORS included with the NASM distribution for ## the specific copyright holders. ## @@ -76,6 +76,9 @@ word yword zword +% TOKEN_ID, 0, TFLAG_WARN, 0 +ptr + % TOKEN_FLOAT, 0, 0, 0 __infinity__ __nan__ |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-05-09 19:09:17
|
Commit-ID: 934f0478d409bced70ba1660512d4839cd76c571 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=934f0478d409bced70ba1660512d4839cd76c571 Author: H. Peter Anvin <hp...@li...> AuthorDate: Mon, 9 May 2016 12:00:19 -0700 Committer: H. Peter Anvin <hp...@li...> CommitDate: Mon, 9 May 2016 12:00:19 -0700 Fix the handling of pass1 warnings, display control option for warnings Fix pass1 warnings so they actually display. When issuing suppressible warnings, display the option that controls them, as gcc has been doing for a while. Signed-off-by: H. Peter Anvin <hp...@li...> --- nasm.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/nasm.c b/nasm.c index fc26bba..bb9e206 100644 --- a/nasm.c +++ b/nasm.c @@ -1953,15 +1953,19 @@ static bool is_suppressed_warning(int severity) static bool skip_this_pass(int severity) { - /* See if it's a pass-one only warning and we're not in pass one. */ + /* See if it's a pass-specific warning which should be skipped. */ + if ((severity & ERR_MASK) > ERR_WARNING) return false; - if (((severity & ERR_PASS1) && pass0 != 1) || - ((severity & ERR_PASS2) && pass0 != 2)) - return true; - return false; + /* + * passn is 1 on the very first pass only. + * pass0 is 2 on the code-generation (final) pass only. + * These are the passes we care about in this case. + */ + return (((severity & ERR_PASS1) && passn != 1) || + ((severity & ERR_PASS2) && pass0 != 2)); } /** @@ -2000,14 +2004,18 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args) break; } - vsnprintf(msg, sizeof msg, fmt, args); + vsnprintf(msg, sizeof msg - 64, fmt, args); + if (severity & ERR_WARN_MASK) { + char *p = strchr(msg, '\0'); + snprintf(p, 64, " [-w+%s]", warnings[WARN_IDX(severity)].name); + } if (!skip_this_pass(severity)) fprintf(error_file, "%s%s\n", pfx, msg); /* * Don't suppress this with skip_this_pass(), or we don't get - * preprocessor warnings in the list file + * pass1 or preprocessor warnings in the list file */ if ((severity & ERR_MASK) >= ERR_WARNING) lfmt->error(severity, pfx, msg); |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-05-09 18:42:16
|
Commit-ID: 3d72e45a137dcf5ff014856ea631811200341ad3 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=3d72e45a137dcf5ff014856ea631811200341ad3 Author: H. Peter Anvin <hp...@li...> AuthorDate: Mon, 9 May 2016 11:36:55 -0700 Committer: H. Peter Anvin <hp...@li...> CommitDate: Mon, 9 May 2016 11:36:55 -0700 outmacho: Fix missing brace Fix a missing brace introduced in checkin 84f6860ed53492976c9d79e9a8a0bdc60da78bc6. This was a transcription error of mine; Zenith432's original patch was correct. Cc: Zenith432 <zen...@us...> Signed-off-by: H. Peter Anvin <hp...@li...> --- output/outmacho.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/output/outmacho.c b/output/outmacho.c index 70936ec..6887d8f 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -1323,7 +1323,7 @@ static void macho_write_section (void) l += sectstab[r->snum]->addr; if (r->pcrel) l -= s->addr; - } else if (r->pcrel && r->type == GENERIC_RELOC_VANILLA) + } else if (r->pcrel && r->type == GENERIC_RELOC_VANILLA) { l -= s->addr; } |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-05-09 18:24:16
|
Commit-ID: 3c27bdcaee1c05f97049ed660826c3b02a87a28b Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=3c27bdcaee1c05f97049ed660826c3b02a87a28b Author: H. Peter Anvin <hp...@li...> AuthorDate: Mon, 9 May 2016 11:21:04 -0700 Committer: H. Peter Anvin <hp...@li...> CommitDate: Mon, 9 May 2016 11:21:04 -0700 NASM 2.12.02rc2 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index dd45fec..c782144 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.12.02rc1 +2.12.02rc2 |
From: nasm-bot f. Z. <zen...@us...> - 2016-05-09 18:21:20
|
Commit-ID: 84f6860ed53492976c9d79e9a8a0bdc60da78bc6 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=84f6860ed53492976c9d79e9a8a0bdc60da78bc6 Author: Zenith432 <zen...@us...> AuthorDate: Mon, 9 May 2016 11:16:10 -0700 Committer: H. Peter Anvin <hp...@li...> CommitDate: Mon, 9 May 2016 11:16:10 -0700 outmacho: Fix relative relocations for 32-bit Mach-O IP-relative relocations were broken for 32-bit Mach-O when referencing external symbols after the Mach-O backends were merged. This fixes bug reports 3392348, 3392352, and 3392346. Signed-off-by: H. Peter Anvin <hp...@li...> --- output/outmacho.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/output/outmacho.c b/output/outmacho.c index 26a62ea..70936ec 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -465,6 +465,8 @@ static int64_t add_reloc(struct section *sect, int32_t section, r->snum = raa_read(extsyms, section); if (reltype == RL_BRANCH) r->type = X86_64_RELOC_BRANCH; + else if (reltype == GENERIC_RELOC_VANILLA) + adjust = -sect->size; } else { /* local */ r->ext = 0; @@ -1321,6 +1323,8 @@ static void macho_write_section (void) l += sectstab[r->snum]->addr; if (r->pcrel) l -= s->addr; + } else if (r->pcrel && r->type == GENERIC_RELOC_VANILLA) + l -= s->addr; } /* write new offset back */ |
From: nasm-bot f. H. P. A. <hp...@li...> - 2016-05-09 18:21:19
|
Commit-ID: ff7ff12b1c973c00a6d4350eaf15c43a24565af2 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=ff7ff12b1c973c00a6d4350eaf15c43a24565af2 Author: H. Peter Anvin <hp...@li...> AuthorDate: Mon, 9 May 2016 11:19:58 -0700 Committer: H. Peter Anvin <hp...@li...> CommitDate: Mon, 9 May 2016 11:19:58 -0700 changes.src: update as of the current time Signed-off-by: H. Peter Anvin <hp...@li...> --- doc/changes.src | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/changes.src b/doc/changes.src index d48c4d3..1010409 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -13,6 +13,11 @@ since 2007. \b Fix preprocessor errors, especially \c{%error} and \c{%warning}, inside \c{%if} statements. +\b Fix relative relocations in 32-bit Mach-O. + +\b More Codeview debug format fixes. + + \S{cl-2.12.01} Version 2.12.01 \b Portability fixes for some platforms. |
From: nasm-bot f. F. G. <fa...@ra...> - 2016-04-30 13:03:24
|
Commit-ID: 5b838ef981ba49349ac05656bff335ac5feaba15 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=5b838ef981ba49349ac05656bff335ac5feaba15 Author: Fabian Giesen <fa...@ra...> AuthorDate: Thu, 28 Apr 2016 13:48:15 -0700 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sat, 30 Apr 2016 16:00:59 +0300 codeview: Make md5sum calc read file in 'binary' mode When assembling on Windows machines with CRLF line endings, computing the MD5 hash from the file read in "text" mode (transforms CRLF->LF) gives incorrect results. Signed-off-by: Fabian Giesen <fa...@ra...> Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/codeview.c | 2 +- preproc.c | 12 ++++++------ preproc.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/output/codeview.c b/output/codeview.c index b3d6248..0a38268 100644 --- a/output/codeview.c +++ b/output/codeview.c @@ -309,7 +309,7 @@ static void calc_md5(const char *const filename, FILE *f; MD5_CTX ctx; - f = pp_input_fopen(filename); + f = pp_input_fopen(filename, "rb"); if (!f) goto done; diff --git a/preproc.c b/preproc.c index a504b88..08e3ad5 100644 --- a/preproc.c +++ b/preproc.c @@ -1504,7 +1504,7 @@ static bool in_list(const StrList *list, const char *str) * the end of the path. */ static FILE *inc_fopen(const char *file, StrList **dhead, StrList ***dtail, - bool missing_ok) + bool missing_ok, const char *mode) { FILE *fp; char *prefix = ""; @@ -1517,7 +1517,7 @@ static FILE *inc_fopen(const char *file, StrList **dhead, StrList ***dtail, sl = nasm_malloc(prefix_len+len+1+sizeof sl->next); memcpy(sl->str, prefix, prefix_len); memcpy(sl->str+prefix_len, file, len+1); - fp = fopen(sl->str, "r"); + fp = fopen(sl->str, mode); if (fp && dhead && !in_list(*dhead, sl->str)) { sl->next = NULL; **dtail = sl; @@ -1559,13 +1559,13 @@ static FILE *inc_fopen(const char *file, StrList **dhead, StrList ***dtail, * that get a file:lineno pair and need to look at the file again * (e.g. the CodeView debug backend). Returns NULL on failure. */ -FILE *pp_input_fopen(const char *filename) +FILE *pp_input_fopen(const char *filename, const char *mode) { FILE *fp; StrList *xsl = NULL; StrList **xst = &xsl; - fp = inc_fopen(filename, &xsl, &xst, true); + fp = inc_fopen(filename, &xsl, &xst, true, mode); if (xsl) nasm_free(xsl); return fp; @@ -2512,7 +2512,7 @@ static int do_directive(Token * tline) inc = nasm_malloc(sizeof(Include)); inc->next = istk; inc->conds = NULL; - inc->fp = inc_fopen(p, dephead, &deptail, pass == 0); + inc->fp = inc_fopen(p, dephead, &deptail, pass == 0, "r"); if (!inc->fp) { /* -MG given but file not found */ nasm_free(inc); @@ -3253,7 +3253,7 @@ issue_error: if (t->type != TOK_INTERNAL_STRING) nasm_unquote(p, NULL); - fp = inc_fopen(p, &xsl, &xst, true); + fp = inc_fopen(p, &xsl, &xst, true, "r"); if (fp) { p = xsl->str; fclose(fp); /* Don't actually care about the file */ diff --git a/preproc.h b/preproc.h index 3dee45f..3d1aa9c 100644 --- a/preproc.h +++ b/preproc.h @@ -49,6 +49,6 @@ typedef const unsigned char macros_t; enum preproc_token pp_token_hash(const char *token); /* Opens an include file or input file. This uses the include path. */ -FILE *pp_input_fopen(const char *filename); +FILE *pp_input_fopen(const char *filename, const char *mode); #endif |
From: nasm-bot f. F. G. <fa...@ra...> - 2016-04-30 13:03:22
|
Commit-ID: 6503051dcc360172c49311d586f2b9cf4ab2ea81 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=6503051dcc360172c49311d586f2b9cf4ab2ea81 Author: Fabian Giesen <fa...@ra...> AuthorDate: Thu, 28 Apr 2016 13:48:16 -0700 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sat, 30 Apr 2016 16:01:30 +0300 codeview: Call register_file only when producing line numbers Previously, debug info would refer to the first file seen, even when it did not actually generate line numbers (e.g. segto=-1). Fix it so we only lock in the file name the first time we actually produce a line number record. Not as good as proper support for debug info referencing multiple source files but much more useful than the current behavior. Signed-off-by: Fabian Giesen <fa...@ra...> Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/codeview.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/output/codeview.c b/output/codeview.c index 0a38268..cfdd825 100644 --- a/output/codeview.c +++ b/output/codeview.c @@ -169,9 +169,6 @@ static void cv8_linenum(const char *filename, int32_t linenumber, struct coff_Section *s; struct linepair *li; - if (cv8_state.source_file.name == NULL) - register_file(filename); - s = find_section(segto); if (s == NULL) return; @@ -179,6 +176,9 @@ static void cv8_linenum(const char *filename, int32_t linenumber, if ((s->flags & IMAGE_SCN_MEM_EXECUTE) == 0) return; + if (cv8_state.source_file.name == NULL) + register_file(filename); + li = saa_wstruct(cv8_state.lines); li->file_offset = cv8_state.text_offset; li->linenumber = linenumber; |
From: nasm-bot f. F. G. <fa...@ra...> - 2016-04-30 13:03:22
|
Commit-ID: 0bbc38dbd576a1a626a31f55ce4c183b195641ef Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=0bbc38dbd576a1a626a31f55ce4c183b195641ef Author: Fabian Giesen <fa...@ra...> AuthorDate: Thu, 28 Apr 2016 13:48:14 -0700 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sat, 30 Apr 2016 16:00:38 +0300 codeview: Look up %include path when determining files to hash. The hash calculation in calc_md5 tries to open the source file via "filename" again. For %includes, this is the file name that was specified in the %include directive, not the actual name of the file that was opened by the preprocessor. In other words, this fails if the include file is not in the current working directory. Add pp_input_fopen that uses the preprocessor include path lookup code to resolve a file name and open it, and use that in codeview.c. Signed-off-by: Fabian Giesen <fa...@ra...> Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/codeview.c | 3 ++- preproc.c | 17 +++++++++++++++++ preproc.h | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/output/codeview.c b/output/codeview.c index a63fd63..b3d6248 100644 --- a/output/codeview.c +++ b/output/codeview.c @@ -44,6 +44,7 @@ #include "nasm.h" #include "nasmlib.h" +#include "preproc.h" #include "saa.h" #include "output/outlib.h" #include "output/pecoff.h" @@ -308,7 +309,7 @@ static void calc_md5(const char *const filename, FILE *f; MD5_CTX ctx; - f = fopen(filename, "r"); + f = pp_input_fopen(filename); if (!f) goto done; diff --git a/preproc.c b/preproc.c index 343a77d..a504b88 100644 --- a/preproc.c +++ b/preproc.c @@ -1555,6 +1555,23 @@ static FILE *inc_fopen(const char *file, StrList **dhead, StrList ***dtail, } /* + * Opens an include or input file. Public version, for use by modules + * that get a file:lineno pair and need to look at the file again + * (e.g. the CodeView debug backend). Returns NULL on failure. + */ +FILE *pp_input_fopen(const char *filename) +{ + FILE *fp; + StrList *xsl = NULL; + StrList **xst = &xsl; + + fp = inc_fopen(filename, &xsl, &xst, true); + if (xsl) + nasm_free(xsl); + return fp; +} + +/* * Determine if we should warn on defining a single-line macro of * name `name', with `nparam' parameters. If nparam is 0 or -1, will * return true if _any_ single-line macro of that name is defined. diff --git a/preproc.h b/preproc.h index fdda37c..3dee45f 100644 --- a/preproc.h +++ b/preproc.h @@ -48,4 +48,7 @@ typedef const unsigned char macros_t; enum preproc_token pp_token_hash(const char *token); +/* Opens an include file or input file. This uses the include path. */ +FILE *pp_input_fopen(const char *filename); + #endif |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:52
|
Commit-ID: 4670887c4db772d2d44889fbc4509b3fb65b311f Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=4670887c4db772d2d44889fbc4509b3fb65b311f Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 10 Apr 2016 17:37:11 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:41 +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 ecd6c4b..52a0d59 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -57,8 +57,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) \ @@ -325,18 +324,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-24 18:00:26
|
Commit-ID: 3421a3f3f34a9b6c4edef69e40dc1b38d58dade3 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=3421a3f3f34a9b6c4edef69e40dc1b38d58dade3 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 24 Apr 2016 20:57:52 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:57:52 +0300 out: Elf -- Fix typo in section name Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/outelf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/output/outelf.c b/output/outelf.c index 72eb7ea..fcae88b 100644 --- a/output/outelf.c +++ b/output/outelf.c @@ -1565,7 +1565,7 @@ static void elf_write(void) nsections++; /* for the section itself */ if (sects[i]->head) { nsections++; /* for its relocations */ - add_sectname(is_elf32() ? ".rel" : "rela", sects[i]->name); + add_sectname(is_elf32() ? ".rel" : ".rela", sects[i]->name); } } |
From: nasm-bot f. C. G. <gor...@gm...> - 2016-04-24 18:00:25
|
Commit-ID: 855ec5aa2c4e68394234587e16b9c1191350295a Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=855ec5aa2c4e68394234587e16b9c1191350295a Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 10 Apr 2016 17:25:45 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:41 +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-24 18:00:24
|
Commit-ID: 6dfc0b221489651b305c14017833ee8e9e231d1b Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=6dfc0b221489651b305c14017833ee8e9e231d1b Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 10 Apr 2016 17:22:49 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:41 +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-24 18:00:24
|
Commit-ID: 8348af4caf27f3db372a6fd02235dfaefe7c5f34 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=8348af4caf27f3db372a6fd02235dfaefe7c5f34 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Fri, 8 Apr 2016 01:11:39 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:41 +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-24 18:00:24
|
Commit-ID: bff511937fd4e17d4f44bf1d0d68bcbb1d9184e1 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=bff511937fd4e17d4f44bf1d0d68bcbb1d9184e1 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Thu, 7 Apr 2016 00:15:44 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:41 +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-24 18:00:24
|
Commit-ID: 239dfaa5b39031037d5c37b3ed1e12bac2a08e20 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=239dfaa5b39031037d5c37b3ed1e12bac2a08e20 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Fri, 8 Apr 2016 00:44:22 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:41 +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-24 18:00:23
|
Commit-ID: b89fb8015c1ec1f8eec0ef489614295c55e03649 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=b89fb8015c1ec1f8eec0ef489614295c55e03649 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Wed, 16 Mar 2016 01:54:15 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:41 +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-24 18:00:22
|
Commit-ID: 232788c549952c68452917f43c9adab68e1f78eb Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=232788c549952c68452917f43c9adab68e1f78eb Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Wed, 16 Mar 2016 00:36:01 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:41 +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-24 18:00:22
|
Commit-ID: 171af38cbc93187d32a6c49eda7854fdf8165081 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=171af38cbc93187d32a6c49eda7854fdf8165081 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 22:47:36 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +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-24 18:00:22
|
Commit-ID: a087d49f70291d360bb03725a9fd57e30316633a Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=a087d49f70291d360bb03725a9fd57e30316633a Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 22:43:56 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +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-24 18:00:21
|
Commit-ID: d3ec4be59009da3a92ba6ef0901da0a9989f1397 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=d3ec4be59009da3a92ba6ef0901da0a9989f1397 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 13:43:14 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +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-24 18:00:21
|
Commit-ID: 784d10cb9a4f41919a680a95f00b07a47bcb9e0d Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=784d10cb9a4f41919a680a95f00b07a47bcb9e0d Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sun, 13 Mar 2016 11:27:12 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sun, 24 Apr 2016 20:02:40 +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; |