Skip to content

Commit

Permalink
LibC+LibELF: Move ELF definitions from LibC to LibELF
Browse files Browse the repository at this point in the history
This is needed to avoid including LibC headers in Lagom builds.
Unfortunately, we cannot rely on the build machine to provide a
fully POSIX-compatible ELF header for Lagom builds, so we have to
use our own.
  • Loading branch information
implicitfield authored and awesomekling committed Jun 27, 2023
1 parent 7d19abd commit 79adeb6
Show file tree
Hide file tree
Showing 16 changed files with 850 additions and 836 deletions.
2 changes: 1 addition & 1 deletion Kernel/Prekernel/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <Kernel/Memory/PhysicalAddress.h>
#include <Kernel/Memory/VirtualAddress.h>
#include <Kernel/Prekernel/Prekernel.h>
#include <LibC/elf.h>
#include <LibELF/ELFABI.h>
#include <LibELF/Relocation.h>

#if ARCH(X86_64)
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Tasks/Coredump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
#include <Kernel/Tasks/Coredump.h>
#include <Kernel/Tasks/Process.h>
#include <LibC/elf.h>
#include <LibELF/Core.h>
#include <LibELF/ELFABI.h>

#define INCLUDE_USERSPACE_HEAP_MEMORY_IN_COREDUMPS 0

Expand Down
2 changes: 1 addition & 1 deletion Kernel/Tasks/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <Kernel/Tasks/ProcessGroup.h>
#include <Kernel/Tasks/Thread.h>
#include <Kernel/UnixTypes.h>
#include <LibC/elf.h>
#include <LibELF/ELFABI.h>

namespace Kernel {

Expand Down
2 changes: 1 addition & 1 deletion Meta/check-style.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'AK/Checked.h',
'AK/Function.h',
'Userland/Libraries/LibJS/SafeFunction.h',
'Userland/Libraries/LibC/elf.h',
'Userland/Libraries/LibELF/ELFABI.h',
'Userland/Libraries/LibCodeComprehension/Cpp/Tests/',
'Userland/Libraries/LibCpp/Tests/parser/',
'Userland/Libraries/LibCpp/Tests/preprocessor/'
Expand Down
2 changes: 2 additions & 0 deletions Toolchain/BuildClang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ SRC_ROOT=$($REALPATH "$DIR"/..)
FILES=$(find \
"$SRC_ROOT"/Kernel/API \
"$SRC_ROOT"/Userland/Libraries/LibC \
"$SRC_ROOT"/Userland/Libraries/LibELF/ELFABI.h \
"$SRC_ROOT"/Userland/Libraries/LibRegex/RegexDefs.h \
-name '*.h' -print)
for arch in $ARCHS; do
Expand All @@ -260,6 +261,7 @@ for arch in $ARCHS; do
target=$(echo "$header" | "$SED" \
-e "s|$SRC_ROOT/Userland/Libraries/LibC||" \
-e "s|$SRC_ROOT/Kernel/|Kernel/|" \
-e "s|$SRC_ROOT/Userland/Libraries/LibELF/|LibELF/|" \
-e "s|$SRC_ROOT/Userland/Libraries/LibRegex/|LibRegex/|")
buildstep "system_headers" "$INSTALL" -D "$header" "Root/usr/include/$target"
done
Expand Down
2 changes: 2 additions & 0 deletions Toolchain/BuildGNU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,15 @@ pushd "$DIR/Build/$ARCH"
"$SRC_ROOT"/Kernel/API \
"$SRC_ROOT"/Kernel/Arch \
"$SRC_ROOT"/Userland/Libraries/LibC \
"$SRC_ROOT"/Userland/Libraries/LibELF/ELFABI.h \
"$SRC_ROOT"/Userland/Libraries/LibRegex/RegexDefs.h \
-name '*.h' -print)
for header in $FILES; do
target=$(echo "$header" | sed \
-e "s|$SRC_ROOT/AK/|AK/|" \
-e "s|$SRC_ROOT/Userland/Libraries/LibC||" \
-e "s|$SRC_ROOT/Kernel/|Kernel/|" \
-e "s|$SRC_ROOT/Userland/Libraries/LibELF/|LibELF/|" \
-e "s|$SRC_ROOT/Userland/Libraries/LibRegex/|LibRegex/|")
buildstep "system_headers" mkdir -p "$(dirname "Root/usr/include/$target")"
buildstep "system_headers" $INSTALL "$header" "Root/usr/include/$target"
Expand Down
Loading

0 comments on commit 79adeb6

Please sign in to comment.