From: nasm-bot f. F. G. <fa...@ra...> - 2016-05-10 09:06:18
|
Commit-ID: 86d8756f0cd255e91c8ef8a4de1ebae3c18d30f3 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=86d8756f0cd255e91c8ef8a4de1ebae3c18d30f3 Author: Fabian Giesen <fa...@ra...> AuthorDate: Thu, 28 Apr 2016 13:48:14 -0700 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Tue, 10 May 2016 12:01:08 +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 f9750bf..571cbab 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 e33a6d7..78263fb 100644 --- a/preproc.c +++ b/preproc.c @@ -1560,6 +1560,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 |