summaryrefslogtreecommitdiffstats
path: root/external/poky/meta/recipes-devtools/nasm
diff options
context:
space:
mode:
Diffstat (limited to 'external/poky/meta/recipes-devtools/nasm')
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm/0001-Verify-that-we-are-not-reading-past-end-of-a-buffer.patch65
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm/0001-asmlib-Drop-pure-function-attribute-from-seg_init.patch27
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm/0001-assemble-Check-global-line-limit.patch50
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm/0001-eval-Eliminate-division-by-zero.patch40
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm/0001-fix-CVE-2018-8882.patch30
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm/0001-preproc-parse_size-Check-for-string-provided.patch37
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm/0001-stdlib-Add-strlcat.patch117
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch325
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm/CVE-2018-19755.patch116
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm/CVE-2019-14248.patch43
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm_2.13.03.bb35
-rw-r--r--external/poky/meta/recipes-devtools/nasm/nasm_2.14.02.bb25
12 files changed, 626 insertions, 284 deletions
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm/0001-Verify-that-we-are-not-reading-past-end-of-a-buffer.patch b/external/poky/meta/recipes-devtools/nasm/nasm/0001-Verify-that-we-are-not-reading-past-end-of-a-buffer.patch
deleted file mode 100644
index a56a08b5..00000000
--- a/external/poky/meta/recipes-devtools/nasm/nasm/0001-Verify-that-we-are-not-reading-past-end-of-a-buffer.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From c5785fdf1d660eaefb9711284414262d0cfe8843 Mon Sep 17 00:00:00 2001
-From: Adam Majer <amajer@suse.de>
-Date: Fri, 17 Aug 2018 14:48:17 +0800
-Subject: [PATCH] Verify that we are not reading past end of a buffer
-
-Simple reproducer is just,
-
- ret &d:ep
-
-which triggers a buffer overread due to parsing of an invalid
-segment override.
-
-Signed-off-by: Adam Majer <amajer@suse.de>
-
-Upstream-Status: Submitted [https://bugzilla.nasm.us/show_bug.cgi?id=3392447]
-CVE: CVE-2018-8883
-Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
----
- include/opflags.h | 2 +-
- include/tables.h | 1 +
- x86/regs.pl | 3 ++-
- 3 files changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/include/opflags.h b/include/opflags.h
-index ef2838c1..8d4b6b1e 100644
---- a/include/opflags.h
-+++ b/include/opflags.h
-@@ -166,7 +166,7 @@
- #define REG_CLASS_BND GEN_REG_CLASS(9)
-
- #define is_class(class, op) (!((opflags_t)(class) & ~(opflags_t)(op)))
--#define is_reg_class(class, reg) is_class((class), nasm_reg_flags[(reg)])
-+#define is_reg_class(class, reg) is_class((class), ((reg) < nasm_reg_flags_size ? nasm_reg_flags[(reg)] : 0))
-
- #define IS_SREG(reg) is_reg_class(REG_SREG, (reg))
- #define IS_FSGS(reg) is_reg_class(REG_FSGS, (reg))
-diff --git a/include/tables.h b/include/tables.h
-index 24a665e2..458752ce 100644
---- a/include/tables.h
-+++ b/include/tables.h
-@@ -64,6 +64,7 @@ extern const char * const nasm_reg_names[];
- typedef uint64_t opflags_t;
- typedef uint16_t decoflags_t;
- extern const opflags_t nasm_reg_flags[];
-+extern const size_t nasm_reg_flags_size;
- /* regvals.c */
- extern const int nasm_regvals[];
-
-diff --git a/x86/regs.pl b/x86/regs.pl
-index 3a1b56f5..cb5cea68 100755
---- a/x86/regs.pl
-+++ b/x86/regs.pl
-@@ -158,7 +158,8 @@ if ( $fmt eq 'h' ) {
- printf " %-15s /* %-5s */\n",
- $regs{$reg}.',', $reg;
- }
-- print "};\n";
-+ print "};\n\n";
-+ print "const size_t nasm_reg_flags_size = sizeof(nasm_reg_flags) / sizeof(opflags_t);\n";
- } elsif ( $fmt eq 'vc' ) {
- # Output regvals.c
- print "/* automatically generated from $file - do not edit */\n\n";
---
-2.17.1
-
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm/0001-asmlib-Drop-pure-function-attribute-from-seg_init.patch b/external/poky/meta/recipes-devtools/nasm/nasm/0001-asmlib-Drop-pure-function-attribute-from-seg_init.patch
deleted file mode 100644
index 12ae3a94..00000000
--- a/external/poky/meta/recipes-devtools/nasm/nasm/0001-asmlib-Drop-pure-function-attribute-from-seg_init.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 77c3a77210d8ca8b94e999c711156e984a8dc737 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Sat, 31 Mar 2018 11:05:33 -0700
-Subject: [PATCH] asmlib: Drop pure function attribute from seg_init
-
-seg_init returns void, so it is impure function
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
-Upstream-Status: Submitted
-
- include/nasmlib.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/include/nasmlib.h b/include/nasmlib.h
-index 79e866b..b80b7e2 100644
---- a/include/nasmlib.h
-+++ b/include/nasmlib.h
-@@ -191,7 +191,7 @@ int64_t readstrnum(char *str, int length, bool *warn);
- * seg_init: Initialise the segment-number allocator.
- * seg_alloc: allocate a hitherto unused segment number.
- */
--void pure_func seg_init(void);
-+void seg_init(void);
- int32_t pure_func seg_alloc(void);
-
- /*
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm/0001-assemble-Check-global-line-limit.patch b/external/poky/meta/recipes-devtools/nasm/nasm/0001-assemble-Check-global-line-limit.patch
deleted file mode 100644
index 682d4c72..00000000
--- a/external/poky/meta/recipes-devtools/nasm/nasm/0001-assemble-Check-global-line-limit.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-From 7a46d6b9e3a1d8a0ab0d816ef1bf194ad285e082 Mon Sep 17 00:00:00 2001
-From: "Chang S. Bae" <chang.seok.bae@intel.com>
-Date: Fri, 17 Aug 2018 14:26:03 +0800
-Subject: [PATCH] assemble: Check global line limit
-
-Without the limit, the while loop opens to semi-infinite
-that will exhaustively consume the heap space. Also, the
-index value gets into the garbage.
-
-https://bugzilla.nasm.us/show_bug.cgi?id=3392474
-
-Reported-by : Dongliang Mu <mudongliangabcd@gmail.com>
-Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
-Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-
-Upstream-Status: Backport from upstream [http://repo.or.cz/nasm.git]
-CVE: CVE-2018-10316
-Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
----
- asm/nasm.c | 7 ++++++-
- 1 file changed, 6 insertions(+), 1 deletion(-)
-
-diff --git a/asm/nasm.c b/asm/nasm.c
-index 8497ec9..81f6cee 100644
---- a/asm/nasm.c
-+++ b/asm/nasm.c
-@@ -99,6 +99,8 @@ static char outname[FILENAME_MAX];
- static char listname[FILENAME_MAX];
- static char errname[FILENAME_MAX];
- static int globallineno; /* for forward-reference tracking */
-+#define GLOBALLINENO_MAX INT32_MAX
-+
- /* static int pass = 0; */
- const struct ofmt *ofmt = &OF_DEFAULT;
- const struct ofmt_alias *ofmt_alias = NULL;
-@@ -1360,7 +1362,10 @@ static void assemble_file(char *fname, StrList **depend_ptr)
- location.offset = offs = get_curr_offs();
-
- while ((line = preproc->getline())) {
-- globallineno++;
-+ if (globallineno++ == GLOBALLINENO_MAX)
-+ nasm_error(ERR_FATAL,
-+ "overall line number reaches the maximum %d\n",
-+ GLOBALLINENO_MAX);
-
- /*
- * Here we parse our directives; this is not handled by the
---
-2.7.4
-
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm/0001-eval-Eliminate-division-by-zero.patch b/external/poky/meta/recipes-devtools/nasm/nasm/0001-eval-Eliminate-division-by-zero.patch
deleted file mode 100644
index 6c332497..00000000
--- a/external/poky/meta/recipes-devtools/nasm/nasm/0001-eval-Eliminate-division-by-zero.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From ceec0d818798aeaa75ed4907e6135b0247ed46b2 Mon Sep 17 00:00:00 2001
-From: Cyrill Gorcunov <gorcunov@gmail.com>
-Date: Sun, 14 Oct 2018 01:26:19 +0300
-Subject: [PATCH] eval: Eliminate division by zero
-
-When doing division we should detect if the value we're
-divided by is not zero. Instead of is_unknown() helper
-we should use is_just_unknown().
-
-https://bugzilla.nasm.us/show_bug.cgi?id=3392515
-https://bugzilla.nasm.us/show_bug.cgi?id=3392473
-
-Reported-by: Jun <jxx13@psu.edu>
-Reported-by: stuartly <situlingyun@gmail.com>
-Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-
-Upstream-Status: Backport [https://github.com/netwide-assembler/nasm/commit/ceec0d818798aeaa75ed4907e6135b0247ed46b2.patch]
-CVE: CVE-2018-10016
-Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
-
----
- asm/eval.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/asm/eval.c b/asm/eval.c
-index 1a6680f..7e727a4 100644
---- a/asm/eval.c
-+++ b/asm/eval.c
-@@ -580,7 +580,7 @@ static expr *expr5(int critical)
- " scalar values");
- return NULL;
- }
-- if (j != '*' && !is_unknown(f) && reloc_value(f) == 0) {
-+ if (j != '*' && !is_just_unknown(f) && reloc_value(f) == 0) {
- nasm_error(ERR_NONFATAL, "division by zero");
- return NULL;
- }
---
-2.10.2
-
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm/0001-fix-CVE-2018-8882.patch b/external/poky/meta/recipes-devtools/nasm/nasm/0001-fix-CVE-2018-8882.patch
deleted file mode 100644
index bc706c3f..00000000
--- a/external/poky/meta/recipes-devtools/nasm/nasm/0001-fix-CVE-2018-8882.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From 33438037e00ec750bff020578b1a5b6f75f60555 Mon Sep 17 00:00:00 2001
-From: Adam Majer <amajer@suse.de>
-Date: Fri, 17 Aug 2018 14:41:02 +0800
-Subject: [PATCH] fix CVE-2018-8882
-
-https://bugzilla.nasm.us/show_bug.cgi?id=3392445
-
-Upstream-Status: Submitted [https://bugzilla.nasm.us/show_bug.cgi?id=3392445]
-CVE: CVE-2018-8882
-Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
----
- asm/float.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/asm/float.c b/asm/float.c
-index dcf69fea..2965d3db 100644
---- a/asm/float.c
-+++ b/asm/float.c
-@@ -608,6 +608,8 @@ static void ieee_shr(fp_limb *mant, int i)
- if (offs)
- for (j = MANT_LIMBS-1; j >= offs; j--)
- mant[j] = mant[j-offs];
-+ } else if (MANT_LIMBS-1-offs < 0) {
-+ j = MANT_LIMBS-1;
- } else {
- n = mant[MANT_LIMBS-1-offs] >> sr;
- for (j = MANT_LIMBS-1; j > offs; j--) {
---
-2.17.1
-
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm/0001-preproc-parse_size-Check-for-string-provided.patch b/external/poky/meta/recipes-devtools/nasm/nasm/0001-preproc-parse_size-Check-for-string-provided.patch
deleted file mode 100644
index 2121fd17..00000000
--- a/external/poky/meta/recipes-devtools/nasm/nasm/0001-preproc-parse_size-Check-for-string-provided.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From a2f43331a853b7cc449cae3361ee1fb54c7fad8d Mon Sep 17 00:00:00 2001
-From: Cyrill Gorcunov <gorcunov@gmail.com>
-Date: Sat, 29 Sep 2018 14:30:14 +0300
-Subject: [PATCH] preproc: parse_size -- Check for string provided
-
-In case if the string is nil we will have sigsegv.
-
-https://bugzilla.nasm.us/show_bug.cgi?id=3392507
-
-Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-
-CVE: CVE-2018-1000667
-Upstream-Status: Backport
-https://repo.or.cz/nasm/nasm.git/commit/c713b5f994cf7b29164c3b6838b91f0499591434
-
-Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
----
- asm/preproc.c | 3 +--
- 1 file changed, 1 insertion(+), 2 deletions(-)
-
-diff --git a/asm/preproc.c b/asm/preproc.c
-index 475926d..1d770a5 100644
---- a/asm/preproc.c
-+++ b/asm/preproc.c
-@@ -2216,8 +2216,7 @@ static int parse_size(const char *str) {
- { "byte", "dword", "oword", "qword", "tword", "word", "yword" };
- static const int sizes[] =
- { 0, 1, 4, 16, 8, 10, 2, 32 };
--
-- return sizes[bsii(str, size_names, ARRAY_SIZE(size_names))+1];
-+ return str ? sizes[bsii(str, size_names, ARRAY_SIZE(size_names))+1] : 0;
- }
-
- /*
---
-2.8.1
-
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm/0001-stdlib-Add-strlcat.patch b/external/poky/meta/recipes-devtools/nasm/nasm/0001-stdlib-Add-strlcat.patch
new file mode 100644
index 00000000..d94fd329
--- /dev/null
+++ b/external/poky/meta/recipes-devtools/nasm/nasm/0001-stdlib-Add-strlcat.patch
@@ -0,0 +1,117 @@
+From 8a204171004fa0d7d21389530c744d215e99efb0 Mon Sep 17 00:00:00 2001
+From: Joshua Watt <JPEWhacker@gmail.com>
+Date: Tue, 19 Nov 2019 12:47:30 -0600
+Subject: [PATCH 1/2] stdlib: Add strlcat
+
+Adds strlcat which can be used to safely concatenate strings
+
+Upstream-Status: Submitted [https://bugzilla.nasm.us/show_bug.cgi?id=3392635]
+Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
+---
+ Makefile.in | 2 +-
+ configure.ac | 2 ++
+ include/compiler.h | 4 ++++
+ stdlib/strlcat.c | 43 +++++++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 50 insertions(+), 1 deletion(-)
+ create mode 100644 stdlib/strlcat.c
+
+diff --git a/Makefile.in b/Makefile.in
+index 32ef3d91..ff7eb447 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -93,7 +93,7 @@ NASM = asm/nasm.$(O)
+ NDISASM = disasm/ndisasm.$(O)
+
+ LIBOBJ = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
+- stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) \
++ stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) stdlib/strlcat.$(O) \
+ \
+ nasmlib/ver.$(O) \
+ nasmlib/crc64.$(O) nasmlib/malloc.$(O) nasmlib/errfile.$(O) \
+diff --git a/configure.ac b/configure.ac
+index 38b3b596..b4e88778 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -152,6 +152,7 @@ AC_CHECK_FUNCS([vsnprintf _vsnprintf])
+ AC_CHECK_FUNCS([snprintf _snprintf])
+ AC_CHECK_FUNCS([strlcpy])
+ AC_CHECK_FUNCS([strrchrnul])
++AC_CHECK_FUNCS([strlcat])
+
+ dnl These types are POSIX-specific, and Windows does it differently...
+ AC_CHECK_TYPES([struct _stati64])
+@@ -170,6 +171,7 @@ AC_CHECK_DECLS(strsep)
+ AC_CHECK_DECLS(strlcpy)
+ AC_CHECK_DECLS(strnlen)
+ AC_CHECK_DECLS(strrchrnul)
++AC_CHECK_DECLS(strlcat)
+
+ dnl Check for missing types
+ AC_TYPE_UINTPTR_T
+diff --git a/include/compiler.h b/include/compiler.h
+index 4178c98e..8153d297 100644
+--- a/include/compiler.h
++++ b/include/compiler.h
+@@ -159,6 +159,10 @@ size_t strlcpy(char *, const char *, size_t);
+ char *strrchrnul(const char *, int);
+ #endif
+
++#if !defined(HAVE_STRLCAT) || !HAVE_DECL_STRLCAT
++size_t strlcat(char *, const char *, size_t);
++#endif
++
+ #ifndef __cplusplus /* C++ has false, true, bool as keywords */
+ # ifdef HAVE_STDBOOL_H
+ # include <stdbool.h>
+diff --git a/stdlib/strlcat.c b/stdlib/strlcat.c
+new file mode 100644
+index 00000000..7084d460
+--- /dev/null
++++ b/stdlib/strlcat.c
+@@ -0,0 +1,43 @@
++/*
++ * Copyright (c) 2019 Garmin Ltd. or its subsidiaries
++ *
++ * Permission to use, copy, modify, and distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ */
++
++#include "compiler.h"
++
++/*
++ * Concatenate src string to dest of size size. The destination buffer will
++ * have no more than size-1 character when the operation finishes. Always NUL
++ * terminates, unless size == 0 or dest has no NUL terminator. Returns
++ * strlen(initial dest) + strlen(src); if retval >= size, truncation occurred.
++ */
++#ifndef HAVE_STRLCAT
++
++size_t strlcat(char *dest, const char *src, size_t size)
++{
++ size_t n;
++
++ /* find the NULL terminator in dest */
++ for (n = 0; i < size && dest[n] != '\0'; n++)
++ ;
++
++ /* destination was not NULL terminated. Return the initial size */
++ if (n == size)
++ return size;
++
++ return strlcpy(&dest[n], src, size - n) + n;
++}
++
++#endif
++
+--
+2.23.0
+
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch b/external/poky/meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch
new file mode 100644
index 00000000..bbfae2e8
--- /dev/null
+++ b/external/poky/meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch
@@ -0,0 +1,325 @@
+From fa677c1caf6b8192971920cf5c1aa8cb33c74605 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
+
+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
+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 ++++++++++++++++++++++++++--
+ include/nasmlib.h | 9 +++++++++
+ nasm.txt | 4 ++++
+ nasmlib/filename.c | 20 ++++++++++++++++++++
+ output/outas86.c | 4 +++-
+ output/outcoff.c | 4 ++--
+ output/outelf.c | 8 ++++----
+ 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(-)
+ create mode 100644 test/elfdebugprefix.asm
+
+diff --git a/asm/nasm.c b/asm/nasm.c
+index 1c5a5fc5..5d45103c 100644
+--- a/asm/nasm.c
++++ b/asm/nasm.c
+@@ -841,7 +841,8 @@ enum text_options {
+ OPT_BEFORE,
+ OPT_LIMIT,
+ OPT_KEEP_ALL,
+- OPT_NO_LINE
++ OPT_NO_LINE,
++ OPT_DEBUG_PREFIX_MAP
+ };
+ 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},
++ {"debug-prefix-map", OPT_DEBUG_PREFIX_MAP, true, 0},
+ {NULL, OPT_BOGUS, false, 0}
+ };
+
+@@ -1217,6 +1219,26 @@ static bool process_arg(char *p, char *q, int pass)
+ case OPT_NO_LINE:
+ pp_noline = true;
+ break;
++ case OPT_DEBUG_PREFIX_MAP: {
++ struct debug_prefix_list *d;
++ char *c;
++ c = strchr(param, '=');
++
++ if (!c) {
++ nasm_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE,
++ "option `--%s' must be of the form `BASE=DEST'", p);
++ break;
++ }
++
++ *c = '\0';
++ d = nasm_malloc(sizeof(*d));
++ d->next = debug_prefixes;
++ d->base = nasm_strdup(param);
++ d->dest = nasm_strdup(c + 1);
++ debug_prefixes = d;
++ *c = '=';
++ }
++ break;
+ case OPT_HELP:
+ help(0);
+ 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");
+
+ for (i = 0; i <= LIMIT_MAX; i++) {
+ printf(" %-15s %s (default ",
+diff --git a/include/nasmlib.h b/include/nasmlib.h
+index e57d0e6d..cf921547 100644
+--- a/include/nasmlib.h
++++ b/include/nasmlib.h
+@@ -195,10 +195,19 @@ int64_t readstrnum(char *str, int length, bool *warn);
+ */
+ int32_t seg_alloc(void);
+
++struct debug_prefix_list {
++ struct debug_prefix_list *next;
++ char *base;
++ char *dest;
++};
++
++extern struct debug_prefix_list *debug_prefixes;
++
+ /*
+ * Add/replace or remove an extension to the end of a filename
+ */
+ const char *filename_set_extension(const char *inname, const char *extension);
++char *filename_debug_remap(char *dest, char const *inname, size_t len);
+
+ /*
+ * Utility macros...
+diff --git a/nasm.txt b/nasm.txt
+index a28202f9..443c06b2 100644
+--- a/nasm.txt
++++ b/nasm.txt
+@@ -147,6 +147,10 @@ OPTIONS
+ Prepend or append (respectively) the given argument to all global or
+ extern variables.
+
++--debug-prefix-map 'BASE=DEST'::
++ Map file names beginning with 'BASE' to 'DEST' when encoding them in
++ output object files.
++
+ SYNTAX
+ ------
+ 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
+--- a/nasmlib/filename.c
++++ b/nasmlib/filename.c
+@@ -39,6 +39,8 @@
+ #include "nasmlib.h"
+ #include "error.h"
+
++struct debug_prefix_list *debug_prefixes = NULL;
++
+ /*
+ * Add/modify a filename extension, assumed to be a period-delimited
+ * field at the very end of the filename. Returns a newly allocated
+@@ -61,3 +63,21 @@ const char *filename_set_extension(const char *inname, const char *extension)
+
+ return p;
+ }
++
++char *filename_debug_remap(char *dest, char const *in, size_t len)
++{
++ struct debug_prefix_list *d;
++ size_t n;
++
++ for (d = debug_prefixes; d != NULL; d = d->next) {
++ n = strlen(d->base);
++ if (strncmp(in, d->base, n) == 0) {
++ strlcpy(dest, d->dest, len);
++ strlcat(dest, &in[n], len);
++ return dest;
++ }
++ }
++
++ strlcpy(dest, in, len);
++ return dest;
++}
+diff --git a/output/outas86.c b/output/outas86.c
+index 3f9867b9..d5f4f966 100644
+--- a/output/outas86.c
++++ b/output/outas86.c
+@@ -113,6 +113,8 @@ static void as86_sect_write(struct Section *, const uint8_t *,
+
+ static void as86_init(void)
+ {
++ char filename[FILENAME_MAX];
++
+ stext.data = saa_init(1L);
+ stext.datalen = 0L;
+ stext.head = stext.last = NULL;
+@@ -134,7 +136,7 @@ static void as86_init(void)
+ strslen = 0;
+
+ /* as86 module name = input file minus extension */
+- as86_add_string(filename_set_extension(inname, ""));
++ as86_add_string(filename_debug_remap(filename, filename_set_extension(inname, ""), sizeof(filename)));
+ }
+
+ static void as86_cleanup(void)
+diff --git a/output/outcoff.c b/output/outcoff.c
+index a2fd302c..bcf576fb 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,
+
+ static void coff_write_symbols(void)
+ {
+- char filename[18];
++ char filename[19];
+ 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);
+ nasm_write(filename, 18, ofile);
+
+ /*
+diff --git a/output/outelf.c b/output/outelf.c
+index de99d076..203b5dc0 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)
+
+ static void elf_init(void)
+ {
+- strlcpy(elf_module, inname, sizeof(elf_module));
++ filename_debug_remap(elf_module, inname, sizeof(elf_module));
+ 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.
+diff --git a/output/outieee.c b/output/outieee.c
+index 3a28942d..f61824e4 100644
+--- a/output/outieee.c
++++ b/output/outieee.c
+@@ -209,7 +209,7 @@ static void ieee_unqualified_name(char *, char *);
+ */
+ static void ieee_init(void)
+ {
+- strlcpy(ieee_infile, inname, sizeof(ieee_infile));
++ filename_debug_remap(ieee_infile, inname, sizeof(ieee_infile));
+ any_segs = false;
+ fpubhead = NULL;
+ fpubtail = &fpubhead;
+diff --git a/output/outobj.c b/output/outobj.c
+index b4f2c499..55bba4a1 100644
+--- a/output/outobj.c
++++ b/output/outobj.c
+@@ -640,7 +640,7 @@ static enum directive_result obj_directive(enum directive, char *, int);
+
+ static void obj_init(void)
+ {
+- strlcpy(obj_infile, inname, sizeof(obj_infile));
++ filename_debug_remap(obj_infile, inname, sizeof(obj_infile));
+ first_seg = seg_alloc();
+ any_segs = false;
+ fpubhead = NULL;
+diff --git a/stdlib/strlcat.c b/stdlib/strlcat.c
+index 7084d460..ee93dea3 100644
+--- a/stdlib/strlcat.c
++++ b/stdlib/strlcat.c
+@@ -29,7 +29,7 @@ size_t strlcat(char *dest, const char *src, size_t size)
+ size_t n;
+
+ /* find the NULL terminator in dest */
+- for (n = 0; i < size && dest[n] != '\0'; n++)
++ for (n = 0; n < size && dest[n] != '\0'; n++)
+ ;
+
+ /* 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
+--- /dev/null
++++ b/test/elfdebugprefix.asm
+@@ -0,0 +1,6 @@
++;Testname=unoptimized; Arguments=-O0 --debug-prefix-map elf=ELF -felf -oelfdebugprefix.o; Files=stdout stderr elfdebugprefix.o; Validate=readelf --wide --symbols elfdebugprefix.o | grep 'FILE.*ELFdebugprefix.asm'
++
++ SECTION .text
++test: ; [1]
++ ret
++
+diff --git a/test/performtest.pl b/test/performtest.pl
+index f7865b39..096f9604 100755
+--- a/test/performtest.pl
++++ b/test/performtest.pl
+@@ -42,14 +42,22 @@ sub perform {
+ TEST:
+ while(<TESTFILE>) {
+ #See if there is a test case
+- last unless /Testname=(.*);\s*Arguments=(.*);\s*Files=(.*)/;
+- my ($subname, $arguments, $files) = ($1, $2, $3);
++ last unless /Testname=(.*);\s*Arguments=(.*);\s*Files=([^;]*)(?:;\s*Validate=(.*))?/;
++ my ($subname, $arguments, $files, $validate) = ($1, $2, $3, $4);
++ chomp $files;
+ debugprint("$subname | $arguments | $files");
+
+ #Call nasm with this test case
+ system("$nasm $arguments $testpath > $stdoutfile 2> $stderrfile");
+ debugprint("$nasm $arguments $testpath > $stdoutfile 2> $stderrfile ----> $?");
+
++ if($validate) {
++ if(system("$validate >> $stdoutfile 2>> $stderrfile") != 0) {
++ print "Test $testname/$subname validation failed\n";
++ $globalresult = 1;
++ }
++ }
++
+ #Move the output to the test dir
+ mkpath("$outputdir/$testname/$subname");
+ foreach(split / /,$files) {
+--
+2.23.0
+
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm/CVE-2018-19755.patch b/external/poky/meta/recipes-devtools/nasm/nasm/CVE-2018-19755.patch
new file mode 100644
index 00000000..6e3f909d
--- /dev/null
+++ b/external/poky/meta/recipes-devtools/nasm/nasm/CVE-2018-19755.patch
@@ -0,0 +1,116 @@
+From 3079f7966dbed4497e36d5067cbfd896a90358cb Mon Sep 17 00:00:00 2001
+From: Cyrill Gorcunov <gorcunov@gmail.com>
+Date: Wed, 14 Nov 2018 10:03:42 +0300
+Subject: [PATCH] preproc: Fix malformed parameter count
+
+readnum returns 64bit number which may become
+a negative integer upon conversion which in
+turn lead to out of bound array access.
+
+Fix it by explicit conversion with bounds check
+
+ | POC6:2: error: parameter count `2222222222' is out of bounds [0; 2147483647]
+
+https://bugzilla.nasm.us/show_bug.cgi?id=3392528
+
+Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
+
+Upstream-Status: Backport
+CVE: CVE-2018-19755
+Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
+---
+ asm/preproc.c | 43 +++++++++++++++++++++----------------------
+ 1 file changed, 21 insertions(+), 22 deletions(-)
+
+diff --git a/asm/preproc.c b/asm/preproc.c
+index b6afee3..e5ad05a 100644
+--- a/asm/preproc.c
++++ b/asm/preproc.c
+@@ -1650,6 +1650,23 @@ smacro_defined(Context * ctx, const char *name, int nparam, SMacro ** defn,
+ return false;
+ }
+
++/* param should be a natural number [0; INT_MAX] */
++static int read_param_count(const char *str)
++{
++ int result;
++ bool err;
++
++ result = readnum(str, &err);
++ if (result < 0 || result > INT_MAX) {
++ result = 0;
++ nasm_error(ERR_NONFATAL, "parameter count `%s' is out of bounds [%d; %d]",
++ str, 0, INT_MAX);
++ } else if (err) {
++ nasm_error(ERR_NONFATAL, "unable to parse parameter count `%s'", str);
++ }
++ return result;
++}
++
+ /*
+ * Count and mark off the parameters in a multi-line macro call.
+ * This is called both from within the multi-line macro expansion
+@@ -1871,11 +1888,7 @@ static bool if_condition(Token * tline, enum preproc_token ct)
+ pp_directives[ct]);
+ } else {
+ searching.nparam_min = searching.nparam_max =
+- readnum(tline->text, &j);
+- if (j)
+- nasm_error(ERR_NONFATAL,
+- "unable to parse parameter count `%s'",
+- tline->text);
++ read_param_count(tline->text);
+ }
+ if (tline && tok_is_(tline->next, "-")) {
+ tline = tline->next->next;
+@@ -1886,11 +1899,7 @@ static bool if_condition(Token * tline, enum preproc_token ct)
+ "`%s' expects a parameter count after `-'",
+ pp_directives[ct]);
+ else {
+- searching.nparam_max = readnum(tline->text, &j);
+- if (j)
+- nasm_error(ERR_NONFATAL,
+- "unable to parse parameter count `%s'",
+- tline->text);
++ searching.nparam_max = read_param_count(tline->text);
+ if (searching.nparam_min > searching.nparam_max) {
+ nasm_error(ERR_NONFATAL,
+ "minimum parameter count exceeds maximum");
+@@ -2079,8 +2088,6 @@ static void undef_smacro(Context *ctx, const char *mname)
+ */
+ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive)
+ {
+- bool err;
+-
+ tline = tline->next;
+ skip_white_(tline);
+ tline = expand_id(tline);
+@@ -2103,11 +2110,7 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive)
+ if (!tok_type_(tline, TOK_NUMBER)) {
+ nasm_error(ERR_NONFATAL, "`%s' expects a parameter count", directive);
+ } else {
+- def->nparam_min = def->nparam_max =
+- readnum(tline->text, &err);
+- if (err)
+- nasm_error(ERR_NONFATAL,
+- "unable to parse parameter count `%s'", tline->text);
++ def->nparam_min = def->nparam_max = read_param_count(tline->text);
+ }
+ if (tline && tok_is_(tline->next, "-")) {
+ tline = tline->next->next;
+@@ -2117,11 +2120,7 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive)
+ nasm_error(ERR_NONFATAL,
+ "`%s' expects a parameter count after `-'", directive);
+ } else {
+- def->nparam_max = readnum(tline->text, &err);
+- if (err) {
+- nasm_error(ERR_NONFATAL, "unable to parse parameter count `%s'",
+- tline->text);
+- }
++ def->nparam_max = read_param_count(tline->text);
+ if (def->nparam_min > def->nparam_max) {
+ nasm_error(ERR_NONFATAL, "minimum parameter count exceeds maximum");
+ def->nparam_max = def->nparam_min;
+--
+2.10.5.GIT
+
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm/CVE-2019-14248.patch b/external/poky/meta/recipes-devtools/nasm/nasm/CVE-2019-14248.patch
new file mode 100644
index 00000000..d45d2cb4
--- /dev/null
+++ b/external/poky/meta/recipes-devtools/nasm/nasm/CVE-2019-14248.patch
@@ -0,0 +1,43 @@
+From 93d41d82963b2cfd0b24c906f5a8daf53281b559 Mon Sep 17 00:00:00 2001
+From: "H. Peter Anvin (Intel)" <hpa@zytor.com>
+Date: Fri, 16 Aug 2019 01:12:54 -0700
+Subject: [PATCH] BR 3392576: don't segfault on a bad %pragma limit
+
+Don't segfault on a bad %pragma limit. Instead treat a NULL pointer as
+an empty string.
+
+Reported-by: Ren Kimura <rkx1209dev@gmail.com>
+Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
+
+CVE: CVE-2019-14248
+Upstream-Status: Backport [https://repo.or.cz/nasm.git/commit/93d41d82963b2cfd0b24c906f5a8daf53281b559]
+Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
+---
+ asm/nasm.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/asm/nasm.c b/asm/nasm.c
+index c84d675..65116ab 100644
+--- a/asm/nasm.c
++++ b/asm/nasm.c
+@@ -212,6 +212,11 @@ nasm_set_limit(const char *limit, const char *valstr)
+ bool rn_error;
+ int errlevel;
+
++ if (!limit)
++ limit = "";
++ if (!valstr)
++ valstr = "";
++
+ for (i = 0; i <= LIMIT_MAX; i++) {
+ if (!nasm_stricmp(limit, limit_info[i].name))
+ break;
+@@ -204,7 +209,7 @@ nasm_set_limit(const char *limit, const char *valstr)
+ errlevel = ERR_WARNING|ERR_NOFILE|ERR_USAGE;
+ else
+ errlevel = ERR_WARNING|ERR_PASS1|WARN_UNKNOWN_PRAGMA;
+- nasm_error(errlevel, "unknown limit: `%s'", limit);
++ nasm_error(errlevel, "invalid limit value: `%s'", valstr);
+ return DIRR_ERROR;
+ }
+
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm_2.13.03.bb b/external/poky/meta/recipes-devtools/nasm/nasm_2.13.03.bb
deleted file mode 100644
index de4c5544..00000000
--- a/external/poky/meta/recipes-devtools/nasm/nasm_2.13.03.bb
+++ /dev/null
@@ -1,35 +0,0 @@
-SUMMARY = "General-purpose x86 assembler"
-SECTION = "devel"
-LICENSE = "BSD-2-Clause"
-LIC_FILES_CHKSUM = "file://LICENSE;md5=90904486f8fbf1861cf42752e1a39efe"
-
-SRC_URI = "http://www.nasm.us/pub/nasm/releasebuilds/${PV}/nasm-${PV}.tar.bz2 \
- file://0001-asmlib-Drop-pure-function-attribute-from-seg_init.patch \
- file://0001-assemble-Check-global-line-limit.patch \
- file://0001-fix-CVE-2018-8882.patch \
- file://0001-Verify-that-we-are-not-reading-past-end-of-a-buffer.patch \
- file://0001-eval-Eliminate-division-by-zero.patch \
- file://0001-preproc-parse_size-Check-for-string-provided.patch \
- "
-
-SRC_URI[md5sum] = "0c581d482f39d5111879ca9601938f74"
-SRC_URI[sha256sum] = "63ec86477ad3f0f6292325fd89e1d93aea2e2fd490070863f17d48f7cd387011"
-
-inherit autotools-brokensep
-
-do_configure_prepend () {
- if [ -f ${S}/aclocal.m4 ] && [ ! -f ${S}/acinclude.m4 ]; then
- mv ${S}/aclocal.m4 ${S}/acinclude.m4
- fi
-}
-
-do_install() {
- install -d ${D}${bindir}
- install -d ${D}${mandir}/man1
-
- oe_runmake 'INSTALLROOT=${D}' install
-}
-
-BBCLASSEXTEND = "native"
-
-DEPENDS = "groff-native"
diff --git a/external/poky/meta/recipes-devtools/nasm/nasm_2.14.02.bb b/external/poky/meta/recipes-devtools/nasm/nasm_2.14.02.bb
new file mode 100644
index 00000000..f8a8d76e
--- /dev/null
+++ b/external/poky/meta/recipes-devtools/nasm/nasm_2.14.02.bb
@@ -0,0 +1,25 @@
+SUMMARY = "General-purpose x86 assembler"
+SECTION = "devel"
+LICENSE = "BSD-2-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=90904486f8fbf1861cf42752e1a39efe"
+
+SRC_URI = "http://www.nasm.us/pub/nasm/releasebuilds/${PV}/nasm-${PV}.tar.bz2 \
+ file://CVE-2018-19755.patch \
+ file://CVE-2019-14248.patch \
+ file://0001-stdlib-Add-strlcat.patch \
+ file://0002-Add-debug-prefix-map-option.patch \
+ "
+
+SRC_URI[md5sum] = "3f489aa48ad2aa1f967dc5e293bbd06f"
+SRC_URI[sha256sum] = "34fd26c70a277a9fdd54cb5ecf389badedaf48047b269d1008fbc819b24e80bc"
+
+# brokensep since this uses autoconf but not automake
+inherit autotools-brokensep
+
+EXTRA_AUTORECONF += "--exclude=aclocal"
+
+BBCLASSEXTEND = "native"
+
+DEPENDS = "groff-native"
+
+CVE_PRODUCT = "netwide_assembler"