Author: kevans
Date: Mon Feb 12 17:44:35 2018
New Revision: 329175
URL: https://svnweb.freebsd.org/changeset/base/329175

Log:
  MFC Loader Fixes 2017q4p7: r324844,r326089,r326926,r326440,r326484,r326494,
  r326588,r326708,r326784,r326914,r327390,r328446,r326090,r326143,r326144,
  r326182,r326384,r326421,r326440,r326441,r326442,r326443,r326444,r326445,
  r326446,r326447,r326448,r326484,r326485,r326486,r326487,r326488,r326490,
  r326491,r326492,r326493,r326494,r326495,r326504,r326507,r326509,r326584,
  r326585,r326586,r326587,r326588,r326589,r326590,r326591,r326592,r326593,
  r326594,r326600,r326616,r326671,r326707,r326708,r326709,r326710,r326711,
  r326712,r326714,r326720,r326768,r326772,r326784,r326792,r326812,r326854,
  r326855,r326856,r326858,r326886,r326887,r326914,r326926,r326927,r326960,
  r326961,r326962,r326963,r327351,r327453,r327390,r327523,r327524,r326489,
  r327880,r328437,r328438,r328439,r328441,r328446,r328448,r328449,r328612,
  r328613,r328615
  
  While here, undo our libfdt hack of not including <stdlib.h> if we're
  compiling _STANDALONE.
  
  r324844: When building standalone, don't define errno. Let the definition from
  stand.h override. This is similar to what we do in the kernel.
  
  r326089: loader.efi: efipart does not recognize partitionless disks
  
  r326090: net_parse_rootpath() has no parameters
  
  r326143: Fix theoretical integer overflow issues. If the product here is
  
  r326144: Mark the func pointer as __dead2. It looks up loader_main, which
  
  r326182: Modify all FreeBSD bootloaders on PowerPC AIM (Book-S) systems
  
  r326384: Use const pointers to avoid casting away constness.
  
  r326421: loader.efi: efipart should exclude iPXE stub block protocol
  
  r326440: Remove stale dependency on ufsread.c
  
  r326441: Minor flags cleanup
  
  r326442: Cleanup CFALGS usage here
  
  r326443: We don't need both _STAND and _STANDALONE, use the latter.
  
  r326444: Move geli to common DO32 stuff
  
  r326445: Fix random() and srandom() prototypes to match the standard.
  
  r326446: Undefine _STANDALONE since this is test code.
  
  r326447: Tweaks to the beri boot loader so that it builds w/o warnings.
  
  r326448: Fix all warnings related to geli and ZFS support on x86.
  
  r326484: Const poison the propname.
  
  r326485: Delcare md_load in libofw.h. Make all prototypes match for ofw
  
  r326486: Include machine/md_var to pick up __syncicache prototype.
  
  r326487: Cast mdp (a vm_offset_t) to void * to match prototype.
  
  r326488: e_entry can be smaller than a pointer. Cast it to an intptr_t
  
  r326490: Declare our strange brand of main().
  
  r326491: Disconnet ps3 from the build. There's too many warnings to fix.
  
  r326492: Cast void * pointer to char * so the arg matches the %s format.
  
  r326493: Provide a md_load64 prototype.
  
  r326494: Mark two things as unused (since they are only sometimes used)
  
  r326495: Now it's safe to bump WARNS to 1.
  
  r326504: Switch to proper MK_LOADER_GELI tests.
  
  r326507: increase maximum size of zfsboot
  
  r326509: loader.efi: add note about iPXE into the efipart.c
  
  r326584: When building standalone, include stand.h rather than the kernel
  
  r326585: Include ficl.h before anything else
  
  r326586: No need to include the userland md5.h, the kernel one is just fine.
  
  r326587: Use the kernel relative paths, rather than the userland relative
  paths
  
  r326588: Need to include skein in the include path
  
  r326589: Make sure we include the right path for skein.h
  
  r326590: Prefer stdint.h to inttypes.h
  
  r326591: This isn't NetBSD specific code. Include these for any kernel /
  
  r326592: Don't inherit CFLAGS. This a specialized test program.
  
  r326593: Stop building with the standard system headers.
  
  r326594: Now that we offer a semi-sane standards-ish set of #include files,
  stop hacking includes with sed.
  
  r326600: Since this is contrib code, create an upstreamable version of my
  
  r326616: dhcp_try_rfc1048() is not used any more
  
  r326671: Avoid setting -Wno-tentative-definition-incomplete-type with gcc.
  
  r326707: Add partial support signal.h functioanlity. Pull in
  machine/signal.h
  
  r326708: Remove _KERNEL hack now that errno.h does the right thing when
  built standalone.
  
  r326709: Provide implementations for iscntrl, ispunct and isgraph.
  
  r326710: Put the files we're copying over into a few variables and clean
  hings up.
  
  r326711: Const poison a couple of interfaces.
  
  r326712: Create interp class.
  
  r326714: boot1.c needs EFI_ZFS_BOOT too, so add it globally.
  
  r326720: This path belongs in ficl/Makefile, not the common defines for
  users
  
  r326768: Fix a comment to be more accurate
  
  r326772: Fix regression with lua import
  
  r326784: Revert part of 362772. It was causing problems for includes
  
  r326792: Attempt to unbreak buildworld
  
  r326812: Revert r326792, r326784, r326772, r326712
  
  r326854: libefi: make efichar.h more usable in stand code
  
  r326855: Cargo cut a fix for the regressions r326585 caused.
  
  r326856: Fix comments after bump in size.
  
  r326858: Revert r326855: Cargo cut a fix for the regressions r326585 caused.
  
  r326886: Panic in sbrk if setheap hasn't been called yet. This is preferable
  o a mysterious crash
  
  r326887: Remove the 'mini libstand in libstand' that util.[ch] provided.
  
  r326914: Move loader-only defines to loader.mk from defs.mk
  
  r326926: Move loader help file definitions to being 100% inside of
  loader.mk.
  
  r326927: libficl is only ever used in a loader (never a boot) program. Move
  it.
  
  r326960: Simplify things a little. The RETURN macro isn't required.
  
  r326961: Interact is always called with NULL. Simplify code a little
  
  r326962: Hoist btx include stuff to i386/Makefile.inc
  
  r326963: No need to use relative paths like this here.
  
  r327351: Fix ubldr. uboot/lib uses defines for the loader.
  
  r327453: Add a validbcd() routine that uses the bcd2bin_data[] array
  
  r327390: Garbage-collect loader.ps3. It is currently disconnected from the
  build and kboot replaces.
  
  r327523: Don't clobber system LDFLAGS for beri boot loaders.
  
  r327524: Use 'extern uint8_t' instead of 'extern void' for external symbols.
  
  r326489: Allow this file to be used in libsa without warning...
  
  r327880: Move getsecs() prototype to stand.h from net.h so it can be used
  
  r328437: Split panic routine
  
  r328438: Implement abort() as a call to panic.
  
  r328439: Provide abs form stdlib.h.
  
  r328441: abort() should be marked __dead2 since it won't return.
  
  r328446: Now that exit is __dead2, we need to tag ub_exit() as __dead2.
  
  r328448: Make exit() never return until host_exit can be written.
  
  r328449: Tag unreachable places as such. I left the while (1); in place
  
  r328612: Move strtold wrapper from strtol.c to its own strtold.c.
  
  r328613: Kill copies of strtol and strtoul.
  
  r328615: Update stand.h for changes for strto*l
  
  PR:           223969

Added:
  stable/11/lib/libc/stdlib/strtold.c
     - copied unchanged from r328612, head/lib/libc/stdlib/strtold.c
  stable/11/stand/libsa/abort.c
     - copied unchanged from r328438, head/stand/libsa/abort.c
  stable/11/stand/libsa/xlocale_private.h
     - copied unchanged from r328613, head/stand/libsa/xlocale_private.h
Deleted:
  stable/11/stand/libsa/strtol.c
  stable/11/stand/libsa/strtoul.c
  stable/11/stand/libsa/util.c
  stable/11/stand/libsa/util.h
  stable/11/stand/powerpc/ps3/
Modified:
  stable/11/contrib/compiler-rt/lib/builtins/int_lib.h
  stable/11/lib/libc/stdlib/Makefile.inc
  stable/11/lib/libc/stdlib/strtol.c
  stable/11/stand/Makefile.amd64
  stable/11/stand/Makefile.i386
  stable/11/stand/Makefile.inc
  stable/11/stand/arm/uboot/Makefile
  stable/11/stand/common/bootstrap.h
  stable/11/stand/common/dev_net.c
  stable/11/stand/common/interp.c
  stable/11/stand/common/interp_backslash.c
  stable/11/stand/common/interp_forth.c
  stable/11/stand/common/interp_parse.c
  stable/11/stand/common/load_elf.c
  stable/11/stand/common/load_elf_obj.c
  stable/11/stand/common/reloc_elf.c
  stable/11/stand/defs.mk
  stable/11/stand/efi/boot1/Makefile
  stable/11/stand/efi/boot1/boot1.c
  stable/11/stand/efi/include/efichar.h
  stable/11/stand/efi/libefi/Makefile
  stable/11/stand/efi/libefi/efichar.c
  stable/11/stand/efi/libefi/efipart.c
  stable/11/stand/efi/loader/Makefile
  stable/11/stand/efi/loader/main.c
  stable/11/stand/ficl.mk
  stable/11/stand/ficl/Makefile
  stable/11/stand/ficl/float.c
  stable/11/stand/geli/Makefile
  stable/11/stand/geli/geliboot.c
  stable/11/stand/geli/geliboot_internal.h
  stable/11/stand/i386/Makefile.inc
  stable/11/stand/i386/boot2/Makefile
  stable/11/stand/i386/common/cons.c
  stable/11/stand/i386/common/drv.c
  stable/11/stand/i386/gptboot/Makefile
  stable/11/stand/i386/gptboot/gptboot.c
  stable/11/stand/i386/gptboot/gptldr.S
  stable/11/stand/i386/gptzfsboot/Makefile
  stable/11/stand/i386/libfirewire/Makefile
  stable/11/stand/i386/libi386/Makefile
  stable/11/stand/i386/libi386/biosdisk.c
  stable/11/stand/i386/libi386/multiboot.c
  stable/11/stand/i386/loader/Makefile
  stable/11/stand/i386/loader/main.c
  stable/11/stand/i386/zfsboot/Makefile
  stable/11/stand/i386/zfsboot/zfsboot.c
  stable/11/stand/libsa/Makefile
  stable/11/stand/libsa/bootp.c
  stable/11/stand/libsa/bootp.h
  stable/11/stand/libsa/cd9660.c
  stable/11/stand/libsa/gpt.c
  stable/11/stand/libsa/net.h
  stable/11/stand/libsa/panic.c
  stable/11/stand/libsa/sbrk.c
  stable/11/stand/libsa/stand.h
  stable/11/stand/loader.mk
  stable/11/stand/mips/beri/boot2/Makefile
  stable/11/stand/mips/beri/boot2/boot2.c
  stable/11/stand/mips/beri/common/altera_jtag_uart.c
  stable/11/stand/mips/beri/common/cfi.c
  stable/11/stand/mips/beri/common/sdcard.c
  stable/11/stand/mips/beri/loader/Makefile
  stable/11/stand/mips/beri/loader/devicename.c
  stable/11/stand/mips/beri/loader/exec.c
  stable/11/stand/mips/beri/loader/loader.h
  stable/11/stand/mips/beri/loader/main.c
  stable/11/stand/mips/uboot/Makefile
  stable/11/stand/mips/uboot/conf.c
  stable/11/stand/ofw/common/main.c
  stable/11/stand/ofw/libofw/elf_freebsd.c
  stable/11/stand/ofw/libofw/libofw.h
  stable/11/stand/ofw/libofw/openfirm.c
  stable/11/stand/ofw/libofw/openfirm.h
  stable/11/stand/ofw/libofw/ppc64_elf_freebsd.c
  stable/11/stand/powerpc/Makefile
  stable/11/stand/powerpc/boot1.chrp/Makefile
  stable/11/stand/powerpc/boot1.chrp/boot1.c
  stable/11/stand/powerpc/kboot/Makefile
  stable/11/stand/powerpc/kboot/host_syscall.h
  stable/11/stand/powerpc/kboot/hostdisk.c
  stable/11/stand/powerpc/kboot/kbootfdt.c
  stable/11/stand/powerpc/kboot/main.c
  stable/11/stand/powerpc/kboot/ppc64_elf_freebsd.c
  stable/11/stand/powerpc/ofw/Makefile
  stable/11/stand/powerpc/ofw/start.c
  stable/11/stand/powerpc/uboot/Makefile
  stable/11/stand/sparc64/boot1/Makefile
  stable/11/stand/sparc64/loader/Makefile
  stable/11/stand/sparc64/loader/main.c
  stable/11/stand/sparc64/loader/metadata.c
  stable/11/stand/uboot/common/main.c
  stable/11/stand/uboot/lib/glue.c
  stable/11/stand/uboot/lib/glue.h
  stable/11/stand/userboot/test/Makefile
  stable/11/stand/userboot/test/test.c
  stable/11/stand/userboot/userboot/Makefile
  stable/11/stand/userboot/userboot/main.c
  stable/11/stand/zfs/zfsimpl.c
  stable/11/sys/cddl/boot/zfs/zfssubr.c
  stable/11/sys/contrib/libfdt/libfdt_env.h
  stable/11/sys/geom/eli/g_eli_hmac.c
  stable/11/sys/geom/eli/pkcs5v2.c
  stable/11/sys/opencrypto/xform_userland.h
  stable/11/sys/sys/errno.h
  stable/11/sys/sys/libkern.h
  stable/11/sys/sys/syslimits.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/compiler-rt/lib/builtins/int_lib.h
==============================================================================
--- stable/11/contrib/compiler-rt/lib/builtins/int_lib.h        Mon Feb 12 
17:42:28 2018        (r329174)
+++ stable/11/contrib/compiler-rt/lib/builtins/int_lib.h        Mon Feb 12 
17:44:35 2018        (r329175)
@@ -55,12 +55,16 @@
 #define UNUSED __attribute__((unused))
 #endif
 
-#if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE))
+#if (defined(__FreeBSD__) || defined(__NetBSD__)) && (defined(_KERNEL) || 
defined(_STANDALONE))
 /*
  * Kernel and boot environment can't use normal headers,
  * so use the equivalent system headers.
  */
+#ifdef __FreeBSD__
+#  include <sys/limits.h>
+#else
 #  include <machine/limits.h>
+#endif
 #  include <sys/stdint.h>
 #  include <sys/types.h>
 #else

Modified: stable/11/lib/libc/stdlib/Makefile.inc
==============================================================================
--- stable/11/lib/libc/stdlib/Makefile.inc      Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/lib/libc/stdlib/Makefile.inc      Mon Feb 12 17:44:35 2018        
(r329175)
@@ -15,7 +15,7 @@ MISRCS+=C99_Exit.c a64l.c abort.c abs.c atexit.c atof.
        radixsort.c rand.c \
        random.c reallocarray.c reallocf.c realpath.c remque.c \
        set_constraint_handler_s.c strfmon.c strtoimax.c \
-       strtol.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
+       strtol.c strtold.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
         strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c
 
 # Work around an issue on case-insensitive file systems.

Modified: stable/11/lib/libc/stdlib/strtol.c
==============================================================================
--- stable/11/lib/libc/stdlib/strtol.c  Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/lib/libc/stdlib/strtol.c  Mon Feb 12 17:44:35 2018        
(r329175)
@@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
 #include <stdlib.h>
 #include "xlocale_private.h"
 
-
 /*
  * Convert a string to a long integer.
  *
@@ -150,9 +149,4 @@ long
 strtol(const char * __restrict nptr, char ** __restrict endptr, int base)
 {
        return strtol_l(nptr, endptr, base, __get_locale());
-}
-long double
-strtold(const char * __restrict nptr, char ** __restrict endptr)
-{
-       return strtold_l(nptr, endptr, __get_locale());
 }

Copied: stable/11/lib/libc/stdlib/strtold.c (from r328612, 
head/lib/libc/stdlib/strtold.c)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/11/lib/libc/stdlib/strtold.c Mon Feb 12 17:44:35 2018        
(r329175, copy of r328612, head/lib/libc/stdlib/strtold.c)
@@ -0,0 +1,45 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <stdlib.h>
+#include "xlocale_private.h"
+
+long double
+strtold(const char * __restrict nptr, char ** __restrict endptr)
+{
+
+       return strtold_l(nptr, endptr, __get_locale());
+}

Modified: stable/11/stand/Makefile.amd64
==============================================================================
--- stable/11/stand/Makefile.amd64      Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/Makefile.amd64      Mon Feb 12 17:44:35 2018        
(r329175)
@@ -11,7 +11,7 @@ SUBDIR+=              ficl32
 SUBDIR+=               efi
 SUBDIR+=               userboot
 
-.if ${LOADER_GELI_SUPPORT:Uyes} == "yes"
+.if ${MK_LOADER_GELI} == "yes"
 SUBDIR+=               geli
 .endif
 

Modified: stable/11/stand/Makefile.i386
==============================================================================
--- stable/11/stand/Makefile.i386       Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/Makefile.i386       Mon Feb 12 17:44:35 2018        
(r329175)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-.if ${LOADER_GELI_SUPPORT:Uyes} == "yes"
+.if ${MK_LOADER_GELI} == "yes"
 SUBDIR+=               geli
 .endif
 .if ${MK_ZFS} != "no"

Modified: stable/11/stand/Makefile.inc
==============================================================================
--- stable/11/stand/Makefile.inc        Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/Makefile.inc        Mon Feb 12 17:44:35 2018        
(r329175)
@@ -1,53 +1,3 @@
 # $FreeBSD$
 
 .include "defs.mk"
-
-.if !defined(__BOOT_MAKEFILE_INC__)
-__BOOT_MAKEFILE_INC__=${MFILE}
-
-CFLAGS+=-I${SASRC}
-
-SSP_CFLAGS=
-
-# Add in the no float / no SIMD stuff and announce we're freestanding
-# aarch64 and riscv don't have -msoft-float, but all others do. riscv
-# currently has no /boot/loader, but may soon.
-CFLAGS+=       -ffreestanding ${CFLAGS_NO_SIMD}
-.if ${MACHINE_CPUARCH} == "aarch64"
-CFLAGS+=       -mgeneral-regs-only
-.elif ${MACHINE_CPUARCH} != "riscv"
-CFLAGS+=       -msoft-float
-.endif
-
-.if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && 
${DO32:U0} == 1)
-CFLAGS+=       -march=i386
-CFLAGS.gcc+=   -mpreferred-stack-boundary=2
-.endif
-
-
-.if ${MACHINE_CPUARCH} == "arm"
-# Do not generate movt/movw, because the relocation fixup for them does not
-# translate to the -Bsymbolic -pie format required by self_reloc() in 
loader(8).
-# Also, the fpu is not available in a standalone environment.
-.if ${COMPILER_VERSION} < 30800
-CFLAGS.clang+= -mllvm -arm-use-movt=0
-.else
-CFLAGS.clang+= -mno-movt
-.endif
-CFLAGS.clang+=  -mfpu=none
-.endif
-
-# The boot loader build uses dd status=none, where possible, for reproducible
-# build output (since performance varies from run to run). Trouble is that
-# option was recently (10.3) added to FreeBSD and is non-standard. Only use it
-# when this test succeeds rather than require dd to be a bootstrap tool.
-DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true
-DD=dd ${DD_NOSTATUS}
-
-.if ${MK_LOADER_FORCE_LE} != "no"
-.if ${MACHINE_ARCH} == "powerpc64"
-CFLAGS+=       -mlittle-endian
-.endif
-.endif
-
-.endif

Modified: stable/11/stand/arm/uboot/Makefile
==============================================================================
--- stable/11/stand/arm/uboot/Makefile  Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/arm/uboot/Makefile  Mon Feb 12 17:44:35 2018        
(r329175)
@@ -28,7 +28,7 @@ SRCS=         start.S conf.c self_reloc.c vers.c
 CWARNFLAGS.self_reloc.c+=      -Wno-error=maybe-uninitialized
 .endif
 
-HELP_FILES+=    help.uboot ${BOOTSRC}/fdt/help.fdt
+HELP_FILES=     ${.CURDIR}/help.uboot ${BOOTSRC}/fdt/help.fdt
 
 # Always add MI sources
 .include       "${BOOTSRC}/loader.mk"

Modified: stable/11/stand/common/bootstrap.h
==============================================================================
--- stable/11/stand/common/bootstrap.h  Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/common/bootstrap.h  Mon Feb 12 17:44:35 2018        
(r329175)
@@ -45,17 +45,17 @@ extern char command_errbuf[COMMAND_ERRBUFSZ];
 #define CMD_FATAL      4
 
 /* interp.c */
-void   interact(const char *rc);
+void   interact(void);
 int    include(const char *filename);
 
 /* interp_backslash.c */
-char   *backslash(char *str);
+char   *backslash(const char *str);
 
 /* interp_parse.c */
-int    parse(int *argc, char ***argv, char *str);
+int    parse(int *argc, char ***argv, const char *str);
 
 /* interp_forth.c */
-void   bf_init(const char *rc);
+void   bf_init(void);
 int    bf_run(char *line);
 
 /* boot.c */

Modified: stable/11/stand/common/dev_net.c
==============================================================================
--- stable/11/stand/common/dev_net.c    Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/common/dev_net.c    Mon Feb 12 17:44:35 2018        
(r329175)
@@ -382,7 +382,7 @@ net_print(int verbose)
  * It leaves just the pathname in the global rootpath.
  */
 uint32_t
-net_parse_rootpath()
+net_parse_rootpath(void)
 {
        n_long addr = htonl(INADDR_NONE);
        size_t i;

Modified: stable/11/stand/common/interp.c
==============================================================================
--- stable/11/stand/common/interp.c     Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/common/interp.c     Mon Feb 12 17:44:35 2018        
(r329175)
@@ -39,11 +39,7 @@ __FBSDID("$FreeBSD$");
 
 #ifdef BOOT_FORTH
 #include "ficl.h"
-#define        RETURN(x)       stackPushINT(bf_vm->pStack,!x); return(x)
-
 extern FICL_VM *bf_vm;
-#else
-#define        RETURN(x)       return(x)
 #endif
 
 #define        MAXARGS 20                      /* maximum number of arguments 
allowed */
@@ -51,12 +47,10 @@ extern FICL_VM *bf_vm;
 static void    prompt(void);
 
 #ifndef BOOT_FORTH
-static int     perform(int argc, char *argv[]);
-
 /*
  * Perform the command
  */
-int
+static int
 perform(int argc, char *argv[])
 {
     int                                result;
@@ -82,7 +76,7 @@ perform(int argc, char *argv[])
     } else {
        command_errmsg = "unknown command";
     }
-    RETURN(result);
+    return(result);
 }
 #endif /* ! BOOT_FORTH */
 
@@ -90,7 +84,7 @@ perform(int argc, char *argv[])
  * Interactive mode
  */
 void
-interact(const char *rc)
+interact(void)
 {
     static char        input[256];                     /* big enough? */
 #ifndef BOOT_FORTH
@@ -99,14 +93,11 @@ interact(const char *rc)
 #endif
 
 #ifdef BOOT_FORTH
-    bf_init((rc) ? "" : NULL);
+    bf_init();
 #endif
 
-    if (rc == NULL) {
-       /* Read our default configuration. */
-       include("/boot/loader.rc");
-    } else if (*rc != '\0')
-       include(rc);
+    /* Read our default configuration. */
+    include("/boot/loader.rc");
 
     printf("\n");
 

Modified: stable/11/stand/common/interp_backslash.c
==============================================================================
--- stable/11/stand/common/interp_backslash.c   Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/common/interp_backslash.c   Mon Feb 12 17:44:35 2018        
(r329175)
@@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$");
  * processing" done on it.  Original can be free'd if desired.
  */
 char *
-backslash(char *str)
+backslash(const char *str)
 {
     /*
      * Remove backslashes from the strings. Turn \040 etc. into a single

Modified: stable/11/stand/common/interp_forth.c
==============================================================================
--- stable/11/stand/common/interp_forth.c       Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/common/interp_forth.c       Mon Feb 12 17:44:35 2018        
(r329175)
@@ -250,7 +250,7 @@ bf_command(FICL_VM *vm)
  * Initialise the Forth interpreter, create all our commands as words.
  */
 void
-bf_init(const char *rc)
+bf_init(void)
 {
     struct bootblk_command     **cmdp;
     char create_buf[41];       /* 31 characters-long builtins */
@@ -280,14 +280,9 @@ bf_init(const char *rc)
     ficlSetEnv(bf_sys, "loader_version", bootprog_rev);
 
     /* try to load and run init file if present */
-    if (rc == NULL)
-       rc = "/boot/boot.4th";
-    if (*rc != '\0') {
-       fd = open(rc, O_RDONLY);
-       if (fd != -1) {
-           (void)ficlExecFD(bf_vm, fd);
-           close(fd);
-       }
+    if ((fd = open("/boot/boot.4th", O_RDONLY)) != -1) {
+       (void)ficlExecFD(bf_vm, fd);
+       close(fd);
     }
 }
 

Modified: stable/11/stand/common/interp_parse.c
==============================================================================
--- stable/11/stand/common/interp_parse.c       Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/common/interp_parse.c       Mon Feb 12 17:44:35 2018        
(r329175)
@@ -7,7 +7,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 
+ *
  * Jordan K. Hubbard
  * 29 August 1998
  *
@@ -82,7 +82,7 @@ isdquote(int ch)
 }
 
 int
-parse(int *argc, char ***argv, char *str)
+parse(int *argc, char ***argv, const char *str)
 {
     int ac;
     char *val, *p, *q, *copy = NULL;

Modified: stable/11/stand/common/load_elf.c
==============================================================================
--- stable/11/stand/common/load_elf.c   Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/common/load_elf.c   Mon Feb 12 17:44:35 2018        
(r329175)
@@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/elf.h>
 #include <stand.h>
 #define FREEBSD_ELF
-#include <link.h>
+#include <sys/link_elf.h>
 
 #include "bootstrap.h"
 
@@ -456,7 +456,7 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_
      * think the rule is going to have to be that you must strip a
      * file to remove symbols before gzipping it.
      */
-    chunk = ehdr->e_shnum * ehdr->e_shentsize;
+    chunk = (size_t)ehdr->e_shnum * (size_t)ehdr->e_shentsize;
     if (chunk == 0 || ehdr->e_shoff == 0)
        goto nosyms;
     shdr = alloc_pread(ef->fd, ehdr->e_shoff, chunk);
@@ -747,7 +747,7 @@ __elfN(load_modmetadata)(struct preloaded_file *fp, u_
                goto out;
        }
 
-       size = ef.ehdr->e_shnum * ef.ehdr->e_shentsize;
+       size = (size_t)ef.ehdr->e_shnum * (size_t)ef.ehdr->e_shentsize;
        shdr = alloc_pread(ef.fd, ef.ehdr->e_shoff, size);
        if (shdr == NULL) {
                err = ENOMEM;

Modified: stable/11/stand/common/load_elf_obj.c
==============================================================================
--- stable/11/stand/common/load_elf_obj.c       Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/common/load_elf_obj.c       Mon Feb 12 17:44:35 2018        
(r329175)
@@ -33,12 +33,12 @@ __FBSDID("$FreeBSD$");
 #include <sys/exec.h>
 #include <sys/linker.h>
 #include <sys/module.h>
-#include <inttypes.h>
+#include <stdint.h>
 #include <string.h>
 #include <machine/elf.h>
 #include <stand.h>
 #define FREEBSD_ELF
-#include <link.h>
+#include <sys/link_elf.h>
 
 #include "bootstrap.h"
 

Modified: stable/11/stand/common/reloc_elf.c
==============================================================================
--- stable/11/stand/common/reloc_elf.c  Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/common/reloc_elf.c  Mon Feb 12 17:44:35 2018        
(r329175)
@@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <stand.h>
 
 #define FREEBSD_ELF
-#include <link.h>
+#include <sys/link_elf.h>
 
 #include "bootstrap.h"
 

Modified: stable/11/stand/defs.mk
==============================================================================
--- stable/11/stand/defs.mk     Mon Feb 12 17:42:28 2018        (r329174)
+++ stable/11/stand/defs.mk     Mon Feb 12 17:44:35 2018        (r329175)
@@ -2,6 +2,8 @@
 
 .include <src.opts.mk>
 
+WARNS?=1
+
 .if !defined(__BOOT_DEFS_MK__)
 __BOOT_DEFS_MK__=${MFILE}
 
@@ -22,15 +24,6 @@ BOOTOBJ=     ${OBJTOP}/stand
 # BINDIR is where we install
 BINDIR?=       /boot
 
-# NB: The makefiles depend on these being empty when we don't build forth.
-.if ${MK_FORTH} != "no"
-LIBFICL=       ${BOOTOBJ}/ficl/libficl.a
-.if ${MACHINE} == "i386"
-LIBFICL32=     ${LIBFICL}
-.else
-LIBFICL32=     ${BOOTOBJ}/ficl32/libficl.a
-.endif
-.endif
 LIBSA=         ${BOOTOBJ}/libsa/libsa.a
 .if ${MACHINE} == "i386"
 LIBSA32=       ${LIBSA}
@@ -39,54 +32,16 @@ LIBSA32=    ${BOOTOBJ}/libsa32/libsa32.a
 .endif
 
 # Standard options:
-
-# Filesystem support
-.if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
-CFLAGS+=       -DLOADER_CD9660_SUPPORT
+CFLAGS+=       -nostdinc
+.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
+CFLAGS+=       -I${BOOTOBJ}/libsa32
+.else
+CFLAGS+=       -I${BOOTOBJ}/libsa
 .endif
-.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
-CFLAGS+=       -DLOADER_EXT2FS_SUPPORT
-.endif
-.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
-CFLAGS+=       -DLOADER_MSDOS_SUPPORT
-.endif
-.if ${LOADER_NANDFS_SUPPORT:U${MK_NAND}} == "yes"
-CFLAGS+=       -DLOADER_NANDFS_SUPPORT
-.endif
-.if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
-CFLAGS+=       -DLOADER_UFS_SUPPORT
-.endif
+CFLAGS+=       -I${SASRC} -D_STANDALONE
+CFLAGS+=       -I${SYSDIR}
 
-# Compression
-.if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
-CFLAGS+=       -DLOADER_GZIP_SUPPORT
-.endif
-.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
-CFLAGS+=       -DLOADER_BZIP2_SUPPORT
-.endif
-
-# Network related things
-.if ${LOADER_NET_SUPPORT:Uno} == "yes"
-CFLAGS+=       -DLOADER_NET_SUPPORT
-.endif
-.if ${LOADER_NFS_SUPPORT:Uno} == "yes"
-CFLAGS+=       -DLOADER_NFS_SUPPORT
-.endif
-.if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
-CFLAGS+=       -DLOADER_TFTP_SUPPORT
-.endif
-
-# Disk and partition support
-.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
-CFLAGS+= -DLOADER_DISK_SUPPORT
-.if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
-CFLAGS+= -DLOADER_GPT_SUPPORT
-.endif
-.if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
-CFLAGS+= -DLOADER_MBR_SUPPORT
-.endif
-
-# GELI Support, with backward compat hooks
+# GELI Support, with backward compat hooks (mostly)
 .if defined(HAVE_GELI)
 .if defined(LOADER_NO_GELI_SUPPORT)
 MK_LOADER_GELI=no
@@ -100,11 +55,17 @@ MK_LOADER_GELI=yes
 CFLAGS+=       -DLOADER_GELI_SUPPORT
 CFLAGS+=       -I${BOOTSRC}/geli
 LIBGELIBOOT=   ${BOOTOBJ}/geli/libgeliboot.a
+.endif # MK_LOADER_GELI
+.endif # HAVE_GELI
+
+# These should be confined to loader.mk, but can't because uboot/lib
+# also uses it. It's part of loader, but isn't a loader so we can't
+# just include loader.mk
+.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
+CFLAGS+= -DLOADER_DISK_SUPPORT
 .endif
-.endif
-.endif
 
-CFLAGS+=       -I${SYSDIR}
+# Machine specific flags for all builds here
 
 # All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc
 # or powerpc64.
@@ -122,6 +83,49 @@ LD_FLAGS+=  -m elf_i386_fbsd
 AFLAGS+=       --32
 .endif
 
+SSP_CFLAGS=
+
+# Add in the no float / no SIMD stuff and announce we're freestanding
+# aarch64 and riscv don't have -msoft-float, but all others do. riscv
+# currently has no /boot/loader, but may soon.
+CFLAGS+=       -ffreestanding ${CFLAGS_NO_SIMD}
+.if ${MACHINE_CPUARCH} == "aarch64"
+CFLAGS+=       -mgeneral-regs-only
+.elif ${MACHINE_CPUARCH} != "riscv"
+CFLAGS+=       -msoft-float
+.endif
+
+.if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && 
${DO32:U0} == 1)
+CFLAGS+=       -march=i386
+CFLAGS.gcc+=   -mpreferred-stack-boundary=2
+.endif
+
+
+.if ${MACHINE_CPUARCH} == "arm"
+# Do not generate movt/movw, because the relocation fixup for them does not
+# translate to the -Bsymbolic -pie format required by self_reloc() in 
loader(8).
+# Also, the fpu is not available in a standalone environment.
+.if ${COMPILER_VERSION} < 30800
+CFLAGS.clang+= -mllvm -arm-use-movt=0
+.else
+CFLAGS.clang+= -mno-movt
+.endif
+CFLAGS.clang+=  -mfpu=none
+.endif
+
+# The boot loader build uses dd status=none, where possible, for reproducible
+# build output (since performance varies from run to run). Trouble is that
+# option was recently (10.3) added to FreeBSD and is non-standard. Only use it
+# when this test succeeds rather than require dd to be a bootstrap tool.
+DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true
+DD=dd ${DD_NOSTATUS}
+
+.if ${MK_LOADER_FORCE_LE} != "no"
+.if ${MACHINE_ARCH} == "powerpc64"
+CFLAGS+=       -mlittle-endian
+.endif
+.endif
+
 # Make sure we use the machine link we're about to create
 CFLAGS+=-I.
 
@@ -163,9 +167,5 @@ ${_ILINKS}:
        path=`(cd $$path && /bin/pwd)` ; \
        ${ECHO} ${.TARGET:T} "->" $$path ; \
        ln -fhs $$path ${.TARGET:T}
-
-# For loader implementations, we generate a loader.help file. This can be 
suppressed by
-# setting HELP_FILES to nothing.
-HELP_FILES=    ${LDRSRC}/help.common
 
 .endif # __BOOT_DEFS_MK__

Modified: stable/11/stand/efi/boot1/Makefile
==============================================================================
--- stable/11/stand/efi/boot1/Makefile  Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/efi/boot1/Makefile  Mon Feb 12 17:44:35 2018        
(r329175)
@@ -31,8 +31,9 @@ CWARNFLAGS.zfs_module.c += -Wno-unused-function
 SRCS=  boot1.c self_reloc.c start.S ufs_module.c
 .if ${MK_ZFS} != "no"
 SRCS+=         zfs_module.c
-CFLAGS+=       -I${ZFSSRC}
-CFLAGS+=       -I${SYSDIR}/cddl/boot/zfs
+CFLAGS.zfs_module.c+=  -I${ZFSSRC}
+CFLAGS.zfs_module.c+=  -I${SYSDIR}/cddl/boot/zfs
+CFLAGS.zfs_module.c+=  -I${SYSDIR}/crypto/skein
 CFLAGS+=       -DEFI_ZFS_BOOT
 LIBZFSBOOT=    ${BOOTOBJ}/zfs/libzfsboot.a
 .endif
@@ -105,8 +106,6 @@ boot1.efi: ${PROG}
                -j .dynamic -j .dynsym -j .rel.dyn \
                -j .rela.dyn -j .reloc -j .eh_frame \
                --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
-
-boot1.o: ${SASRC}/ufsread.c
 
 # The following inserts our objects into a template FAT file system
 # created by generate-fat.sh

Modified: stable/11/stand/efi/boot1/boot1.c
==============================================================================
--- stable/11/stand/efi/boot1/boot1.c   Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/efi/boot1/boot1.c   Mon Feb 12 17:44:35 2018        
(r329175)
@@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$");
 
 #include <efi.h>
 #include <eficonsctl.h>
-typedef CHAR16 efi_char;
 #include <efichar.h>
 
 #include "boot_module.h"

Modified: stable/11/stand/efi/include/efichar.h
==============================================================================
--- stable/11/stand/efi/include/efichar.h       Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/efi/include/efichar.h       Mon Feb 12 17:44:35 2018        
(r329175)
@@ -29,6 +29,12 @@
 #ifndef _BOOT_EFI_EFICHAR_H_
 #define        _BOOT_EFI_EFICHAR_H_
 
+#ifdef _STANDALONE
+#include <efi.h>
+
+typedef CHAR16 efi_char;
+#endif
+
 int ucs2_to_utf8(const efi_char *, char **);
 int utf8_to_ucs2(const char *, efi_char **, size_t *);
 int ucs2len(const efi_char *);

Modified: stable/11/stand/efi/libefi/Makefile
==============================================================================
--- stable/11/stand/efi/libefi/Makefile Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/efi/libefi/Makefile Mon Feb 12 17:44:35 2018        
(r329175)
@@ -52,6 +52,4 @@ CFLAGS+= ${FORMAT_EXTENSIONS}
 CFLAGS+= -DTERM_EMU
 .endif
 
-CFLAGS+= -DLIBEFI
-
 .include <bsd.lib.mk>

Modified: stable/11/stand/efi/libefi/efichar.c
==============================================================================
--- stable/11/stand/efi/libefi/efichar.c        Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/efi/libefi/efichar.c        Mon Feb 12 17:44:35 2018        
(r329175)
@@ -29,16 +29,16 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
 #include <errno.h>
-#ifdef LIBEFI
+#ifdef _STANDALONE
 #include <stand.h>
 #else
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#endif
 #include <sys/efi.h>
 #include <machine/efi.h>
+#endif
 
 #include "efichar.h"
 

Modified: stable/11/stand/efi/libefi/efipart.c
==============================================================================
--- stable/11/stand/efi/libefi/efipart.c        Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/efi/libefi/efipart.c        Mon Feb 12 17:44:35 2018        
(r329175)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <efi.h>
 #include <efilib.h>
 #include <efiprot.h>
+#include <efichar.h>
 #include <disk.h>
 
 static EFI_GUID blkio_guid = BLOCK_IO_PROTOCOL;
@@ -196,6 +197,82 @@ efipart_floppy(EFI_DEVICE_PATH *node)
 }
 
 /*
+ * Determine if the provided device path is hdd.
+ *
+ * There really is no simple fool proof way to classify the devices.
+ * Since we do build three lists of devices - floppy, cd and hdd, we
+ * will try to see  if the device is floppy or cd, and list anything else
+ * as hdd.
+ */
+static bool
+efipart_hdd(EFI_DEVICE_PATH *dp)
+{
+       unsigned i, nin;
+       EFI_DEVICE_PATH *devpath, *node;
+       EFI_BLOCK_IO *blkio;
+       EFI_STATUS status;
+
+       if (dp == NULL)
+               return (false);
+
+       if ((node = efi_devpath_last_node(dp)) == NULL)
+               return (false);
+
+       if (efipart_floppy(node) != NULL)
+               return (false);
+
+       /*
+        * Test every EFI BLOCK IO handle to make sure dp is not device path
+        * for CD/DVD.
+        */
+       nin = efipart_nhandles / sizeof (*efipart_handles);
+       for (i = 0; i < nin; i++) {
+               devpath = efi_lookup_devpath(efipart_handles[i]);
+               if (devpath == NULL)
+                       return (false);
+
+               /* Only continue testing when dp is prefix in devpath. */
+               if (!efi_devpath_is_prefix(dp, devpath))
+                       continue;
+
+               /*
+                * The device path has to have last node describing the
+                *  device, or we can not test the type.
+                */
+               if ((node = efi_devpath_last_node(devpath)) == NULL)
+                       return (false);
+
+               if (DevicePathType(node) == MEDIA_DEVICE_PATH &&
+                   DevicePathSubType(node) == MEDIA_CDROM_DP) {
+                       return (false);
+               }
+
+               /* Make sure we do have the media. */
+               status = BS->HandleProtocol(efipart_handles[i],
+                   &blkio_guid, (void **)&blkio);
+               if (EFI_ERROR(status))
+                       return (false);
+
+               /* USB or SATA cd without the media. */
+               if (blkio->Media->RemovableMedia &&
+                   !blkio->Media->MediaPresent) {
+                       return (false);
+               }
+
+               /*
+                * We assume the block size 512 or greater power of 2. 
+                * iPXE is known to insert stub BLOCK IO device with
+                * BlockSize 1.
+                */
+               if (blkio->Media->BlockSize < 512 ||
+                   !powerof2(blkio->Media->BlockSize)) {
+                       return (false);
+               }
+       }
+       return (true);
+}
+
+/*
  * Add or update entries with new handle data.
  */
 static int
@@ -308,9 +385,13 @@ efipart_updatecd(void)
 
                if ((node = efi_devpath_last_node(devpath)) == NULL)
                        continue;
+
                if (efipart_floppy(node) != NULL)
                        continue;
 
+               if (efipart_hdd(devpath))
+                       continue;
+
                status = BS->HandleProtocol(efipart_handles[i],
                    &blkio_guid, (void **)&blkio);
                if (EFI_ERROR(status))
@@ -380,13 +461,21 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE 
        pdinfo_t *hd, *pd, *last;
 
        disk_devpath = efi_lookup_devpath(disk_handle);
-       part_devpath = efi_lookup_devpath(part_handle);
-       if (disk_devpath == NULL || part_devpath == NULL) {
+       if (disk_devpath == NULL)
                return (ENOENT);
+
+       if (part_handle != NULL) {
+               part_devpath = efi_lookup_devpath(part_handle);
+               if (part_devpath == NULL)
+                       return (ENOENT);
+               node = (HARDDRIVE_DEVICE_PATH *)
+                   efi_devpath_last_node(part_devpath);
+               if (node == NULL)
+                       return (ENOENT);        /* This should not happen. */
+       } else {
+               part_devpath = NULL;
+               node = NULL;
        }
-       node = (HARDDRIVE_DEVICE_PATH *)efi_devpath_last_node(part_devpath);
-       if (node == NULL)
-               return (ENOENT);        /* This should not happen. */
 
        pd = calloc(1, sizeof(pdinfo_t));
        if (pd == NULL) {
@@ -397,6 +486,9 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE 
 
        STAILQ_FOREACH(hd, &hdinfo, pd_link) {
                if (efi_devpath_match(hd->pd_devpath, disk_devpath) == true) {
+                       if (part_devpath == NULL)
+                               return (0);
+
                        /* Add the partition. */
                        pd->pd_handle = part_handle;
                        pd->pd_unit = node->PartitionNumber;
@@ -419,6 +511,9 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE 
        hd->pd_devpath = disk_devpath;
        STAILQ_INSERT_TAIL(&hdinfo, hd, pd_link);
 
+       if (part_devpath == NULL)
+               return (0);
+
        pd = calloc(1, sizeof(pdinfo_t));
        if (pd == NULL) {
                printf("Failed to add partition, out of memory\n");
@@ -470,8 +565,7 @@ efipart_hdinfo_add_filepath(EFI_HANDLE disk_handle)
                unit = 0;
 
        /* FILEPATH_DEVICE_PATH has 0 terminated string */
-       for (len = 0; node->PathName[len] != 0; len++)
-               ;
+       len = ucs2len(node->PathName);
        if ((pathname = malloc(len + 1)) == NULL) {
                printf("Failed to add disk, out of memory\n");
                free(pd);
@@ -541,7 +635,8 @@ efipart_updatehd(void)
 
                if ((node = efi_devpath_last_node(devpath)) == NULL)
                        continue;
-               if (efipart_floppy(node) != NULL)
+
+               if (!efipart_hdd(devpath))
                        continue;
 
                status = BS->HandleProtocol(efipart_handles[i],
@@ -550,6 +645,12 @@ efipart_updatehd(void)
                        continue;
 
                if (DevicePathType(node) == MEDIA_DEVICE_PATH &&
+                   DevicePathSubType(node) == MEDIA_FILEPATH_DP) {
+                       efipart_hdinfo_add_filepath(efipart_handles[i]);
+                       continue;
+               }
+
+               if (DevicePathType(node) == MEDIA_DEVICE_PATH &&
                    DevicePathSubType(node) == MEDIA_HARDDRIVE_DP) {
                        devpathcpy = efi_devpath_trim(devpath);
                        if (devpathcpy == NULL)
@@ -568,18 +669,16 @@ efipart_updatehd(void)
                                continue;
                        if ((node = efi_devpath_last_node(devpathcpy)) == NULL)
                                continue;
+
                        if (DevicePathType(node) == MEDIA_DEVICE_PATH &&
                            DevicePathSubType(node) == MEDIA_HARDDRIVE_DP)
                                continue;
+
                        efipart_hdinfo_add(handle, efipart_handles[i]);
                        continue;
                }
 
-               if (DevicePathType(node) == MEDIA_DEVICE_PATH &&
-                   DevicePathSubType(node) == MEDIA_FILEPATH_DP) {
-                       efipart_hdinfo_add_filepath(efipart_handles[i]);
-                       continue;
-               }
+               efipart_hdinfo_add(efipart_handles[i], NULL);
        }
 }
 

Modified: stable/11/stand/efi/loader/Makefile
==============================================================================
--- stable/11/stand/efi/loader/Makefile Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/efi/loader/Makefile Mon Feb 12 17:44:35 2018        
(r329175)
@@ -89,7 +89,6 @@ CFLAGS+=      -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
 .endif
 
 # Always add MI sources
-HELP_FILES=
 .include       "${BOOTSRC}/loader.mk"
 
 FILES+=        loader.efi

Modified: stable/11/stand/efi/loader/main.c
==============================================================================
--- stable/11/stand/efi/loader/main.c   Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/efi/loader/main.c   Mon Feb 12 17:44:35 2018        
(r329175)
@@ -32,7 +32,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/reboot.h>
 #include <sys/boot.h>
-#include <inttypes.h>
+#include <stdint.h>
 #include <stand.h>
 #include <string.h>
 #include <setjmp.h>
@@ -501,7 +501,7 @@ main(int argc, CHAR16 *argv[])
 #endif
        }
 
-       interact(NULL);                 /* doesn't return */
+       interact();                     /* doesn't return */
 
        return (EFI_SUCCESS);           /* keep compiler happy */
 }

Modified: stable/11/stand/ficl.mk
==============================================================================
--- stable/11/stand/ficl.mk     Mon Feb 12 17:42:28 2018        (r329174)
+++ stable/11/stand/ficl.mk     Mon Feb 12 17:44:35 2018        (r329175)
@@ -12,8 +12,6 @@ FICL_CPUARCH= mips64
 FICL_CPUARCH=  ${MACHINE_CPUARCH}
 .endif
 
-.PATH: ${FICLSRC} ${FICLSRC}/${FICL_CPUARCH}
-
 .if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0
 CFLAGS+=       -fPIC
 .endif

Modified: stable/11/stand/ficl/Makefile
==============================================================================
--- stable/11/stand/ficl/Makefile       Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/ficl/Makefile       Mon Feb 12 17:44:35 2018        
(r329175)
@@ -4,6 +4,8 @@
 .include <bsd.init.mk>
 .include "${BOOTSRC}/ficl.mk"
 
+.PATH: ${FICLSRC} ${FICLSRC}/${FICL_CPUARCH}
+
 BASE_SRCS=     dict.c ficl.c fileaccess.c float.c loader.c math64.c \
                prefix.c search.c stack.c tools.c vm.c words.c
 

Modified: stable/11/stand/ficl/float.c
==============================================================================
--- stable/11/stand/ficl/float.c        Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/ficl/float.c        Mon Feb 12 17:44:35 2018        
(r329175)
@@ -43,14 +43,14 @@
 
 /* $FreeBSD$ */
 
+#include "ficl.h"
+
+#if FICL_WANT_FLOAT
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 #include <math.h>
-#include "ficl.h"
-
-#if FICL_WANT_FLOAT
 
 /*******************************************************************
 ** Do float addition r1 + r2.

Modified: stable/11/stand/geli/Makefile
==============================================================================
--- stable/11/stand/geli/Makefile       Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/geli/Makefile       Mon Feb 12 17:44:35 2018        
(r329175)
@@ -2,6 +2,7 @@
 # libgeliboot
 
 MAN=
+DO32=1
 
 .include <bsd.init.mk>
 MK_SSP=                no
@@ -11,19 +12,6 @@ INTERNALLIB=
 MK_PROFILE=    no
 NO_PIC=
 
-.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
-CFLAGS+=        -march=i386
-.endif
-.if ${MACHINE_ARCH} == "amd64"
-CFLAGS+=        -m32
-.endif
-
-WARNS?=                0
-
-# string functions from libc
-.PATH: ${SRCTOP}/lib/libc/string
-SRCS+=  bcmp.c bcopy.c bzero.c
-
 # Our password input method
 SRCS+=  pwgets.c
 
@@ -45,7 +33,6 @@ SRCS+=                rijndael-alg-fst.c rijndael-api-fst.c 
rijndael
 
 # local GELI Implementation
 .PATH: ${SYSDIR}/geom/eli
-CFLAGS+=       -D_STAND
 SRCS+=         geliboot_crypto.c g_eli_hmac.c g_eli_key.c g_eli_key_cache.c 
pkcs5v2.c
 
 # aes

Modified: stable/11/stand/geli/geliboot.c
==============================================================================
--- stable/11/stand/geli/geliboot.c     Mon Feb 12 17:42:28 2018        
(r329174)
+++ stable/11/stand/geli/geliboot.c     Mon Feb 12 17:44:35 2018        
(r329175)
@@ -222,7 +222,7 @@ geli_taste(int read_func(void *vdev, void *priv, off_t
  */
 static int
 geli_attach(struct geli_entry *ge, struct dsk *dskp, const char *passphrase,
-    const u_char *mkeyp)
+    u_char *mkeyp)
 {
        u_char key[G_ELI_USERKEYLEN], mkey[G_ELI_DATAIVKEYLEN], *mkp;
        u_int keynum;
@@ -248,7 +248,7 @@ geli_attach(struct geli_entry *ge, struct dsk *dskp, c
        } else if (geli_e->md.md_iterations == 0) {
                g_eli_crypto_hmac_update(&ctx, geli_e->md.md_salt,
                    sizeof(geli_e->md.md_salt));
-               g_eli_crypto_hmac_update(&ctx, passphrase,
+               g_eli_crypto_hmac_update(&ctx, (const uint8_t *)passphrase,
                    strlen(passphrase));
        } else if (geli_e->md.md_iterations > 0) {
                printf("Calculating GELI Decryption Key disk%dp%d @ %d"
@@ -294,7 +294,7 @@ found_key:
                /*
                 * The encryption key is: ekey = HMAC_SHA512(Data-Key, 0x10)
                 */
-               g_eli_crypto_hmac(mkp, G_ELI_MAXKEYLEN, "\x10", 1,
+               g_eli_crypto_hmac(mkp, G_ELI_MAXKEYLEN, (const uint8_t 
*)"\x10", 1,
                    geli_e->sc.sc_ekey, 0);
        }
        explicit_bzero(mkey, sizeof(mkey));

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to