Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
# along with this program; see the file COPYING. If not see
# <http://www.gnu.org/licenses/>.

MAKE ?= make
DESTDIR ?= /opt/ps5-payload-sdk
include common.mk

TOPTARGETS := all clean install
SUBDIRS := crt sce_stubs libc libufs include host
Expand Down
34 changes: 34 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
MAKE ?= make
PYTHON ?= python3

DESTDIR ?= /opt/ps5-payload-sdk

LLVM_CONFIG_CANDIDATES := llvm-config-21 \
llvm-config-20 llvm-config-19 llvm-config-18 \
llvm-config-17 llvm-config-16 llvm-config-15 \
llvm-config
LLVM_CONFIG_CANDIDATES := $(foreach LCC,$(LLVM_CONFIG_CANDIDATES), \
$(if $(shell command -v $(LCC) 2>/dev/null), $(LCC)))

LLVM_CONFIG ?= $(firstword $(LLVM_CONFIG_CANDIDATES))
ifndef LLVM_CONFIG
$(error Unable to find llvm-config)
endif

LLVM_BINDIR := $(shell $(LLVM_CONFIG) --bindir)
CC := $(LLVM_BINDIR)/clang
AR := $(LLVM_BINDIR)/llvm-ar
LD := $(LLVM_BINDIR)/ld.lld

# ld is moved out of llvm on MacOS
ifeq ($(shell command -v $(LD) 2>/dev/null),)
OS := $(shell uname -s)
ifeq ($(OS),Darwin)
BREW := $(shell command -v brew 2>/dev/null)
ifneq ($(BREW),)
LD := $(shell $(BREW) --prefix lld 2>/dev/null)/bin/ld.lld
else
$(error Unable to find Homebrew)
endif
endif
endif
19 changes: 1 addition & 18 deletions crt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,7 @@
# along with this program; see the file COPYING. If not see
# <http://www.gnu.org/licenses/>.

DESTDIR ?= /opt/ps5-payload-sdk

LLVM_CONFIG_CANDIDATES := llvm-config-21 \
llvm-config-20 llvm-config-19 llvm-config-18 \
llvm-config-17 llvm-config-16 llvm-config-15 \
llvm-config
LLVM_CONFIG_CANDIDATES := $(foreach LCC,$(LLVM_CONFIG_CANDIDATES), \
$(if $(shell command -v $(LCC) 2>/dev/null), $(LCC)))

LLVM_CONFIG ?= $(firstword $(LLVM_CONFIG_CANDIDATES))
ifndef LLVM_CONFIG
$(error Unable to find llvm-config)
endif

LLVM_BINDIR := $(shell $(LLVM_CONFIG) --bindir)
CC := $(LLVM_BINDIR)/clang
AR := $(LLVM_BINDIR)/llvm-ar
LD := $(LLVM_BINDIR)/ld.lld
include ../common.mk

CFLAGS += -ffreestanding -fno-builtin -nostdlib -fPIC
CFLAGS += -target x86_64-sie-ps5 -fno-plt -fno-stack-protector
Expand Down
22 changes: 18 additions & 4 deletions host/bin/prospero-lld
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,35 @@ LDSCRIPT="-T${PS5_PAYLOAD_SDK}/ldscripts/elf_x86_64.x"

for ARG in "$@"; do
if [[ "$ARG" == "--shared" ]]; then
PIE=""
PIE=""
fi
if [[ "$ARG" == "-r" ]]; then
PIE=""
PIE=""
fi
if [[ "$ARG" == "--static" ]]; then
PIE=""
PIE=""
fi
if [[ "$ARG" == "--script" || "$ARG" == "-T" ]]; then
LDSCRIPT=""
LDSCRIPT=""
fi
done

LLVM_BINDIR=$("${SCRIPT_DIR}/prospero-llvm-config" --bindir)
BIN_PATH="${LLVM_BINDIR}/ld.lld"

# ld is moved out of llvm on macOS
if ! command -v "${BIN_PATH}" >/dev/null 2>&1; then
if [ "$(uname -s)" = "Darwin" ]; then
BREW="$(command -v brew 2>/dev/null)"
if [ -n "${BREW}" ]; then
BIN_PATH="$("${BREW}" --prefix lld 2>/dev/null)/bin/ld.lld"
else
echo "Unable to find Homebrew" >&2
exit 1
fi
fi
fi

exec "${BIN_PATH}" \
-m elf_x86_64 $PIE $LDSCRIPT --eh-frame-hdr \
-z max-page-size=0x4000 -mllvm -emulated-tls \
Expand Down
18 changes: 1 addition & 17 deletions libc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,7 @@
# along with this program; see the file COPYING. If not see
# <http://www.gnu.org/licenses/>.

DESTDIR ?= /opt/ps5-payload-sdk

LLVM_CONFIG_CANDIDATES := llvm-config-21 \
llvm-config-20 llvm-config-19 llvm-config-18 \
llvm-config-17 llvm-config-16 llvm-config-15 \
llvm-config
LLVM_CONFIG_CANDIDATES := $(foreach LCC,$(LLVM_CONFIG_CANDIDATES), \
$(if $(shell command -v $(LCC) 2>/dev/null), $(LCC)))

LLVM_CONFIG ?= $(firstword $(LLVM_CONFIG_CANDIDATES))
ifndef LLVM_CONFIG
$(error Unable to find llvm-config)
endif

LLVM_BINDIR := $(shell $(LLVM_CONFIG) --bindir)
CC := $(LLVM_BINDIR)/clang
AR := $(LLVM_BINDIR)/llvm-ar
include ../common.mk

CFLAGS := -target x86_64-sie-ps5 -fPIC -fno-plt -fno-stack-protector
CFLAGS += -nobuiltininc -isystem ../include/freebsd
Expand Down
18 changes: 1 addition & 17 deletions libufs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,7 @@
# along with this program; see the file COPYING. If not see
# <http://www.gnu.org/licenses/>.

DESTDIR ?= /opt/ps5-payload-sdk

LLVM_CONFIG_CANDIDATES := llvm-config-21 \
llvm-config-20 llvm-config-19 llvm-config-18 \
llvm-config-17 llvm-config-16 llvm-config-15 \
llvm-config
LLVM_CONFIG_CANDIDATES := $(foreach LCC,$(LLVM_CONFIG_CANDIDATES), \
$(if $(shell command -v $(LCC) 2>/dev/null), $(LCC)))

LLVM_CONFIG ?= $(firstword $(LLVM_CONFIG_CANDIDATES))
ifndef LLVM_CONFIG
$(error Unable to find llvm-config)
endif

LLVM_BINDIR := $(shell $(LLVM_CONFIG) --bindir)
CC := $(LLVM_BINDIR)/clang
AR := $(LLVM_BINDIR)/llvm-ar
include ../common.mk

CFLAGS := -target x86_64-sie-ps5 -fPIC -fno-plt -fno-stack-protector
CFLAGS += -nobuiltininc -isystem ../include/freebsd
Expand Down
19 changes: 1 addition & 18 deletions sce_stubs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,7 @@
# along with this program; see the file COPYING. If not see
# <http://www.gnu.org/licenses/>.

PYTHON ?= python3
DESTDIR ?= /opt/ps5-payload-sdk

LLVM_CONFIG_CANDIDATES := llvm-config-21 \
llvm-config-20 llvm-config-19 llvm-config-18 \
llvm-config-17 llvm-config-16 llvm-config-15 \
llvm-config
LLVM_CONFIG_CANDIDATES := $(foreach LCC,$(LLVM_CONFIG_CANDIDATES), \
$(if $(shell command -v $(LCC) 2>/dev/null), $(LCC)))

LLVM_CONFIG ?= $(firstword $(LLVM_CONFIG_CANDIDATES))
ifndef LLVM_CONFIG
$(error Unable to find llvm-config)
endif

LLVM_BINDIR := $(shell $(LLVM_CONFIG) --bindir)
CC := $(LLVM_BINDIR)/clang
LD := $(LLVM_BINDIR)/ld.lld
include ../common.mk

CFLAGS := -ffreestanding -fno-builtin -nostdlib -fPIC
CFLAGS += -target x86_64-sie-ps5 -fno-plt -fno-stack-protector
Expand Down
Loading