summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch')
-rw-r--r--meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch175
1 files changed, 88 insertions, 87 deletions
diff --git a/meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch b/meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch
index bbfae2e8a5..84fcca0fe1 100644
--- a/meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch
+++ b/meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch
@@ -1,7 +1,7 @@
-From fa677c1caf6b8192971920cf5c1aa8cb33c74605 Mon Sep 17 00:00:00 2001
+From e28c8883050d34d18ee2d66dfeece51e13adb6d5 Mon Sep 17 00:00:00 2001
From: Joshua Watt <JPEWhacker@gmail.com>
Date: Tue, 19 Nov 2019 13:12:17 -0600
-Subject: [PATCH 2/2] Add --debug-prefix-map option
+Subject: [PATCH] Add --debug-prefix-map option
Adds an option to remap file prefixes in output object files. This is
analogous to the "-fdebug-prefix-map" option in GCC, and allows files to
@@ -9,47 +9,46 @@ be built in a reproducible manner regardless of the build directory.
Upstream-Status: Submitted [https://bugzilla.nasm.us/show_bug.cgi?id=3392635]
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
+
---
- asm/nasm.c | 28 ++++++++++++++++++++++++++--
+ asm/nasm.c | 24 ++++++++++++++++++++++++
include/nasmlib.h | 9 +++++++++
nasm.txt | 4 ++++
nasmlib/filename.c | 20 ++++++++++++++++++++
output/outas86.c | 4 +++-
output/outcoff.c | 4 ++--
- output/outelf.c | 8 ++++----
+ output/outelf.c | 13 ++++++++-----
output/outieee.c | 2 +-
output/outobj.c | 2 +-
stdlib/strlcat.c | 2 +-
test/elfdebugprefix.asm | 6 ++++++
test/performtest.pl | 12 ++++++++++--
- 12 files changed, 87 insertions(+), 14 deletions(-)
+ 12 files changed, 89 insertions(+), 13 deletions(-)
create mode 100644 test/elfdebugprefix.asm
diff --git a/asm/nasm.c b/asm/nasm.c
-index 1c5a5fc5..5d45103c 100644
+index 76c70f6..08ff119 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
-@@ -841,7 +841,8 @@ enum text_options {
- OPT_BEFORE,
- OPT_LIMIT,
+@@ -939,6 +939,7 @@ enum text_options {
OPT_KEEP_ALL,
-- OPT_NO_LINE
-+ OPT_NO_LINE,
-+ OPT_DEBUG_PREFIX_MAP
+ OPT_NO_LINE,
+ OPT_DEBUG,
++ OPT_DEBUG_PREFIX_MAP,
+ OPT_REPRODUCIBLE
};
- struct textargs {
- const char *label;
-@@ -866,6 +867,7 @@ static const struct textargs textopts[] = {
- {"limit-", OPT_LIMIT, true, 0},
- {"keep-all", OPT_KEEP_ALL, false, 0},
- {"no-line", OPT_NO_LINE, false, 0},
+ enum need_arg {
+@@ -971,6 +972,7 @@ static const struct textargs textopts[] = {
+ {"keep-all", OPT_KEEP_ALL, ARG_NO, 0},
+ {"no-line", OPT_NO_LINE, ARG_NO, 0},
+ {"debug", OPT_DEBUG, ARG_MAYBE, 0},
+ {"debug-prefix-map", OPT_DEBUG_PREFIX_MAP, true, 0},
- {NULL, OPT_BOGUS, false, 0}
+ {"reproducible", OPT_REPRODUCIBLE, ARG_NO, 0},
+ {NULL, OPT_BOGUS, ARG_NO, 0}
};
-
-@@ -1217,6 +1219,26 @@ static bool process_arg(char *p, char *q, int pass)
- case OPT_NO_LINE:
- pp_noline = true;
+@@ -1335,6 +1337,26 @@ static bool process_arg(char *p, char *q, int pass)
+ case OPT_REPRODUCIBLE:
+ reproducible = true;
break;
+ case OPT_DEBUG_PREFIX_MAP: {
+ struct debug_prefix_list *d;
@@ -72,24 +71,22 @@ index 1c5a5fc5..5d45103c 100644
+ }
+ break;
case OPT_HELP:
- help(0);
+ help(stdout);
exit(0);
-@@ -2010,7 +2032,9 @@ static void help(const char xopt)
- " --lpostfix str append the given string to all other symbols\n"
- " --keep-all output files will not be removed even if an error happens\n"
- " --no-line ignore %%line directives in input\n"
-- " --limit-X val set execution limit X\n");
-+ " --limit-X val set execution limit X\n"
-+ " --debug-prefix-map base=dest\n"
-+ " remap paths starting with 'base' to 'dest' in output files\n");
+@@ -2298,6 +2320,8 @@ static void help(FILE *out)
+ " -w-x disable warning x (also -Wno-x)\n"
+ " -w[+-]error promote all warnings to errors (also -Werror)\n"
+ " -w[+-]error=x promote warning x to errors (also -Werror=x)\n"
++ " --debug-prefix-map base=dest\n"
++ " remap paths starting with 'base' to 'dest' in output files\n"
+ , out);
- for (i = 0; i <= LIMIT_MAX; i++) {
- printf(" %-15s %s (default ",
+ fprintf(out, " %-20s %s\n",
diff --git a/include/nasmlib.h b/include/nasmlib.h
-index e57d0e6d..cf921547 100644
+index 87a7fc6..a3e5144 100644
--- a/include/nasmlib.h
+++ b/include/nasmlib.h
-@@ -195,10 +195,19 @@ int64_t readstrnum(char *str, int length, bool *warn);
+@@ -250,10 +250,19 @@ int64_t readstrnum(char *str, int length, bool *warn);
*/
int32_t seg_alloc(void);
@@ -110,7 +107,7 @@ index e57d0e6d..cf921547 100644
/*
* Utility macros...
diff --git a/nasm.txt b/nasm.txt
-index a28202f9..443c06b2 100644
+index 950c361..784618c 100644
--- a/nasm.txt
+++ b/nasm.txt
@@ -147,6 +147,10 @@ OPTIONS
@@ -125,7 +122,7 @@ index a28202f9..443c06b2 100644
------
This man page does not fully describe the syntax of *nasm*'s assembly language,
diff --git a/nasmlib/filename.c b/nasmlib/filename.c
-index 172ae0bc..fda2be41 100644
+index 172ae0b..fda2be4 100644
--- a/nasmlib/filename.c
+++ b/nasmlib/filename.c
@@ -39,6 +39,8 @@
@@ -160,10 +157,10 @@ index 172ae0bc..fda2be41 100644
+ return dest;
+}
diff --git a/output/outas86.c b/output/outas86.c
-index 3f9867b9..d5f4f966 100644
+index 54b22f8..c4a412c 100644
--- a/output/outas86.c
+++ b/output/outas86.c
-@@ -113,6 +113,8 @@ static void as86_sect_write(struct Section *, const uint8_t *,
+@@ -110,6 +110,8 @@ static void as86_sect_write(struct Section *, const uint8_t *,
static void as86_init(void)
{
@@ -172,7 +169,7 @@ index 3f9867b9..d5f4f966 100644
stext.data = saa_init(1L);
stext.datalen = 0L;
stext.head = stext.last = NULL;
-@@ -134,7 +136,7 @@ static void as86_init(void)
+@@ -131,7 +133,7 @@ static void as86_init(void)
strslen = 0;
/* as86 module name = input file minus extension */
@@ -182,10 +179,10 @@ index 3f9867b9..d5f4f966 100644
static void as86_cleanup(void)
diff --git a/output/outcoff.c b/output/outcoff.c
-index a2fd302c..bcf576fb 100644
+index c2b4eb6..e242db2 100644
--- a/output/outcoff.c
+++ b/output/outcoff.c
-@@ -1070,14 +1070,14 @@ static void coff_symbol(char *name, int32_t strpos, int32_t value,
+@@ -1259,7 +1259,7 @@ static void coff_symbol(char *name, int32_t strpos, int32_t value,
static void coff_write_symbols(void)
{
@@ -194,57 +191,64 @@ index a2fd302c..bcf576fb 100644
uint32_t i;
/*
- * The `.file' record, and the file name auxiliary record.
- */
- coff_symbol(".file", 0L, 0L, -2, 0, 0x67, 1);
-- strncpy(filename, inname, 18);
-+ filename_debug_remap(filename, inname, 19);
+@@ -1269,7 +1269,7 @@ static void coff_write_symbols(void)
+ if (reproducible)
+ memset(filename, 0, 18);
+ else
+- strncpy(filename, inname, 18);
++ filename_debug_remap(filename, inname, 19);
nasm_write(filename, 18, ofile);
/*
diff --git a/output/outelf.c b/output/outelf.c
-index de99d076..203b5dc0 100644
+index ad8d210..29f1dc1 100644
--- a/output/outelf.c
+++ b/output/outelf.c
-@@ -1,5 +1,5 @@
- /* ----------------------------------------------------------------------- *
-- *
-+ *
- * Copyright 1996-2017 The NASM Authors - All Rights Reserved
- * See the file AUTHORS included with the NASM distribution for
- * the specific copyright holders.
-@@ -14,7 +14,7 @@
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
-- *
-+ *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-@@ -315,7 +315,7 @@ elf_directive(enum directive directive, char *value, int pass)
+@@ -546,8 +546,8 @@ static void elf_init(void)
+ const char * const *p;
+ const char * cur_path = nasm_realpath(inname);
- static void elf_init(void)
- {
- strlcpy(elf_module, inname, sizeof(elf_module));
+- strlcpy(elf_dir, nasm_dirname(cur_path), sizeof(elf_dir));
+ filename_debug_remap(elf_module, inname, sizeof(elf_module));
++ filename_debug_remap(elf_dir, nasm_dirname(cur_path), sizeof(elf_dir));
sects = NULL;
nsects = sectlen = 0;
syms = saa_init((int32_t)sizeof(struct elf_symbol));
-@@ -868,7 +868,7 @@ static void elf32_out(int32_t segto, const void *data,
- " 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.
+@@ -3590,13 +3590,17 @@ static void dwarf_findfile(const char * fname)
+ if (dwarf_clist && !(strcmp(fname, dwarf_clist->filename)))
+ return;
+
++ char * fname_remapped = nasm_malloc(FILENAME_MAX);
++ filename_debug_remap(fname_remapped,fname,FILENAME_MAX);
++
+ /* search for match */
+ match = 0;
+ if (dwarf_flist) {
+ match = dwarf_flist;
+ for (finx = 0; finx < dwarf_numfiles; finx++) {
+- if (!(strcmp(fname, match->filename))) {
++ if (!(strcmp(fname_remapped, match->filename))) {
+ dwarf_clist = match;
++ nasm_free(fname_remapped);
+ return;
+ }
+ match = match->next;
+@@ -3607,8 +3611,7 @@ static void dwarf_findfile(const char * fname)
+ dwarf_clist = nasm_malloc(sizeof(struct linelist));
+ dwarf_numfiles++;
+ dwarf_clist->line = dwarf_numfiles;
+- dwarf_clist->filename = nasm_malloc(strlen(fname) + 1);
+- strcpy(dwarf_clist->filename,fname);
++ dwarf_clist->filename = fname_remapped;
+ dwarf_clist->next = 0;
+ if (!dwarf_flist) { /* if first entry */
+ dwarf_flist = dwarf_elist = dwarf_clist;
diff --git a/output/outieee.c b/output/outieee.c
-index 3a28942d..f61824e4 100644
+index 7ba9036..796e5af 100644
--- a/output/outieee.c
+++ b/output/outieee.c
-@@ -209,7 +209,7 @@ static void ieee_unqualified_name(char *, char *);
+@@ -207,7 +207,7 @@ static void ieee_unqualified_name(char *, char *);
*/
static void ieee_init(void)
{
@@ -254,10 +258,10 @@ index 3a28942d..f61824e4 100644
fpubhead = NULL;
fpubtail = &fpubhead;
diff --git a/output/outobj.c b/output/outobj.c
-index b4f2c499..55bba4a1 100644
+index 281839d..fc336c1 100644
--- a/output/outobj.c
+++ b/output/outobj.c
-@@ -640,7 +640,7 @@ static enum directive_result obj_directive(enum directive, char *, int);
+@@ -644,7 +644,7 @@ static enum directive_result obj_directive(enum directive, char *);
static void obj_init(void)
{
@@ -267,7 +271,7 @@ index b4f2c499..55bba4a1 100644
any_segs = false;
fpubhead = NULL;
diff --git a/stdlib/strlcat.c b/stdlib/strlcat.c
-index 7084d460..ee93dea3 100644
+index 7084d46..ee93dea 100644
--- a/stdlib/strlcat.c
+++ b/stdlib/strlcat.c
@@ -29,7 +29,7 @@ size_t strlcat(char *dest, const char *src, size_t size)
@@ -281,7 +285,7 @@ index 7084d460..ee93dea3 100644
/* destination was not NULL terminated. Return the initial size */
diff --git a/test/elfdebugprefix.asm b/test/elfdebugprefix.asm
new file mode 100644
-index 00000000..a67ba29c
+index 0000000..a67ba29
--- /dev/null
+++ b/test/elfdebugprefix.asm
@@ -0,0 +1,6 @@
@@ -292,7 +296,7 @@ index 00000000..a67ba29c
+ ret
+
diff --git a/test/performtest.pl b/test/performtest.pl
-index f7865b39..096f9604 100755
+index 46b1bdf..2426848 100755
--- a/test/performtest.pl
+++ b/test/performtest.pl
@@ -42,14 +42,22 @@ sub perform {
@@ -320,6 +324,3 @@ index f7865b39..096f9604 100755
#Move the output to the test dir
mkpath("$outputdir/$testname/$subname");
foreach(split / /,$files) {
---
-2.23.0
-