Made it possible to build kernel modules for x86_64.
Added the necessary build flags for modules, and added a module (dpc) to the floppy image for x86_64 builds for testing purposes. The module gets loaded correctly and its code runs without issue. Only non-trivial addition is the different method for generating kernel.so, this is explained in the kernel Jamfile.
This commit is contained in:
+12
-8
@@ -356,6 +356,7 @@ if $(HAIKU_GCC_VERSION[1]) >= 4 {
|
||||
|
||||
HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ;
|
||||
HAIKU_KERNEL_PIC_LINKFLAGS = ;
|
||||
HAIKU_KERNEL_ADDON_LINKFLAGS = ;
|
||||
|
||||
switch $(HAIKU_ARCH) {
|
||||
case ppc :
|
||||
@@ -389,13 +390,16 @@ switch $(HAIKU_ARCH) {
|
||||
case x86_64 :
|
||||
{
|
||||
# Kernel lives in the top 2GB of the address space, use kernel code
|
||||
# model. Also disable the red zone, which cannot be used in kernel
|
||||
# code due to interrupts.
|
||||
HAIKU_KERNEL_CCFLAGS += -mcmodel=kernel -mno-red-zone
|
||||
-fno-omit-frame-pointer ;
|
||||
HAIKU_KERNEL_C++FLAGS += -mcmodel=kernel -mno-red-zone
|
||||
-fno-omit-frame-pointer ;
|
||||
# model.
|
||||
HAIKU_KERNEL_PIC_CCFLAGS += -mcmodel=kernel ;
|
||||
|
||||
# Disable the red zone, which cannot be used in kernel code due to
|
||||
# interrupts, and always enable the frame pointer so stack traces are
|
||||
# correct.
|
||||
HAIKU_KERNEL_CCFLAGS += -mno-red-zone -fno-omit-frame-pointer ;
|
||||
HAIKU_KERNEL_C++FLAGS += -mno-red-zone -fno-omit-frame-pointer ;
|
||||
HAIKU_KERNEL_PIC_LINKFLAGS += -z max-page-size=0x1000 ;
|
||||
HAIKU_KERNEL_ADDON_LINKFLAGS += -z max-page-size=0x1000 ;
|
||||
|
||||
# Bootloader is 32-bit.
|
||||
HAIKU_BOOT_LINKFLAGS += -m elf_i386_haiku ;
|
||||
@@ -984,7 +988,7 @@ if $(TARGET_PLATFORM) != haiku {
|
||||
local buildVars =
|
||||
ARCH CPU GCC_VERSION KERNEL_ARCH
|
||||
|
||||
AR CC C++ LD OBJCOPY RANLIB
|
||||
AR CC C++ LD OBJCOPY RANLIB ELFEDIT
|
||||
|
||||
INCLUDES_SEPARATOR LOCAL_INCLUDES_OPTION SYSTEM_INCLUDES_OPTION
|
||||
|
||||
@@ -993,7 +997,7 @@ local buildVars =
|
||||
KERNEL_DEFINES
|
||||
|
||||
KERNEL_CCFLAGS KERNEL_C++FLAGS
|
||||
KERNEL_PIC_CCFLAGS KERNEL_PIC_LINKFLAGS
|
||||
KERNEL_PIC_CCFLAGS KERNEL_PIC_LINKFLAGS KERNEL_ADDON_LINKFLAGS
|
||||
BOOT_CCFLAGS BOOT_C++FLAGS BOOT_LINKFLAGS
|
||||
WARNING_CCFLAGS WARNING_C++FLAGS
|
||||
|
||||
|
||||
@@ -52,7 +52,10 @@ SYSTEM_ADD_ONS_BUS_MANAGERS = $(X86_ONLY)acpi $(ATA_ONLY)ata config_manager dpc
|
||||
SYSTEM_ADD_ONS_FILE_SYSTEMS = bfs iso9660 attribute_overlay write_overlay ;
|
||||
|
||||
|
||||
if $(TARGET_ARCH) != x86_64 {
|
||||
if $(TARGET_ARCH) = x86_64 {
|
||||
AddFilesToFloppyBootArchive system add-ons kernel bus_managers
|
||||
: dpc ;
|
||||
} else {
|
||||
# modules
|
||||
AddFilesToFloppyBootArchive system add-ons kernel bus_managers
|
||||
: $(SYSTEM_ADD_ONS_BUS_MANAGERS) ;
|
||||
@@ -121,7 +124,11 @@ if $(NET_BOOT) = 1 {
|
||||
}
|
||||
|
||||
# boot module links
|
||||
if $(TARGET_ARCH) != x86_64 {
|
||||
if $(TARGET_ARCH) = x86_64 {
|
||||
AddBootModuleSymlinksToFloppyBootArchive
|
||||
dpc
|
||||
;
|
||||
} else {
|
||||
AddBootModuleSymlinksToFloppyBootArchive
|
||||
$(SYSTEM_ADD_ONS_BUS_MANAGERS)
|
||||
$(PPC_ONLY)openpic
|
||||
|
||||
+19
-1
@@ -77,6 +77,24 @@ actions KernelLd bind VERSION_SCRIPT
|
||||
--version-script=$(VERSION_SCRIPT)
|
||||
}
|
||||
|
||||
rule KernelSo target : source
|
||||
{
|
||||
# KernelSo <target> : <source>
|
||||
|
||||
Depends $(target) : <build>copyattr $(source) ;
|
||||
|
||||
MakeLocateDebug $(1) ;
|
||||
KernelSo1 $(target) : <build>copyattr $(source) ;
|
||||
}
|
||||
|
||||
actions KernelSo1
|
||||
{
|
||||
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
||||
|
||||
$(2[1]) --data $(2[2]) $(1) &&
|
||||
$(HAIKU_ELFEDIT) --output-type dyn $(1)
|
||||
}
|
||||
|
||||
rule KernelAddon
|
||||
{
|
||||
# KernelAddon <name> : <sources> : <static-libraries> : <res> ;
|
||||
@@ -117,7 +135,7 @@ rule KernelAddon
|
||||
# compile and link
|
||||
SetupKernel $(sources) : $(TARGET_KERNEL_PIC_FLAGS) : false ;
|
||||
local linkFlags = -nostdlib -Xlinker --no-undefined
|
||||
-Xlinker -soname=\"$(target:G=)\" ;
|
||||
-Xlinker -soname=\"$(target:G=)\" $(TARGET_KERNEL_ADDON_LINKFLAGS) ;
|
||||
LINKFLAGS on $(target) = [ on $(target) return $(LINKFLAGS) ] $(linkFlags) ;
|
||||
Main $(target) : $(sources) ;
|
||||
LinkAgainst $(target) : $(libs) $(kernel) ;
|
||||
|
||||
Reference in New Issue
Block a user