Kernel: Tell the compiler about operator new's alignment

By default, the compiler will assume that `operator new` returns
pointers that are aligned correctly for every built-in type. This is not
the case in the kernel on x64, since the assumed alignment is 16
(because of long double), but the kmalloc blocks are only
`alignas(void*)`.
This commit is contained in:
Daniel Bertalan 2021-07-15 12:05:08 +02:00 committed by Andreas Kling
parent 860417fb4f
commit c176680443
Notes: sideshowbarker 2024-07-18 08:55:04 +09:00

View file

@ -356,8 +356,10 @@ endif()
if ("${SERENITY_ARCH}" STREQUAL "x86_64") if ("${SERENITY_ARCH}" STREQUAL "x86_64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large -fno-pic -mno-red-zone") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large -fno-pic -mno-red-zone")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new=8")
else() else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fPIE") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fPIE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new=4")
endif() endif()
# Kernel Undefined Behavior Sanitizer (KUBSAN) # Kernel Undefined Behavior Sanitizer (KUBSAN)