Index: head/Makefile =================================================================== --- head/Makefile +++ head/Makefile @@ -500,7 +500,7 @@ EXTRA_ARCHES_mips= mipsel mipshf mipselhf mips64el mips64hf mips64elhf EXTRA_ARCHES_mips+= mipsn32 # powerpcspe excluded from main list until clang fixed -EXTRA_ARCHES_powerpc= powerpcspe +EXTRA_ARCHES_powerpc= powerpcspe powerpc64le .endif TARGETS?=amd64 arm arm64 i386 mips powerpc riscv _UNIVERSE_TARGETS= ${TARGETS} Index: head/Makefile.inc1 =================================================================== --- head/Makefile.inc1 +++ head/Makefile.inc1 @@ -152,6 +152,7 @@ mips64hf/mips \ powerpc \ powerpc64/powerpc \ + powerpc64le/powerpc \ powerpcspe/powerpc \ riscv64/riscv \ riscv64sf/riscv Index: head/share/mk/bsd.cpu.mk =================================================================== --- head/share/mk/bsd.cpu.mk +++ head/share/mk/bsd.cpu.mk @@ -128,7 +128,7 @@ . else _CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64 . endif -. elif ${MACHINE_ARCH} == "powerpc64" +. elif ${MACHINE_ARCH:Mpowerpc64*} != "" _CPUCFLAGS = -mcpu=${CPUTYPE} . elif ${MACHINE_CPUARCH} == "mips" # mips[1234], mips32, mips64, and all later releases need to have mips Index: head/share/mk/bsd.endian.mk =================================================================== --- head/share/mk/bsd.endian.mk +++ head/share/mk/bsd.endian.mk @@ -4,6 +4,7 @@ ${MACHINE_ARCH} == "amd64" || \ ${MACHINE_ARCH} == "i386" || \ (${MACHINE} == "arm" && ${MACHINE_ARCH:Marm*eb*} == "") || \ + ${MACHINE_ARCH} == "powerpc64le" || \ ${MACHINE_CPUARCH} == "riscv" || \ ${MACHINE_ARCH:Mmips*el*} != "" TARGET_ENDIANNESS= 1234 Index: head/share/mk/local.meta.sys.mk =================================================================== --- head/share/mk/local.meta.sys.mk +++ head/share/mk/local.meta.sys.mk @@ -17,7 +17,7 @@ TARGET_ARCHES_arm?= arm armv6 armv7 TARGET_ARCHES_arm64?= aarch64 TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32 mipsn32el -TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpcspe +TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpc64le powerpcspe TARGET_ARCHES_riscv?= riscv64 riscv64sf # some corner cases Index: head/share/mk/src.opts.mk =================================================================== --- head/share/mk/src.opts.mk +++ head/share/mk/src.opts.mk @@ -354,14 +354,14 @@ BROKEN_OPTIONS+=HYPERV .endif -# NVME is only aarch64, x86 and powerpc64 +# NVME is only aarch64, x86 and powerpc64* .if ${__T} != "aarch64" && ${__T} != "amd64" && ${__T} != "i386" && \ - ${__T} != "powerpc64" + ${__T:Mpowerpc64*} == "" BROKEN_OPTIONS+=NVME .endif .if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \ - ${__T} == "powerpc64" + ${__T:Mpowerpc64*} != "" __DEFAULT_YES_OPTIONS+=OPENMP .else __DEFAULT_NO_OPTIONS+=OPENMP Index: head/share/mk/sys.mk =================================================================== --- head/share/mk/sys.mk +++ head/share/mk/sys.mk @@ -13,7 +13,7 @@ # and/or endian. This is called MACHINE_CPU in NetBSD, but that's used # for something different in FreeBSD. # -__TO_CPUARCH=C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v[67])?(eb)?/arm/:C/powerpc(64|spe)/powerpc/:C/riscv64(sf)?/riscv/ +__TO_CPUARCH=C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v[67])?(eb)?/arm/:C/powerpc(64|64le|spe)/powerpc/:C/riscv64(sf)?/riscv/ MACHINE_CPUARCH=${MACHINE_ARCH:${__TO_CPUARCH}} .endif Index: head/stand/defs.mk =================================================================== --- head/stand/defs.mk +++ head/stand/defs.mk @@ -105,10 +105,10 @@ # Machine specific flags for all builds here -# All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc -# or powerpc64. -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc +# Ensure PowerPC64 and PowerPC64LE boot loaders are compiled as 32 bit +# and in big endian. +.if ${MACHINE_ARCH:Mpowerpc64*} != "" +CFLAGS+= -m32 -mcpu=powerpc -mbig-endian .endif # For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is Index: head/sys/conf/files.powerpc =================================================================== --- head/sys/conf/files.powerpc +++ head/sys/conf/files.powerpc @@ -93,7 +93,7 @@ dev/ofw/ofw_subr.c standard dev/powermac_nvram/powermac_nvram.c optional powermac_nvram powermac dev/quicc/quicc_bfe_fdt.c optional quicc mpc85xx -dev/random/darn.c optional powerpc64 !random_loadable +dev/random/darn.c optional powerpc64 !random_loadable | powerpc64le !random_loadable dev/scc/scc_bfe_macio.c optional scc powermac dev/sdhci/fsl_sdhci.c optional mpc85xx sdhci dev/sec/sec.c optional sec mpc85xx @@ -136,10 +136,10 @@ powerpc/aim/aim_machdep.c optional aim powerpc/aim/mmu_oea.c optional aim powerpc powerpc/aim/mmu_oea64.c optional aim -powerpc/aim/mmu_radix.c optional aim powerpc64 +powerpc/aim/mmu_radix.c optional aim powerpc64 | aim powerpc64le powerpc/aim/moea64_native.c optional aim powerpc/aim/mp_cpudep.c optional aim -powerpc/aim/slb.c optional aim powerpc64 +powerpc/aim/slb.c optional aim powerpc64 | aim powerpc64le powerpc/amigaone/platform_amigaone.c optional amigaone powerpc/amigaone/cpld_a1222.c optional powerpc amigaone | powerpcspe amigaone powerpc/amigaone/cpld_x5000.c optional powerpc amigaone | powerpc64 amigaone @@ -153,7 +153,7 @@ powerpc/cpufreq/dfs.c optional cpufreq powerpc/cpufreq/mpc85xx_jog.c optional cpufreq mpc85xx powerpc/cpufreq/pcr.c optional cpufreq aim -powerpc/cpufreq/pmcr.c optional cpufreq aim powerpc64 +powerpc/cpufreq/pmcr.c optional cpufreq aim powerpc64 | cpufreq aim powerpc64le powerpc/cpufreq/pmufreq.c optional cpufreq aim pmu powerpc/fpu/fpu_add.c optional fpu_emu | powerpcspe powerpc/fpu/fpu_compare.c optional fpu_emu | powerpcspe @@ -192,10 +192,10 @@ powerpc/ofw/ofw_real.c optional aim powerpc/ofw/ofw_syscons.c optional sc aim powerpc/ofw/ofwcall32.S optional aim powerpc -powerpc/ofw/ofwcall64.S optional aim powerpc64 +powerpc/ofw/ofwcall64.S optional aim powerpc64 | aim powerpc64le powerpc/ofw/openpic_ofw.c standard powerpc/ofw/rtas.c optional aim -powerpc/ofw/ofw_initrd.c optional md_root_mem powerpc64 +powerpc/ofw/ofw_initrd.c optional md_root_mem powerpc64 | md_root_mem powerpc64le powerpc/powermac/ata_kauai.c optional powermac ata | powermac atamacio powerpc/powermac/ata_macio.c optional powermac ata | powermac atamacio powerpc/powermac/ata_dbdma.c optional powermac ata | powermac atamacio @@ -236,21 +236,21 @@ powerpc/powernv/powernv_centaur.c optional powernv powerpc/powernv/powernv_xscom.c optional powernv powerpc/powernv/xive.c optional powernv -powerpc/powerpc/altivec.c optional powerpc | powerpc64 +powerpc/powerpc/altivec.c optional !powerpcspe powerpc/powerpc/autoconf.c standard powerpc/powerpc/bus_machdep.c standard powerpc/powerpc/busdma_machdep.c standard powerpc/powerpc/clock.c standard powerpc/powerpc/copyinout.c optional aim powerpc/powerpc/cpu.c standard -powerpc/powerpc/cpu_subr64.S optional powerpc64 +powerpc/powerpc/cpu_subr64.S optional powerpc64 | powerpc64le powerpc/powerpc/db_disasm.c optional ddb powerpc/powerpc/db_hwwatch.c optional ddb powerpc/powerpc/db_interface.c optional ddb powerpc/powerpc/db_trace.c optional ddb powerpc/powerpc/dump_machdep.c standard powerpc/powerpc/elf32_machdep.c optional powerpc | powerpcspe | compat_freebsd32 -powerpc/powerpc/elf64_machdep.c optional powerpc64 +powerpc/powerpc/elf64_machdep.c optional powerpc64 | powerpc64le powerpc/powerpc/exec_machdep.c standard powerpc/powerpc/fpu.c standard powerpc/powerpc/gdb_machdep.c optional gdb @@ -260,7 +260,7 @@ powerpc/powerpc/iommu_if.m standard powerpc/powerpc/machdep.c standard powerpc/powerpc/mem.c optional mem -powerpc/powerpc/minidump_machdep.c optional powerpc64 +powerpc/powerpc/minidump_machdep.c optional powerpc64 | powerpc64le powerpc/powerpc/mp_machdep.c optional smp powerpc/powerpc/nexus.c standard powerpc/powerpc/openpic.c standard @@ -272,11 +272,11 @@ powerpc/powerpc/sc_machdep.c optional sc powerpc/powerpc/setjmp.S standard powerpc/powerpc/sigcode32.S optional powerpc | powerpcspe | compat_freebsd32 -powerpc/powerpc/sigcode64.S optional powerpc64 +powerpc/powerpc/sigcode64.S optional powerpc64 | powerpc64le powerpc/powerpc/swtch32.S optional powerpc | powerpcspe -powerpc/powerpc/swtch64.S optional powerpc64 +powerpc/powerpc/swtch64.S optional powerpc64 | powerpc64le powerpc/powerpc/stack_machdep.c optional ddb | stack -powerpc/powerpc/support.S optional powerpc64 | booke +powerpc/powerpc/support.S optional powerpc64 | powerpc64le | booke powerpc/powerpc/syncicache.c standard powerpc/powerpc/sys_machdep.c standard powerpc/powerpc/trap.c standard @@ -294,19 +294,19 @@ powerpc/ps3/ps3pic.c optional ps3 powerpc/ps3/ps3_syscons.c optional ps3 vt powerpc/ps3/ps3-hvcall.S optional ps3 -powerpc/pseries/phyp-hvcall.S optional pseries powerpc64 -powerpc/pseries/mmu_phyp.c optional pseries powerpc64 -powerpc/pseries/phyp_console.c optional pseries powerpc64 uart -powerpc/pseries/phyp_dbg.c optional pseries powerpc64 gdb +powerpc/pseries/phyp-hvcall.S optional pseries powerpc64 | pseries powerpc64le +powerpc/pseries/mmu_phyp.c optional pseries powerpc64 | pseries powerpc64le +powerpc/pseries/phyp_console.c optional pseries powerpc64 uart | pseries powerpc64le uart +powerpc/pseries/phyp_dbg.c optional pseries powerpc64 gdb | pseries powerpc64le gdb powerpc/pseries/phyp_llan.c optional llan -powerpc/pseries/phyp_vscsi.c optional pseries powerpc64 scbus +powerpc/pseries/phyp_vscsi.c optional pseries powerpc64 scbus | pseries powerpc64le scbus powerpc/pseries/platform_chrp.c optional pseries -powerpc/pseries/plpar_iommu.c optional pseries powerpc64 -powerpc/pseries/plpar_pcibus.c optional pseries powerpc64 pci +powerpc/pseries/plpar_iommu.c optional pseries powerpc64 | pseries powerpc64le +powerpc/pseries/plpar_pcibus.c optional pseries powerpc64 pci | pseries powerpc64le pci powerpc/pseries/rtas_dev.c optional pseries powerpc/pseries/rtas_pci.c optional pseries pci -powerpc/pseries/vdevice.c optional pseries powerpc64 -powerpc/pseries/xics.c optional pseries powerpc64 +powerpc/pseries/vdevice.c optional pseries powerpc64 | pseries powerpc64le +powerpc/pseries/xics.c optional pseries powerpc64 | pseries powerpc64le powerpc/psim/iobus.c optional psim powerpc/psim/ata_iobus.c optional ata psim powerpc/psim/openpic_iobus.c optional psim Index: head/sys/conf/kern.mk =================================================================== --- head/sys/conf/kern.mk +++ head/sys/conf/kern.mk @@ -185,7 +185,7 @@ # Use dot symbols (or, better, the V2 ELF ABI) on powerpc64 to make # DDB happy. ELFv2, if available, has some other efficiency benefits. # -.if ${MACHINE_ARCH} == "powerpc64" +.if ${MACHINE_ARCH:Mpowerpc64*} != "" CFLAGS+= -mabi=elfv2 .endif @@ -307,6 +307,7 @@ LD_EMULATION_powerpc= elf32ppc_fbsd LD_EMULATION_powerpcspe= elf32ppc_fbsd LD_EMULATION_powerpc64= elf64ppc_fbsd +LD_EMULATION_powerpc64le= elf64lppc_fbsd LD_EMULATION_riscv64= elf64lriscv LD_EMULATION_riscv64sf= elf64lriscv LD_EMULATION=${LD_EMULATION_${MACHINE_ARCH}} Index: head/sys/conf/ldscript.powerpc64le =================================================================== --- head/sys/conf/ldscript.powerpc64le +++ head/sys/conf/ldscript.powerpc64le @@ -0,0 +1,180 @@ +/* $FreeBSD$ */ + +OUTPUT_FORMAT("elf64-powerpcle-freebsd", "elf64-powerpcle-freebsd", + "elf64-powerpcle-freebsd") +OUTPUT_ARCH(powerpc:common64) +ENTRY(__start) +SEARCH_DIR(/usr/lib); +PROVIDE (__stack = 0); +PHDRS +{ + text PT_LOAD ; + dynamic PT_DYNAMIC ; +} +SECTIONS +{ + + /* Low-address wrapper for bootloaders (kexec/kboot) that can't parse ELF */ + . = kernbase - 0x100; + .kboot : { *(.text.kboot) } :text + + /* Read-only sections, merged into text segment: */ + . = kernbase; + PROVIDE (begin = .); + + .text : + { + *(.glink) + *(.text) + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } =0 + _etext = .; + PROVIDE (etext = .); + + /* Do not emit PT_INTERP section, which confuses some loaders (kexec-lite) */ + /DISCARD/ : { *(.interp) } + + /* Also delete notes */ + /DISCARD/ : { *(.note.*) } + + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } + .rela.text : + { *(.rela.text) *(.rela.gnu.linkonce.t*) } + .rela.data : + { *(.rela.data) *(.rela.gnu.linkonce.d*) } + .rela.rodata : + { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } + .rela.got : { *(.rela.got) } + .rela.got1 : { *(.rela.got1) } + .rela.got2 : { *(.rela.got2) } + .rela.ctors : { *(.rela.ctors) } + .rela.dtors : { *(.rela.dtors) } + .rela.init : { *(.rela.init) } + .rela.fini : { *(.rela.fini) } + .rela.bss : { *(.rela.bss) } + .rela.plt : { *(.rela.plt) } + .rela.sdata : { *(.rela.sdata) } + .rela.sbss : { *(.rela.sbss) } + .rela.sdata2 : { *(.rela.sdata2) } + .rela.sbss2 : { *(.rela.sbss2) } + + .init : { *(.init) } =0 + .fini : { *(.fini) } =0 + .rodata : { *(.rodata) *(.gnu.linkonce.r*) } + .rodata1 : { *(.rodata1) } + .sdata2 : { *(.sdata2) } + .sbss2 : { *(.sbss2) } + /* Adjust the address for the data segment to the next page up. */ + . = ALIGN(4096); + .data.read_frequently : + { + *(SORT_BY_ALIGNMENT(.data.read_frequently)) + } + .data.read_mostly : + { + *(.data.read_mostly) + } + . = ALIGN(128); + .data.exclusive_cache_line : + { + *(.data.exclusive_cache_line) + } + . = ALIGN(128); + .data : + { + *(.data) + *(.gnu.linkonce.d*) + } + .data1 : { *(.data1) } + .toc1 : ALIGN(8) { *(.toc1) } + .opd : ALIGN(8) { KEEP (*(.opd)) } + .branch_lt : ALIGN(8) { *(.branch_lt) } + . = ALIGN(4096); + .got : ALIGN(8) { __tocbase = .; *(.got) } + .toc : ALIGN(8) { *(.toc) } + + .dynamic : { *(.dynamic) } :text :dynamic + /* Put .ctors and .dtors next to the .got2 section, so that the pointers + get relocated with -mrelocatable. Also put in the .fixup pointers. + The current compiler no longer needs this, but keep it around for 2.7.2 */ + PROVIDE (_GOT2_START_ = .); + .got2 : { *(.got2) } + PROVIDE (__CTOR_LIST__ = .); + .ctors : { *(.ctors) } + PROVIDE (__CTOR_END__ = .); + PROVIDE (__DTOR_LIST__ = .); + .dtors : { *(.dtors) } + PROVIDE (__DTOR_END__ = .); + PROVIDE (_FIXUP_START_ = .); + .fixup : { *(.fixup) } + PROVIDE (_FIXUP_END_ = .); + PROVIDE (_GOT2_END_ = .); + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata : { *(.sdata) } + _edata = .; + PROVIDE (edata = .); + .sbss : + { + PROVIDE (__sbss_start = .); + *(.sbss) + *(.scommon) + *(.dynsbss) + PROVIDE (__sbss_end = .); + } + .plt : { *(.plt) } + .iplt : { *(.iplt) } + .bss : + { + PROVIDE (__bss_start = .); + *(.dynbss) + *(.bss) + *(COMMON) + } + _end = . ; + PROVIDE (end = .); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* These must appear regardless of . */ +} + Index: head/sys/conf/options.powerpc =================================================================== --- head/sys/conf/options.powerpc +++ head/sys/conf/options.powerpc @@ -8,6 +8,7 @@ POWERPC POWERPC64 +POWERPC64LE POWERPCSPE FPU_EMU Index: head/sys/modules/Makefile =================================================================== --- head/sys/modules/Makefile +++ head/sys/modules/Makefile @@ -779,7 +779,7 @@ _virtio= virtio .endif -.if ${MACHINE_ARCH} == "powerpc64" +.if ${MACHINE_ARCH:Mpowerpc64*} != "" _ipmi= ipmi _ixl= ixl _nvram= opal_nvram Index: head/sys/powerpc/include/param.h =================================================================== --- head/sys/powerpc/include/param.h +++ head/sys/powerpc/include/param.h @@ -57,7 +57,11 @@ #endif #ifndef MACHINE_ARCH #ifdef __powerpc64__ +#if defined(__LITTLE_ENDIAN__) +#define MACHINE_ARCH "powerpc64le" +#else #define MACHINE_ARCH "powerpc64" +#endif #else #ifdef __SPE__ #define MACHINE_ARCH "powerpcspe"