Commit Graph

10 Commits

Author SHA1 Message Date
Dan Klishch
61cf20582c DynamicLoader+LibC: Link LibC into DynamicLoader --as-sane-people
In particular, define a static LibC library *in LibC's CMakeLists* and
use it in DynamicLoader. This is similar to the way LibELF is included
in DynamicLoader.

Additionally, compile DynamicLoader with -ffunction-sections,
-fdata-sections, and -Wl,--gc-sections. This brings the loader size from
~2Mb to ~1Mb with debug symbols and from ~500Kb to ~150Kb without. Also,
this makes linking DynamicLoader with LibTimeZone unnecessary.
2024-05-07 16:39:17 -06:00
Dan Klishch
0b6c08c9a2 LibSystem: Slightly simplify CMakeLists.txt
LibSystem's source directory is included project-wide in
/CMakeLists.txt.
2024-05-07 16:39:17 -06:00
Dan Klishch
4439b4afcf LibC+LibSanitizer+LibSystem: Remove static libc
Static libc on Serenity is broken in a more than one way and requires a
lot of patches to bring it to a usable and useful state. Therefore,
instead of keeping it around (and breaking even more) during the
upcoming libc build refactor, let's just delete it.
2024-05-07 16:39:17 -06:00
implicitfield
5dfe2eb389 Everywhere: Resolve conflicts with LibC and libc++
Since https://reviews.llvm.org/D131441, libc++ must be included before
LibC. As clang includes libc++ as one of the system includes, LibC
must be included after those, and the only correct way to do that is
to install LibC's headers into the sysroot.

Targets that don't link with LibC yet require its headers for one
reason or another must add install_libc_headers as a dependency to
ensure that the correct headers have been (re)installed into the
sysroot.

LibC/stddef.h has been dropped since the built-in stddef.h receives
a higher include priority.

In addition, string.h and wchar.h must
define __CORRECT_ISO_CPP_STRING_H_PROTO and
_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS respectively in order to tell
libc++ to not try to define methods implemented by LibC.
2023-06-27 12:40:38 +02:00
Andrew Kaster
5120b39d0e Meta+Userland: Add ENABLE_USERSPACE_COVERAGE_COLLECTION CMake option
This option sets -fprofile-instr-generate -fcoverage-mapping for Clang
builds only on almost all of Userland. Loader and LibTimeZone are
exempt. This can be used for generating code coverage reports, or even
PGO in the future.
2022-05-02 01:46:18 +02:00
Andreas Kling
21a5fb0fa2 LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore
With this change, System::foo() becomes Core::System::foo().

Since LibCore builds on other systems than SerenityOS, we now have to
make sure that wrappers work with just a standard C library underneath.
2021-11-23 11:33:36 +01:00
Andreas Kling
317ceb0ee2 LibSystem: Disable stack protector in syscall wrappers on i686
This is a hack to avoid a circular dependency issue with the stack check
failure handler being in LibC.

This is not ideal, and there's most likely a better way to solve this.

That said, LibSystem should not have anything but thin wrappers around
system calls, so stack protectors have limited utility here anyway.
2021-11-22 19:28:31 +01:00
Andreas Kling
dc486fa3f9 LibSystem: Add pledge() and unveil() wrappers that return ErrorOr<void>
These will be more ergonomic to use together with TRY(). :^)
2021-11-22 18:34:08 +01:00
Itamar
ae67cabe11 CMake: Make libc.a self-contained
Previously, libc.a contained undefined symbols from ssp and libsystem,
which caused static compilation to fail.

We now generate libc.a with a custom CMake rule that combines all
object files from libc, ssp and libsystem to form libc.a

Closes #5758.
2021-03-19 22:55:53 +01:00
Andreas Kling
e87eac9273 Userland: Add LibSystem and funnel all syscalls through it
This achieves two things:

- Programs can now intentionally perform arbitrary syscalls by calling
  syscall(). This allows us to work on things like syscall fuzzing.

- It restricts the ability of userspace to make syscalls to a single
  4KB page of code. In order to call the kernel directly, an attacker
  must now locate this page and call through it.
2021-02-05 12:23:39 +01:00