- -Wl,-sectcreate,__PRELINK,__text,/dev/null \
- -Wl,-sectcreate,__PRELINK,__symtab,/dev/null \
- -Wl,-sectcreate,__PRELINK,__info,/dev/null
-
-export LDFLAGS_KERNEL_RELEASE =
-# -noseglinkedit
-export LDFLAGS_KERNEL_DEBUG =
-export LDFLAGS_KERNEL_PROFILE =
-
-export LDFLAGS_KERNEL_PPC = \
- -arch ppc \
- -Wl,-segaddr,__VECTORS,0x0 \
- -Wl,-segaddr,__HIB,0x7000 \
- -Wl,-segaddr,__TEXT,0xe000
-
-export LDFLAGS_KERNEL_I386 = \
- -arch i386 \
- -Wl,-segaddr,__HIB,0x100000 \
- -Wl,-segaddr,__TEXT,0x111000
-
-export LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \
- $($(addsuffix $(ARCH_CONFIG),LDFLAGS_KERNEL_)) \
- $($(addsuffix $(KERNEL_CONFIG),LDFLAGS_KERNEL_))
-
+ -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \
+ -Wl,-sectcreate,__PRELINK_STATE,__kernel,/dev/null \
+ -Wl,-sectcreate,__PRELINK_STATE,__kexts,/dev/null \
+ -Wl,-sectcreate,__PRELINK_INFO,__info,/dev/null \
+ -Wl,-new_linker \
+ -Wl,-pagezero_size,0x0 \
+ -Wl,-version_load_command \
+ -Wl,-function_starts \
+ -Wl,-headerpad,152
+
+LDFLAGS_KERNEL_RELEASE =
+LDFLAGS_KERNEL_DEVELOPMENT =
+LDFLAGS_KERNEL_DEBUG =
+LDFLAGS_KERNEL_PROFILE =
+
+# KASLR static slide config:
+ifndef SLIDE
+SLIDE=0x00
+endif
+KERNEL_MIN_ADDRESS = 0xffffff8000000000
+KERNEL_BASE_OFFSET = 0x100000
+KERNEL_STATIC_SLIDE = $(shell printf "0x%016x" \
+ $$[ $(SLIDE) << 21 ])
+KERNEL_STATIC_BASE = $(shell printf "0x%016x" \
+ $$[ $(KERNEL_MIN_ADDRESS) + $(KERNEL_BASE_OFFSET) ])
+KERNEL_HIB_SECTION_BASE = $(shell printf "0x%016x" \
+ $$[ $(KERNEL_STATIC_BASE) + $(KERNEL_STATIC_SLIDE) ])
+KERNEL_TEXT_BASE = $(shell printf "0x%016x" \
+ $$[ $(KERNEL_HIB_SECTION_BASE) + 0x100000 ])
+
+LDFLAGS_KERNEL_RELEASEX86_64 = \
+ -Wl,-pie \
+ -Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \
+ -Wl,-image_base,$(KERNEL_TEXT_BASE) \
+ -Wl,-seg_page_size,__TEXT,0x200000 \
+ -Wl,-sectalign,__DATA,__const,0x1000 \
+ -Wl,-sectalign,__DATA,__sysctl_set,0x1000 \
+ -Wl,-sectalign,__HIB,__bootPT,0x1000 \
+ -Wl,-sectalign,__HIB,__desc,0x1000 \
+ -Wl,-sectalign,__HIB,__data,0x1000 \
+ -Wl,-sectalign,__HIB,__text,0x1000 \
+ -Wl,-sectalign,__HIB,__const,0x1000 \
+ -Wl,-sectalign,__HIB,__bss,0x1000 \
+ -Wl,-sectalign,__HIB,__common,0x1000 \
+ $(LDFLAGS_NOSTRIP_FLAG)
+
+# Define KERNEL_BASE_OFFSET so known at compile time:
+CFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)
+
+LDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
+LDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
+LDFLAGS_KERNEL_PROFILEX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
+
+
+LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \
+ $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
+ $($(addsuffix $(CURRENT_ARCH_CONFIG),LDFLAGS_KERNEL_)) \
+ $($(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_)) \
+ $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_))) \
+ $(DEPLOYMENT_TARGET_FLAGS)