Browse Source

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*)`.
Daniel Bertalan 4 năm trước cách đây
mục cha
commit
c176680443
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  1. 2 0
      Kernel/CMakeLists.txt

+ 2 - 0
Kernel/CMakeLists.txt

@@ -356,8 +356,10 @@ endif()
 
 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} -faligned-new=8")
 else()
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fPIE")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new=4")
 endif()
 
 # Kernel Undefined Behavior Sanitizer (KUBSAN)