Commit Graph

43 Commits

Author SHA1 Message Date
Warner Losh
158c18ffb4 dd is currently a bootstrap tool. It really doesn't have any business
being a bootstrap tool. However, for reproducible build output,
FreeBSD added dd status=none because it was otherwise difficult to
suppress the status information, but retain any errors that might
happen. There's no real reason that dd has to be a build tool, other
than we use status=none unconditional. Remove dd from a bootstrap tool
entirely by only using status=none when available. This may also help
efforts to build the system on non-FreeBSD hosts as well.

Differential Revision: https://reviews.freebsd.org/D8605
2016-12-02 14:44:38 +00:00
Pedro F. Giffuni
768f89e078 sys/boot: make use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
2016-04-26 14:51:58 +00:00
Warner Losh
5bbc34e185 Move all the separate copies of the same strings into paths.h. There's
nothing machine specific about these.

Differential Revision: https://reviews.freebsd.org/D5038
2016-01-26 06:26:19 +00:00
Bryan Drewery
5608fd23c2 Revert r267233 for now. PIE support needs to be reworked.
1. 50+% of NO_PIE use is fixed by adding -fPIC to INTERNALLIB and other
   build-only utility libraries.
2. Another 40% is fixed by generating _pic.a variants of various libraries.
3. Some of the NO_PIE use is a bit absurd as it is disabling PIE (and ASLR)
   where it never would work anyhow, such as csu or loader. This suggests
   there may be better ways of adding support to the tree. Many of these
   cases can be fixed such that -fPIE will work but there is really no
   reason to have it in those cases.
4. Some of the uses are working around hacks done to some Makefiles that are
   really building libraries but have been using bsd.prog.mk because the code
   is cleaner. Had they been using bsd.lib.mk then NO_PIE would not have
   been needed.

We likely do want to enable PIE by default (opt-out) for non-tree consumers
(such as ports). For in-tree though we probably want to only enable PIE
(opt-in) for common attack targets such as remote service daemons and setuid
utilities. This is also a great performance compromise since ASLR is expected
to reduce performance. As such it does not make sense to enable it in all
utilities such as ls(1) that have little benefit to having it enabled.

Reported by:	kib
2014-08-19 15:04:32 +00:00
Bryan Drewery
864c53ead8 In preparation for ASLR [1] support add WITH_PIE to support building with -fPIE.
This is currently an opt-in build flag. Once ASLR support is ready and stable
it should changed to opt-out and be enabled by default along with ASLR.

Each application Makefile uses opt-out to ensure that ASLR will be enabled by
default in new directories when the system is compiled with PIE/ASLR. [2]

Mark known build failures as NO_PIE for now.

The only known runtime failure was rtld.

[1] http://www.bsdcan.org/2014/schedule/events/452.en.html
Submitted by:		Shawn Webb <lattera@gmail.com>
Discussed between:	des@ and Shawn Webb [2]
2014-06-08 17:29:31 +00:00
Warner Losh
3bdf775801 NO_MAN= has been deprecated in favor of MAN= for some time, go ahead
and finish the job. ncurses is now the only Makefile in the tree that
uses it since it wasn't a simple mechanical change, and will be
addressed in a future commit.
2014-04-13 05:21:56 +00:00
Dimitry Andric
d7c3b3b9de For now, clang spells -mcmodel=medlow as -mcmodel=small. 2014-02-21 21:51:19 +00:00
Marius Strobl
c0c11f4c92 Restore pre-r234898 printing of boot loader and path.
MFC after:	3 days
2012-12-16 20:43:29 +00:00
Marius Strobl
c261e6bfe4 Fix build after r243245.
Submitted by:	trasz
2012-11-19 19:31:54 +00:00
Gleb Kurtsou
491a40587d Use 32-bit ufs_ino_t instead of ino_t to keep boot2 small and prevent
unnecessary 64-bit math on 32-bit machines.

Sponsored by:	Google Summer of Code 2011
2012-05-25 09:36:39 +00:00
Marius Strobl
e4b3eb5fe3 Use a non-tricky approach for building and installing zfsboot sharing
the Makefile with boot1.

Submitted by:	ru
2012-05-09 19:08:54 +00:00
Marius Strobl
2d75b8321f Add initial support for booting from ZFS on sparc64. At least on Sun Fire
V100, the firmware is known to be broken and not allowing to simultaneously
open disk devices, causing attempts to boot from a mirror or RAIDZ to cause
a crash. This will be worked around later. The firmwares of newer sun4u models
don't seem to exhibit this problem though.

Steps for ZFS booting:

1. create VTOC8 label
# gpart create -s vtoc8 da0

2. add partitions, f.e.:
# gpart add -t freebsd-zfs -s 60g da0
# gpart add -t freebsd-swap da0
resulting in something like:
# gpart show
=>        0  143331930  da0  VTOC8  (68G)
          0  125821080    1  freebsd-zfs  (60G)
  125821080   17510850    2  freebsd-swap  (8.4G)

3. create zpool
# zpool create bunker da0a
or for mirror/RAIDZ (after preparing additional disks as in steps 1. + 2.):
# zpool create bunker mirror da0a da1a
# zpool create bunker raidz da0a da1a da2a ...

4. set bootfs
# zpool set bootfs=bunker bunker

5. install zfsboot
# zpool export bunker
# gpart bootcode -p /boot/zfsboot da0

6. write zfsloader to the ZFS Boot Block (so far, there's no dedicated tool
for this, so dd(1) has to be used for this purpose)
When using mirror/RAIDZ, step 4. and the dd(1) invocation should be repeated
for the additional disks in order to be able to boot from another disk in
case of failure.
# sysctl kern.geom.debugflags=0x10
# dd if=/boot/zfsloader of=/dev/da0a bs=512 oseek=1024 conv=notrunc
# zpool import bunker

7. install system on ZFS filesystem
Don't forget to set 'zfs_load="YES"' and vfs.root.mountfrom="zfs:bunker" in
loader.conf as well as 'zfs_enable="YES"'in rc.conf.

8. copy zpool.cache to the ZFS filesystem
cp -p /boot/zfs/zpool.cache /bunker/boot/zfs/zpool.cache

9. set mountpoint
# zfs set mountpoint=/ bunker

10. Now, given that aliases for all disks in the zpool exists (check with
the `devalias` command on the boot monitor prompt) and disk0 corresponds
to da0 (likewise for additional disks), the system can be booted from the
ZFS with:
{1} ok boot disk0

PR:             165025
Submitted by:   Gavin Mu
2012-05-01 17:16:01 +00:00
Marius Strobl
fe198baaa6 Merge from powerpc:
- Change putc_func_t to use a char instead of an int for the character.
- Make functions and variables not used outside of this source file static.
- Remove unused prototypes and variables.
- The OFW read and seek methods take 3 and not 4 input arguments.
2010-09-16 12:05:00 +00:00
Ed Schouten
d05becf2b6 Use -Wl,-N instead of the undocumented -N option for GCC.
GCC forwards the -N flag directly to ld. This flag is not documented and
not supported by (for example) Clang. Just use -Wl,-N.

Submitted by:	Pawel Worach
2010-06-03 17:42:32 +00:00
Warner Losh
6a0fd84b50 Start each of the license/copyright comments with /*- 2005-01-05 22:16:58 +00:00
Ruslan Ermilov
e653b48c80 Start the dreaded NOFOO -> NO_FOO conversion.
OK'ed by:	core
2004-12-21 08:47:35 +00:00
Marius Strobl
39513fa664 Instead of "OpenFirmware", "openfirmware", etc. use the official spelling
"Open Firmware" from IEEE 1275 and OpenFirmware.org (no pun intended).

Ok'ed by:	tmm
2004-08-16 15:45:27 +00:00
Ruslan Ermilov
23350aaf89 _start.S -> _start.s as the latter is pure asm file.
Repocopied by:	joe
2004-02-11 21:17:04 +00:00
Ruslan Ermilov
78d6d797e9 MFi386.
- Factor out common settings and put them in an upper level Makefile.inc.
- Properly use PROG for real programs, not their products.
- Further reduce diffs to i386 versions.

Tested on:	sparc64 (panther)
2004-02-09 14:17:02 +00:00
David E. O'Brien
bd506e2a3a Convert to __FBSDID. 2004-01-04 23:21:18 +00:00
Poul-Henning Kamp
f770d2d3dd Cut&Paste considered far too easy:
Don't include <sys/disklabel.h>
2003-04-16 21:09:41 +00:00
Poul-Henning Kamp
197e5e73ef Libdisk does not need to include <sys/diskslice.h> any more.
Move the remaining bits of <sys/diskslice.h> to <i386/include/bootinfo.h>

Move i386/pc98 specific bits from <sys/reboot.h> to
<i386/include/bootinfo.h> as well.

Adjust includes in sys/boot accordingly.
2003-04-04 16:35:16 +00:00
Poul-Henning Kamp
080ef30b20 Add explicit dependency on ufsread.c 2002-06-05 12:30:45 +00:00
Poul-Henning Kamp
af53575a04 Remove UFS related #includes, they're read in ufsread.c now. 2002-06-05 12:12:25 +00:00
Poul-Henning Kamp
3795d538a8 Make sparc64 share ufsread.c with i386.
Sponsored by: DARPA & NAI Labs.
2002-06-05 12:00:53 +00:00
Poul-Henning Kamp
7cbccd7f79 Avoid entering IOCCC with a memcpy turned bcopy. 2002-06-05 11:56:12 +00:00
David E. O'Brien
21ab21338d Match the default newfs UFS block size. 2002-05-13 05:09:34 +00:00
David E. O'Brien
d1bdfb40fd -ffreestanding is the word.
(also resort some CFLAGS such that the more "important" value are first so
they are easier to see)
2002-05-10 09:26:35 +00:00
Jake Burkholder
127e8646b8 Split file system setup code out into a function called mount.
Implement vsnprintf.  Implement panic in terms of it.
2002-04-24 05:54:10 +00:00
Jake Burkholder
0d0c927680 Add support for loading files other than /boot/loader. Useful if you're
loader is screwed and you want loader.old.
Rewrite the scaled down printf so it actually works right, and add support
for more formats.
2002-04-24 04:27:49 +00:00
Jake Burkholder
3ff6556567 Add an exit function. 2002-04-24 02:50:59 +00:00
Jake Burkholder
083d8c5bab Add -Wno-unused. 2002-04-24 02:50:36 +00:00
Jake Burkholder
8c2f8986a6 memcpy, memset -> bcopy, bzero. 2002-04-24 02:24:32 +00:00
Jake Burkholder
4b487ad2ec Clean up elf loading to not make assumptions about the ordering of sections.
Don't load the symbol table; this is only needed for loading kernels and we
load the loader.
2002-04-24 02:10:35 +00:00
Jake Burkholder
e2b255fdea Remove xfsread. Just call fsread directly. 2002-04-24 01:47:05 +00:00
Jake Burkholder
912ceb7f18 Remove a bunch of unused variables, functions and macros. Allocate storage
statically instead of using a faked up malloc.
2002-04-24 01:40:54 +00:00
David E. O'Brien
34ef85ee3d o Use our own elf2aout now.
o Generalize a little.
2002-04-21 02:37:55 +00:00
Thomas Moestl
163f47b1ec 1.) Produce a boot1 disklabel template of the format disklabel(8) expects.
2.) Clean up and change over to using bsd.prog.mk

Submitted by:	jake (2)
2002-04-01 22:57:51 +00:00
David E. O'Brien
20d9715213 Apparently either gcc or ld, in their infinite wisdom, want to
put a bunch of crap before the code in .text.  Since the firmware
doesn't seem to honour the a.out entry point, we need to include
a little assmbler file which jumps to where we want to be in C.

Submitted by:	jake
2002-03-28 02:41:52 +00:00
Robert Drehmel
aa22cb469c Change every occurrence of "bootblock" into "boot1" after
the repo-move from "src/sys/boot/sparc64/bootblock".
2002-03-05 16:39:36 +00:00
Robert Drehmel
83ea6c23b5 - Fix seeking for offsets requiring more than 32 bits.
- Add sanity checks to lookup().
 - Implement the 'l' modifier in printf().

Submitted by:	tmm
2002-03-05 11:22:43 +00:00
Robert Drehmel
4d79812a7c - Fix indentation and return statements to conform to style(9).
- Use the __FBSDID macro.
 - Fix some warnings.

Submitted by:	obrien (partly)
2002-02-26 10:05:20 +00:00
Robert Drehmel
c119807ba8 Add the FreeBSD/sparc64 bootblock and its make file. 2002-02-15 12:49:20 +00:00