diff options
Diffstat (limited to 'meta/recipes-devtools/nasm')
4 files changed, 464 insertions, 28 deletions
diff --git a/meta/recipes-devtools/nasm/nasm/0001-stdlib-Add-strlcat.patch b/meta/recipes-devtools/nasm/nasm/0001-stdlib-Add-strlcat.patch new file mode 100644 index 0000000000..1b8e947c56 --- /dev/null +++ b/meta/recipes-devtools/nasm/nasm/0001-stdlib-Add-strlcat.patch @@ -0,0 +1,115 @@ +From 680220e772dfa381829983fa73b915416f676894 Mon Sep 17 00:00:00 2001 +From: Joshua Watt <JPEWhacker@gmail.com> +Date: Tue, 19 Nov 2019 12:47:30 -0600 +Subject: [PATCH] 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 b85ebee..045fabe 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -104,7 +104,7 @@ PROGOBJ = $(NASM) $(NDISASM) + PROGS = nasm$(X) ndisasm$(X) + + LIBOBJ_NW = 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/alloc.$(O) nasmlib/asprintf.$(O) nasmlib/errfile.$(O) \ +diff --git a/configure.ac b/configure.ac +index 42cd198..e206338 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -236,6 +236,7 @@ PA_FUNC_SNPRINTF + PA_FUNC_VSNPRINTF + 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]) +@@ -255,6 +256,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 407c160..b64da6a 100644 +--- a/include/compiler.h ++++ b/include/compiler.h +@@ -169,6 +169,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 0000000..7084d46 +--- /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 ++ 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 new file mode 100644 index 0000000000..84fcca0fe1 --- /dev/null +++ b/meta/recipes-devtools/nasm/nasm/0002-Add-debug-prefix-map-option.patch @@ -0,0 +1,326 @@ +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] 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 | 24 ++++++++++++++++++++++++ + include/nasmlib.h | 9 +++++++++ + nasm.txt | 4 ++++ + nasmlib/filename.c | 20 ++++++++++++++++++++ + output/outas86.c | 4 +++- + output/outcoff.c | 4 ++-- + 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, 89 insertions(+), 13 deletions(-) + create mode 100644 test/elfdebugprefix.asm + +diff --git a/asm/nasm.c b/asm/nasm.c +index 76c70f6..08ff119 100644 +--- a/asm/nasm.c ++++ b/asm/nasm.c +@@ -939,6 +939,7 @@ enum text_options { + OPT_KEEP_ALL, + OPT_NO_LINE, + OPT_DEBUG, ++ OPT_DEBUG_PREFIX_MAP, + OPT_REPRODUCIBLE + }; + 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}, + {"reproducible", OPT_REPRODUCIBLE, ARG_NO, 0}, + {NULL, OPT_BOGUS, ARG_NO, 0} + }; +@@ -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; ++ 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(stdout); + exit(0); +@@ -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); + + fprintf(out, " %-20s %s\n", +diff --git a/include/nasmlib.h b/include/nasmlib.h +index 87a7fc6..a3e5144 100644 +--- a/include/nasmlib.h ++++ b/include/nasmlib.h +@@ -250,10 +250,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 950c361..784618c 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 172ae0b..fda2be4 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 54b22f8..c4a412c 100644 +--- a/output/outas86.c ++++ b/output/outas86.c +@@ -110,6 +110,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; +@@ -131,7 +133,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 c2b4eb6..e242db2 100644 +--- a/output/outcoff.c ++++ b/output/outcoff.c +@@ -1259,7 +1259,7 @@ 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; + + /* +@@ -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 ad8d210..29f1dc1 100644 +--- a/output/outelf.c ++++ b/output/outelf.c +@@ -546,8 +546,8 @@ static void elf_init(void) + const char * const *p; + const char * cur_path = nasm_realpath(inname); + +- 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)); +@@ -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 7ba9036..796e5af 100644 +--- a/output/outieee.c ++++ b/output/outieee.c +@@ -207,7 +207,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 281839d..fc336c1 100644 +--- a/output/outobj.c ++++ b/output/outobj.c +@@ -644,7 +644,7 @@ static enum directive_result obj_directive(enum directive, char *); + + 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 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) + 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 0000000..a67ba29 +--- /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 46b1bdf..2426848 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) { diff --git a/meta/recipes-devtools/nasm/nasm_2.13.01.bb b/meta/recipes-devtools/nasm/nasm_2.13.01.bb deleted file mode 100644 index bf18cd6d14..0000000000 --- a/meta/recipes-devtools/nasm/nasm_2.13.01.bb +++ /dev/null @@ -1,28 +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 " - -SRC_URI[md5sum] = "1f7d4662040d24351df7d6719ed4f97a" -SRC_URI[sha256sum] = "08f97baf0a7f892128c6413cfa93b69dc5825fbbd06c70928aea028835d198fa" - -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/meta/recipes-devtools/nasm/nasm_2.16.01.bb b/meta/recipes-devtools/nasm/nasm_2.16.01.bb new file mode 100644 index 0000000000..219cc49360 --- /dev/null +++ b/meta/recipes-devtools/nasm/nasm_2.16.01.bb @@ -0,0 +1,23 @@ +SUMMARY = "General-purpose x86 assembler" +SECTION = "devel" +HOMEPAGE = "http://www.nasm.us/" +DESCRIPTION = "The Netwide Assembler (NASM) is an assembler and disassembler for the Intel x86 architecture." +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-stdlib-Add-strlcat.patch \ + file://0002-Add-debug-prefix-map-option.patch \ + " + +SRC_URI[sha256sum] = "35b6ad2ee048d41c4779f073f3efca7762a822b7d2d4ef4e8df24cf65747bb2e" + +EXTRA_AUTORECONF:append = " -I autoconf/m4" + +inherit autotools-brokensep + +BBCLASSEXTEND = "native" + +DEPENDS = "groff-native" + +CVE_PRODUCT = "netwide_assembler" |