mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibC+DynamicLoader: Prevent GCC from removing null checks
GCC implements `fputc`, `fputs` and `fwrite` as builtin functions, whose `FILE*` argument is implicitly marked `__attribute__((nonnull))`. This causes our `VERIFY(stream)` statements to be removed. This does not happen with Clang, as they do not use the `nonnull` attribute in this way.
This commit is contained in:
parent
b19fe744ab
commit
c2c12e9dc5
Notes:
sideshowbarker
2024-07-18 07:03:37 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/c2c12e9dc5d Pull-request: https://github.com/SerenityOS/serenity/pull/9339 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/dascandy ✅
2 changed files with 5 additions and 0 deletions
|
@ -31,6 +31,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -nodefaultlibs -nostdlib -pie
|
|||
|
||||
set_source_files_properties (../Libraries/LibC/ssp.cpp PROPERTIES COMPILE_FLAGS
|
||||
"-fno-stack-protector")
|
||||
# Prevent GCC from removing null checks by marking the `FILE*` argument non-null
|
||||
set_source_files_properties(../Libraries/LibC/stdio.cpp PROPERTIES COMPILE_FLAGS "-fno-builtin-fputc -fno-builtin-fputs -fno-builtin-fwrite")
|
||||
|
||||
add_executable(Loader.so ${SOURCES})
|
||||
|
||||
|
|
|
@ -115,6 +115,9 @@ if (NOT USE_CLANG_TOOLCHAIN)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
|
||||
endif()
|
||||
|
||||
# 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")
|
||||
|
||||
add_library(LibCStaticWithoutDeps STATIC ${SOURCES})
|
||||
target_link_libraries(LibCStaticWithoutDeps ssp)
|
||||
add_dependencies(LibCStaticWithoutDeps LibM LibSystem LibUBSanitizer)
|
||||
|
|
Loading…
Reference in a new issue