awk(1): Override FOPEN_MAX to handle 64 open files instead of 20
Awk uses a fixed array of size FOPEN_MAX to track the open files, so it
could only open max 20 files as the default FOPEN_MAX is defined to be
20 in <stdio.h>. Override FOPEN_MAX to 64 to support more open files.
Obtained-from: FreeBSD (commit d97cdd33492f5afe2150e1fced657c9a31911c67)
bsd.crunchgen.mk: Pass CFLAGS to "make exe" to enable WARNS
The "make exe" phase builds the stub objects and the final crunched
executable. Because the crunchgen(1) generated makefile does not
include any makefile from the system, the ${CFLAGS} was empty and the
${WARNS} tunable was ineffective.
By explicitly passing the ${CFLAGS} to the "make exe" phase, the ${WARNS}
is correctly accounted in the main Makefile (that includes
<bsd.crunchgen.mk>) and works as expected.
The "make objs" that builds the objects of each individual tool to be
crunched is not affected. Those objects are already built with their
corresponding ${WARNS} and ${CFLAGS}.
As we're explicitly setting the ${CFLAGS}, filter the LTO flags in
<bsd.crunchgen.mk> and thus revert the previous commit
a3f29142615c9b60b7f2d6c4eecbf55e595d778b.
[6 lines not shown]
crunchgen(1): Fix compilation warnings (prepare for future update)
Fix the following compilation warnings when we enable WARNS for
initrd/{rescue,rescue.libcrypto} build in the future:
```
rescue.c: In function 'cmpstringp':
rescue.c:88:20: error: cast discards 'const' qualifier from pointer target type [-Werror=cast-qual]
const char *s1 = *(const char **)p1;
^
rescue.c:89:20: error: cast discards 'const' qualifier from pointer target type [-Werror=cast-qual]
const char *s2 = *(const char **)p2;
^
rescue.c: In function 'crunched_usage':
rescue.c:96:1: error: old-style function definition [-Werror=old-style-definition]
crunched_usage()
^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```
[2 lines not shown]
uname(1): Add '-b' flag to show the kernel's build-ID
The kernel's build-ID has been exposed via the "kern.build_id" sysctl
MIB. Add a '-b' flag to uname(1) to report it.
Obtained-from: FreeBSD (https://reviews.freebsd.org/D20511)
kern.pre.mk: Introduce ${ELDFLAGS} to help customize linker flags
Similar to the case in kmod.mk, introduce the ${ELDFLAGS} variable to
collect the linker flags and makes it easier to customize them.
While there, clean up a bit.
platform: Remove obsolete '.exception_ranges' from linker scripts
As the comment says, it was generate by the Sun/Oracle C++ compiler,
so does not apply to us. Just remove it as FreeBSD did.
See also: FreeBSD
kernel: Expose the build-ID via "kern.build_id" sysctl
Update the linker scripts to expose the start and end of the
linker-generated build-ID, and add the "kern.build_id" sysctl handler to
fetch the information.
A subsequent commit will update uname(1) to report it as well.
Obtained-from: FreeBSD (https://reviews.freebsd.org/D20326)
platform: Use INT3 instead of NOP for x86 binary padding
We should never end up executing the inter-function padding, so we
are better off faulting than silently carrying on to whatever function
happens to be next.
Obtained-from: FreeBSD (https://reviews.freebsd.org/D10047)
stand: Remove obsolete 'FREEBSD_ELF' define
The last use of it was removed from <link.h> back in 2002 in FreeBSD, so
it never affected DragonFly.
Obtained-from: FreeBSD (https://reviews.freebsd.org/D42964)
platform: Move debug sections to a common linker script
In addition, sync the debug sections with FreeBSD's to add DWARF 4 and 5.
Obtained-from: FreeBSD (https://reviews.freebsd.org/D44071)
platform: Remove .ldata/.lrodata/.lbss sections from ldscript
The kernel is compiled with '-mcmodel=kernel', so the compiler never
emits the large model sections (e.g., .ldata/.lrodata/.lbss). Therefore,
remove such sections from the kernel linker scripts.
This change has another major benefit: the '.bss' section now correctly
lies at the end, so the linker does not need to allocate real file space
to store the BSS section. As a result, the kernel file size is reduced
by 14MB (e.g., stripped kernel reduces from 29MB to 15MB)! Meanwhile,
the following gold linker warning is also fixed:
```
/usr/libexec/binutils234/elf/ld.gold: warning: script places BSS section in the middle of a LOAD segment; space will be allocated in the file
```
See also: FreeBSD (https://reviews.freebsd.org/D21859)
platform: Remove wrong comment from ldscript
The comment 'default linker script' was copied from the GNU ld's default
linker script, and is obviously wrong for the kernel, so just remove it.
kern.post.mk: Early fail the build in case of any duplicate objs
Since all the kernel objects are built and placed in the same directory,
a conflict is quite possible when two modules have a file with the same
name. Another conflict possibility is that the source is specified
twice in conf/files.
In order to avoid running into mysterious/unexpected issues caused by
duplicate objects, simply abort the build when such a duplicate is
found.
Of course, a better solution is to refactor the build framework to
eliminate such a limitation, so that a module may choose whatever
filename it likes.
bsd.kern.mk: Remove -finline-limit and related compiler parameters
These compiler flags/parameter were inherited from FreeBSD. They
basically meant to ALWAYS inline the functions mark with the 'inline'
keyword. Since modern GCC provides with the 'always_inline' attribute,
it's better to use '__always_inline' annotation for those functions that
must be inlined. As a result, remove the '-finline-limit' and related
parameters to achieve better inlining results; e.g., it avoids
unnecessary over-inlining.
kernel: Adjust inlining annotations for better results
We will be removing the '-finline-limit=8000 ...' compiler flags, which
can change the inlining results. By adjusting the inlining annoations
with proper '__always_inline' annotations, the inlining results become
better and more deterministic.
In the meantime, a few unnecessary '__inline' annotations are removed.
Discussed-with: dillon
kern.pre.mk: Remove 'gcc2_compiled.' symbol stripping
This was inherited from FreeBSD and has long been obsolete since GCC 3.
See also: FreeBSD (https://reviews.freebsd.org/D38764)
ddb - Try AcpiReset() when invoking DDB's reset command.
- This allows some modern notebooks to successfully reset from DDB, where
the classic outb(0x64, 0xFE) method no longer works. For some notebooks,
we'll also need to support EFI Reset here, but that will require further
work.
efirt - Register EFI Reset with the shutdown_final EVENTHANDLER.
- This adds a safeguard to efi_enter() to fail gracefully when called from
a kernel thread, where curthread->td_lwp is NULL.
- Further work is needed to allow EFI Reset to work more simply without
messing with the current LWP's vmspace.