Commit Graph

95 Commits

Author SHA1 Message Date
Idan Horowitz
f7a1f28d7f Kernel: Add initial basic support for KASAN
This commit adds minimal support for compiler-instrumentation based
memory access sanitization.
Currently we only support detection of kmalloc redzone accesses, and
kmalloc use-after-free accesses.

Support for inline checks (for improved performance), and for stack
use-after-return and use-after-return detection is left for future PRs.
2023-12-30 13:57:10 +01:00
Daniel Bertalan
4defa401d3 Toolchain+Ports: Update binutils to 2.41
Aside from a straightforward rebase, this contains an out-of-tree patch
from MaskRay which adds the `-Bsymbolic-non-weak-functions` flag to ld.
2023-09-18 10:26:42 +02:00
Daniel Bertalan
ae21002cb5 Toolchain+Ports: Update GCC to 13.2.0
This is a minor bugfix release, which to my knowledge contains nothing
of importance to us. However, there is one QoL change to our patches.

We no longer force `-fpic` in the compiler driver, and instead use the
`--enable-default-pie` configure option to generate position-independent
code suitable for executables. For building shared libraries, the
`-fpic` flag must be specified explicitly.
2023-09-18 10:26:42 +02:00
Daniel Bertalan
d87fbcccb7 Toolchain+Ports: Update QEMU to 8.1.0
This version contains my patch that adds support for the proprietary
VideoCore mailbox message for reading the kernel command line, so
patches aren't needed anymore.
2023-09-17 15:26:20 -06:00
kleines Filmröllchen
0b91d36a1e Toolchain: Build Clang with RISC-V support 2023-08-11 13:35:17 +02:00
Sönke Holz
9522794a0e Toolchain: Add (basic) support for riscv64
This makes `ARCH=riscv64 Toolchain/BuildGNU.sh` work, but the patches
might not be completely correct.
2023-08-11 09:20:08 +02:00
Shannon Booth
2b46e6f664 Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2023-07-15 16:21:29 +02:00
implicitfield
941d68ac2d Toolchain+Ports: Update LLVM to 16.0.6 2023-06-27 12:40:38 +02:00
Daniel Bertalan
02fe3feb71 Toolchain: Enable RELRO support for AArch64
The BFD linker requires the `COMMONPAGESIZE` emulation parameter to be
set in order to enable RELRO support for AArch64. As we are adding a
custom `emulparams` file anyways, let's also tell LD that our ELF
interpreter is called `/usr/lib/Loader.so`.

This commit also removes some vestigial references to i686 SerenityOS.
The one in `gas/configure.tgt` is still needed, as it also handles
x86_64.
2023-05-15 07:00:29 +02:00
Daniel Bertalan
07918b79b7 Toolchain+Ports: Update GCC to 13.1.0
This is a mostly straight-forward rebase of our patches on top of
13.1.0. The spec files needed a change, as GCC no longer supports STABS
debug information, but we were building GCC with support for it.

Highlights of this release include static `operator()`, The Equality
Operator You Are Looking For and extended `constexpr` support.
2023-05-15 07:00:29 +02:00
Daniel Bertalan
20fcbcb860 Toolchain: Patch QEMU to support reading kernel cmdline via RPI Mailbox
This commit backports my upstream QEMU patch to implement this
functionality, which is currently waiting for review.

It was submitted here:
https://lists.nongnu.org/archive/html/qemu-arm/2023-04/msg00549
2023-04-29 08:24:18 +02:00
Tim Schumacher
18565dd286 Ports/llvm: Increase the default stack size for LLVM executables 2023-04-14 10:05:05 +02:00
Andrew Kaster
d74fa5e283 Toolchain: Allow many patches for gdb and add clang workaround
This ports https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ae61525fcf456ab395d55c45492a106d1275873a
from upstream binutils, which enables building with the newest host
clang versions.
2023-04-02 10:52:28 +02:00
Cameron Youell
cff303bd69 Ports/binutils: Update binutils to version 2.40 2023-03-27 14:27:32 +01:00
Tim Schumacher
cd5868a0f1 Toolchain: Don't abuse crt{begin,end}.o for shared or PIE binaries
aarch64 required this to successfully build, but the actual fix to that
is to just make sure that crtbeginS and crtendS get built as a part of
the toolchain.

This partially reverts commit c18c84dbfd.
2023-03-01 12:41:56 +00:00
Timon Kruiper
7eccacf418 Toolchain: Ensure aarch64 libgcc_s.so.1 includes DT_SONAME tag
Without this tag, executables that link libgcc_s.so.1, which is every
executable, end up with the host path to libgcc_s.so.1 as the path for
the dynamic dependency (DT_NEEDED) of the executable. By making sure
that the libgcc_s.so.1 shared object includes the DT_SONAME tag, the
path to libgcc_s.so.1 dynamic dependency will only contain the basename,
instead of the absolute host path.
2023-01-25 14:28:53 +01:00
Liav A
55f17fff36 Meta: Remove i686 target 2022-12-28 11:53:41 +01:00
Kenneth Myhra
e152a28737 Toolchain: Update BuildQemu.sh to qemu-7.1
QEMU 7.1 was released on August 30th.
Release Notes: https://wiki.qemu.org/ChangeLog/7.1

The patch 'Toolchain/Patches/qemu-cf-protection-none.patch' (or similar)
has been upstreamed so it can be safely removed.
2022-10-27 13:29:40 +02:00
Tim Schumacher
335fd20c34 Toolchain: Keep LLVM from using shm_open and friends
I originally missed this while handling the upgrade to LLVM 15 (as it
only affects the on-serenity port), so the patch gets to be here with a
bit of a delay.

Co-Authored-By: sin-ack <sin-ack@users.noreply.github.com>
2022-10-21 20:15:34 +02:00
Gunnar Beutner
c18c84dbfd Toolchain: Fix building libgcc for AARCH64
There was a typo in one of the spec files which resulted in us not
building softfp support for libgcc. Additionally we were missing flags
to build libgcc_s. This patch also makes sure we're not trying to
link against crtbeginS.o and crtendS.o. This is part of a larger effort
to at least get the userland to build at all.
2022-10-14 13:01:13 +02:00
Tim Schumacher
24987e2b1f Toolchain: Add SerenityOS to the LLVM config.guess 2022-10-14 12:57:55 +02:00
Tim Schumacher
1faca15193 Toolchain: Move the binutils patch into its own folder
This makes binutils compatible with `./package.sh dev`, so that we can
regenerate patches more easily, and neatly stack (temporary) patches on
top.
2022-10-01 18:43:29 +01:00
Tim Schumacher
cb2f0d9861 Toolchain: Regenerate patches using the latest format rules 2022-09-18 13:00:46 +04:30
Tim Schumacher
77f124c87a Toolchain: Remove references to -lm 2022-09-16 16:09:19 +00:00
Tim Schumacher
f45238db0f Toolchain: Update to LLVM 15.0.0 2022-09-16 05:39:28 +00:00
Tim Schumacher
39477e923f Toolchain: Remove references to -ldl 2022-09-05 10:12:02 +01:00
Tim Schumacher
a857b6297a Toolchain: Don't pass -lpthread when pthreads are requested
This is essentially a no-op since we have our replacement linker script,
but if we can skip over that entirely, why not?
2022-07-19 11:00:35 +01:00
Andrew Kaster
010190beb8 Toolchain: Remove workarounds for initializer_list and _aligned_alloc
These are no longer required to use libc++ on Serenity
2022-06-30 12:34:16 +01:00
Andrew Kaster
efc1805b8f Toolchain: Create separate serenity xlocale support file 2022-06-30 12:34:16 +01:00
Andrew Kaster
d889294036 Toolchain: Format llvm patches per new patch format
This removes the patch series 1/N comments, git version at the bottom of
the patch, and zeros out the original commit hash.
2022-06-30 12:34:16 +01:00
Tim Schumacher
242bbf1be4 Toolchain: Set '/' as default division character for binutils
While we are at it, regenerate the patch and remove some outdated parts
of the description.
2022-06-30 12:27:17 +01:00
Tim Schumacher
2df56f840f Revert "Toolchain: Load x64 executables at a higher address"
Now that the lower pages can be unmapped and more of the virtual
address range is available to us, we can actually use the default
mapping address of x86_64 again.

This reverts commit 292398b585.
2022-06-21 22:38:15 +01:00
Daniel Bertalan
d0edf2627c Toolchain+Ports: Split the GCC patches
This shouldn't cause any breaking changes, so a toolchain rebuild is not
required.

As per Hendiadyoin's request, math errno is disabled by default, which
should enable some extra compiler optimizations in LibGL and LibSoftGPU
code that uses math functions heavily.

Co-Authored-By: Ali Mohammad Pur <mpfard@serenityos.org>
2022-05-19 20:17:10 +04:30
Daniel Bertalan
6cf260c7af Toolchain: Upgrade to GCC 12.1.0
This release brings support for various C++23 constructs like `if
consteval` and multidimensional subscript operators. Vectorization is
now enabled for O2 too, and `-ftrivial-auto-var-init` has been added
which can help us find and prevent security issues coming from
uninitialized variables.

Toolchain/Patches/gcc.patch is now significanly smaller as some unused,
autoconf-generated code has been removed.
2022-05-12 13:12:37 +02:00
Andrew Kaster
4334bd06b8 Toolchain: Enable LLVM Profile instrumentation
Add a patch to let llvm's InstrProfiling modules know serenity supports
all the Unix-y features required to make -fprofile-instr-generate and
-fcoverage-mapping work properly on target.
2022-05-02 01:46:18 +02:00
Daniel Bertalan
01b31d9858 Toolchain+Ports: Update LLVM to 14.0.1
Besides a version bump, the following changes have been made to our
toolchain infrastructure:
- LLVM/Clang is now built with -march=native if the host compiler
  supports it. An exception to this is CI, as the toolchain cache is
  shared among many different machines there.
- The LLVM tarball is not re-extracted if the hash of the applied
  patches doesn't differ.
- The patches have been split up into atomic chunks.
- Port-specific patches have been integrated into the main patches,
  which will aid in the work towards self-hosting.
- <sysroot>/usr/local/lib is now appended to the linker's search path by
  default.
- --pack-dyn-relocs=relr is appended to the linker command line by
  default, meaning ports take advantage of RELR relocations without any
  patches or additional compiler flags.

The formatting of LLVM port's package.sh has been bothering me, so I
also indented the arguments to the CMake invocation.
2022-04-23 10:43:32 -07:00
James Mintram
11bcde0bbd Toolchain: Add a gcc patch to fix linker error on M1 host 2022-03-31 19:22:53 -07:00
Daniel Bertalan
5550905c00 Toolchain: Update gdb to 11.2 2022-03-24 20:08:08 -07:00
Tim Schumacher
2788d46ae0 Toolchain: Make wint_t unsigned for Clang 2022-03-19 00:11:45 +00:00
Tim Schumacher
5d0869d5ca Toolchain: Enable IFUNC support for GCC 2022-03-19 00:11:45 +00:00
Tim Schumacher
b55a3a504e Toolchain: Enforce correct sizes for size_t and ptrdiff_t 2022-03-19 00:11:45 +00:00
Brian Gianforcaro
d386d3946a Toolchain: Fix QEMU build with latest gcc by disabling -fcf-protection
I noticed after upgrading my machine that the QEMU is no longer building
due to GCC enabling `-fcf-protection` by default, even for targets that
don't support it.

The included patch came from the QEMU development list, but hasn't be
included in any patch releases at the time of writing.
https://lore.kernel.org/all/20220208211937.79580-1-vineetg@rivosinc.com/

Until QEMU patches, lets fix it on our end by patching before we build.
2022-02-13 17:11:53 +00:00
Daniel Bertalan
85780fafcd Toolchain: Update binutils to version 2.38
This version comes with general fixes and, more importantly, introduces
support for the packed RELR relocation format.
2022-02-11 18:07:53 +01:00
Daniel Bertalan
ad649c48da Toolchain: Backport support for the mold linker
The `-fuse-ld=mold` flag was only added in the not-yet-released GCC 12.

Cherry-picked from the following upstream commit:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=ad964f7eaef9c03ce68a01cfdd7fde9d56524868
2022-01-24 10:41:47 +00:00
Daniel Bertalan
9e8c4bb072 Toolchain: Enable the -rdynamic flag in the gcc driver
Although we handle it in the linker spec file, gcc will actually reject
this argument unless it's also enabled in the option file.

CMake adds this flag if the minimum required version is 3.3 or less (see
CMP0065), so old projects would fail to compile because of this
unrecognized option.
2022-01-12 14:54:12 +01:00
Daniel Bertalan
b19cc3cdcb Toolchain: Backport --update-section support to llvm-objcopy
This commit backports the LLVM commit that adds support for the
`--update-section` flag to llvm-objcopy. We use this feature of GNU
objcopy to embed the symbol map in the kernel.

The corresponding LLVM Phabricator Differential Revision can be found
here: https://reviews.llvm.org/D112116

This patch is identical to the upstream commit, except for two hunks
that had to be changed as they didn't apply cleanly.
2022-01-10 09:55:45 +03:30
Daniel Bertalan
20e29c403e Toolchain: Fix macOS build failure due to a malformed patch
Discord user aesophor pointed out that the GCC toolchain fails to build
on macOS, and traced the issue back to 41ea37f2, which is the latest
change to `gcc.patch`. Similarly, when I tried to run BuildIt.sh in the
`--dev` mode, `git apply` complained about the patch being malformed.

I regenerated the patch by manually applying the changes of 41ea37f2 on
top of a known good GCC source tree, and I sent the new file to them.
They reported that this fixed the build issue they were having.
2022-01-09 14:15:24 +01:00
Martin Bříza
41ea37f25a Toolchain/GCC: Declare we don't have memalign
I'm not even sure if this is a hack. However, we don't implement
memalign so it's necessary to tell GCC so it doesn't go looking for it
in their implementation of `new`
2022-01-07 18:38:32 +01:00
Daniel Bertalan
84c6d6649e Toolchain: Fix building the aarch64 toolchain
The `aarch64/t-aarch64` makefile fragment needs to be included for the
aarch64-specific parts of GCC to be built. Before 738e52da5, this was
done implicitly, but now it is not. This caused the following error when
building the toolchain: "aarch64-builtins.o: No such file or directory".
2022-01-04 17:40:09 +00:00
Andrew Kaster
c5898806d2 Toolchain: Use Platform/SerenityOS.cmake in LLVM toolchain build
By setting CMAKE_MODULE_PATH in the LLVM initial cache scripts, we can
make the "SerenityOS" CMAKE_SYSTEM_NAME usable in the builds of
compiler-rt, libunwind, libcxxabi and libcxx.

This simplifies some toolchain patches and brings the cross-compiler
patches closer to the Port's patches, and closer to something
upstreamable.
2022-01-03 11:08:45 +00:00