Meta+Userland: Make LibELF a proper library on Serenity

Dynamically loaded LibC doesn't need LibELF definitions, so let's not
put them there.
This commit is contained in:
Dan Klishch 2024-04-24 16:23:57 -04:00 committed by Andrew Kaster
parent 19206f75ee
commit 7b88363490
11 changed files with 51 additions and 21 deletions

View file

@ -13,4 +13,4 @@ set(SOURCES
)
serenity_app(CrashReporter ICON app-crash-reporter)
target_link_libraries(CrashReporter PRIVATE LibCore LibCoredump LibDebug LibDesktop LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibMain LibThreading LibURL)
target_link_libraries(CrashReporter PRIVATE LibCore LibCoredump LibDebug LibDesktop LibELF LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibMain LibThreading LibURL)

View file

@ -41,7 +41,7 @@ set(utility_srcs
serenity_bin(BuggieBox)
target_sources(BuggieBox PRIVATE main.cpp)
target_link_libraries(BuggieBox PRIVATE LibMain LibShell LibArchive LibCompress LibCore LibCrypto LibFileSystem LibGfx LibLine LibRegex LibAudio LibURL)
target_link_libraries(BuggieBox PRIVATE LibMain LibShell LibArchive LibCompress LibCore LibCrypto LibELF LibFileSystem LibGfx LibLine LibRegex LibAudio LibURL)
foreach(file IN LISTS utility_srcs)
buggiebox_utility(${file})

View file

@ -55,5 +55,5 @@ set(GENERATED_SOURCES
)
serenity_app(HackStudio ICON app-hack-studio)
target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibFileSystem LibIPC LibJS LibMain LibThreading LibURL)
target_link_libraries(HackStudio PRIVATE LibELF LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibFileSystem LibIPC LibJS LibMain LibThreading LibURL)
add_dependencies(HackStudio CppLanguageServer)

View file

@ -24,4 +24,4 @@ set(SOURCES
)
serenity_app(Profiler ICON app-profiler)
target_link_libraries(Profiler PRIVATE LibCore LibDebug LibFileSystem LibGfx LibGUI LibDesktop LibX86 LibSymbolication LibMain LibURL)
target_link_libraries(Profiler PRIVATE LibCore LibDebug LibELF LibFileSystem LibGfx LibGUI LibDesktop LibX86 LibSymbolication LibMain LibURL)

View file

@ -97,24 +97,19 @@ foreach(RELATIVE_HEADER_PATH IN LISTS LIBC_HEADERS)
)
endforeach()
file(GLOB ELF_SOURCES CONFIGURE_DEPENDS "../LibELF/*.cpp" "../LibELF/Arch/${SERENITY_ARCH}/*.cpp")
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
set(LIBC_SOURCES ${LIBC_SOURCES} "arch/aarch64/fenv.cpp")
set(ASM_SOURCES "arch/aarch64/setjmp.S")
set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/aarch64/entry.S ../LibELF/Arch/aarch64/plt_trampoline.S ../LibELF/Arch/aarch64/tls.S)
set(CRTI_SOURCE "arch/aarch64/crti.S")
set(CRTN_SOURCE "arch/aarch64/crtn.S")
elseif ("${SERENITY_ARCH}" STREQUAL "x86_64")
set(LIBC_SOURCES ${LIBC_SOURCES} "arch/x86_64/memset.cpp" "arch/x86_64/fenv.cpp")
set(ASM_SOURCES "arch/x86_64/setjmp.S" "arch/x86_64/memset.S")
set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/x86_64/entry.S ../LibELF/Arch/x86_64/plt_trampoline.S)
set(CRTI_SOURCE "arch/x86_64/crti.S")
set(CRTN_SOURCE "arch/x86_64/crtn.S")
elseif ("${SERENITY_ARCH}" STREQUAL "riscv64")
set(LIBC_SOURCES ${LIBC_SOURCES} "arch/riscv64/fenv.cpp")
set(ASM_SOURCES "arch/riscv64/setjmp.S")
set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/riscv64/entry.S ../LibELF/Arch/riscv64/plt_trampoline.S)
set(CRTI_SOURCE "arch/riscv64/crti.S")
set(CRTN_SOURCE "arch/riscv64/crtn.S")
endif()
@ -160,7 +155,7 @@ add_dependencies(ssp_nonshared install_libc_headers)
target_link_libraries(ssp_nonshared PRIVATE NoCoverage)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libssp_nonshared.a DESTINATION ${CMAKE_INSTALL_PREFIX}/usr/lib/)
set(SOURCES ${LIBC_SOURCES} ${AK_SOURCES} ${ELF_SOURCES} ${ASM_SOURCES})
set(SOURCES ${LIBC_SOURCES} ${AK_SOURCES} ${ASM_SOURCES})
# Prevent GCC from removing null checks by marking the `FILE*` argument non-null
set_source_files_properties(stdio.cpp PROPERTIES COMPILE_FLAGS "-fno-builtin-fputc -fno-builtin-fputs -fno-builtin-fwrite")

View file

@ -5,4 +5,4 @@ set(SOURCES
)
serenity_lib(LibCoredump coredump)
target_link_libraries(LibCoredump PRIVATE LibCompress LibCore LibDebug LibFileSystem)
target_link_libraries(LibCoredump PRIVATE LibCompress LibCore LibDebug LibELF LibFileSystem)

View file

@ -13,4 +13,4 @@ set(SOURCES
)
serenity_lib(LibDebug debug)
target_link_libraries(LibDebug PRIVATE LibCore LibFileSystem LibRegex)
target_link_libraries(LibDebug PRIVATE LibCore LibELF LibFileSystem LibRegex)

View file

@ -1,6 +1,38 @@
# LibELF is included within LibC on Serenity and defined as a target in a different place for Lagom,
# so add a dummy interface library for platform-agnosticism.
add_library(LibELF INTERFACE)
# This is here just to not make any changes to Lagom CMakeLists in this commit.
if (NOT SERENITYOS)
add_library(LibELF INTERFACE)
serenity_install_headers("LibELF")
serenity_install_sources("Userland/Libraries/LibELF")
return()
endif()
set(SOURCES
Image.cpp
Validation.cpp
)
serenity_install_headers("LibELF")
serenity_install_sources("Userland/Libraries/LibELF")
if (SERENITYOS)
list(APPEND SOURCES
Arch/${SERENITY_ARCH}/entry.S
Arch/${SERENITY_ARCH}/plt_trampoline.S
Arch/${SERENITY_ARCH}/tls.cpp
DynamicLinker.cpp
DynamicLoader.cpp
DynamicObject.cpp
ELFBuild.cpp
Relocation.cpp
)
if (SERENITY_ARCH STREQUAL "aarch64")
list(APPEND SOURCES
Arch/aarch64/tls.S
)
endif()
endif()
serenity_lib(LibELF elf ${SOURCES})
target_link_libraries(LibELF PRIVATE LibSystem)

View file

@ -156,5 +156,5 @@ set(GENERATED_SOURCES
)
serenity_lib(LibGUI gui)
target_link_libraries(LibGUI PRIVATE LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibThreading LibRegex LibConfig LibUnicode LibURL)
target_link_libraries(LibGUI PRIVATE LibCore LibELF LibFileSystem LibGfx LibImageDecoderClient LibIPC LibThreading LibRegex LibConfig LibUnicode LibURL)
target_link_libraries(LibGUI PUBLIC LibSyntax)

View file

@ -3,4 +3,4 @@ set(SOURCES
)
serenity_lib(LibSymbolication symbolication)
target_link_libraries(LibSymbolication PRIVATE LibCore LibDebug LibFileSystem)
target_link_libraries(LibSymbolication PRIVATE LibCore LibDebug LibELF LibFileSystem)

View file

@ -88,13 +88,13 @@ target_link_libraries(cpp-lexer PRIVATE LibCpp)
target_link_libraries(cpp-parser PRIVATE LibCpp)
target_link_libraries(cpp-preprocessor PRIVATE LibCpp)
target_link_libraries(diff PRIVATE LibDiff)
target_link_libraries(disasm PRIVATE LibX86)
target_link_libraries(disasm PRIVATE LibELF LibX86)
target_link_libraries(drain PRIVATE LibFileSystem)
target_link_libraries(expr PRIVATE LibRegex)
target_link_libraries(fdtdump PRIVATE LibDeviceTree)
target_link_libraries(file PRIVATE LibGfx LibIPC LibArchive LibCompress LibAudio)
target_link_libraries(file PRIVATE LibELF LibGfx LibIPC LibArchive LibCompress LibAudio)
target_link_libraries(find PRIVATE LibFileSystem LibRegex LibURL)
target_link_libraries(functrace PRIVATE LibDebug LibX86)
target_link_libraries(functrace PRIVATE LibDebug LibELF LibX86)
target_link_libraries(glsl-compiler PRIVATE LibGLSL)
target_link_libraries(gml-format PRIVATE LibGUI)
target_link_libraries(grep PRIVATE LibFileSystem LibRegex LibURL)
@ -109,6 +109,7 @@ target_link_libraries(install-bin PRIVATE LibFileSystem)
target_link_libraries(isobmff PRIVATE LibGfx)
target_link_libraries(js PRIVATE LibCrypto LibJS LibLine LibLocale LibTextCodec)
target_link_libraries(keymap PRIVATE LibKeyboard)
target_link_libraries(ldd PRIVATE LibELF)
target_link_libraries(less PRIVATE LibLine)
target_link_libraries(ls PRIVATE LibFileSystem LibURL)
target_link_libraries(lspci PRIVATE LibPCIDB)
@ -130,11 +131,13 @@ target_link_libraries(pdf PRIVATE LibGfx LibPDF)
target_link_libraries(pgrep PRIVATE LibRegex)
target_link_libraries(pixelflut PRIVATE LibImageDecoderClient LibIPC LibGfx)
target_link_libraries(pkill PRIVATE LibRegex)
target_link_libraries(pledge PRIVATE LibELF)
target_link_libraries(pls PRIVATE LibCrypt)
target_link_libraries(pro PRIVATE LibFileSystem LibProtocol LibHTTP LibURL)
target_link_libraries(readelf PRIVATE LibELF)
target_link_libraries(readlink PRIVATE LibFileSystem)
target_link_libraries(realpath PRIVATE LibFileSystem)
target_link_libraries(run-tests PRIVATE LibCoredump LibDebug LibFileSystem LibRegex)
target_link_libraries(run-tests PRIVATE LibCoredump LibDebug LibELF LibFileSystem LibRegex)
target_link_libraries(rm PRIVATE LibFileSystem)
target_link_libraries(sed PRIVATE LibRegex LibFileSystem)
target_link_libraries(shot PRIVATE LibFileSystem LibGfx LibGUI LibIPC LibURL)