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
1 change: 1 addition & 0 deletions archives/archives.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
6c7af8ed1c8cf9b4b9d6e6fe09a3e1d3d479fe63984ba8b9b26bf356b6313ca9 19973532 https://sourceware.org/pub/binutils/releases/binutils-2.22.tar.bz2 -> binutils-2.22.tar.bz2
aa54850ebda5064c72cd4ec2d9b056c294252991486350d9a97ab2a6dfdfaf12 38254526 https://sourceware.org/pub/binutils/releases/binutils-2.42.tar.bz2 -> binutils-2.42.tar.bz2
27769f64ef1d4cd5e2be8682c0c93f9887983e6cfd1a927ce5a0a2915a95cf8f 72462752 https://sourceware.org/pub/gcc/releases/gcc-9.5.0/gcc-9.5.0.tar.xz -> gcc-9.5.0.tar.xz
e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da 87858592 https://sourceware.org/pub/gcc/releases/gcc-13.2.0/gcc-13.2.0.tar.xz -> gcc-13.2.0.tar.xz
c644b2847244278c57bec2ddda69d8fab5a7c767f3b9af69aa7aa3da823ff692 14571004 https://sourceware.org/pub/newlib/newlib-1.20.0.tar.gz -> newlib-1.20.0.tar.gz
Expand Down
90 changes: 90 additions & 0 deletions patches/binutils-2.42-PS3-PPU.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Original from https://github.com/ps3dev/ps3toolchain
# Updated for binutils 2.40 by Darjan Krijan [https://disc-kuraudo.eu]
diff '--color=auto' -urN a/ld/emulparams/elf32_spu.sh b/ld/emulparams/elf32_spu.sh
--- a/ld/emulparams/elf32_spu.sh 2022-07-08 11:46:48.000000000 +0200
+++ b/ld/emulparams/elf32_spu.sh 2023-01-04 22:15:19.310575828 +0100
@@ -6,6 +6,8 @@
ARCH=spu
MACHINE=
ALIGNMENT=16
+GENERATE_PIE_SCRIPT=yes
+GENERATE_COMBRELOC_SCRIPT=yes
TEXT_START_ADDR=0
INITIAL_READONLY_SECTIONS='.interrupt : { KEEP(*(.interrupt)) }'
if test -z "${CREATE_SHLIB}"; then
diff '--color=auto' -urN a/ld/emultempl/spuelf.em b/ld/emultempl/spuelf.em
--- a/ld/emultempl/spuelf.em 2022-07-08 11:46:48.000000000 +0200
+++ b/ld/emultempl/spuelf.em 2023-01-04 22:17:32.998687355 +0100
@@ -258,6 +258,14 @@
return total;
}

+static void
+spu_before_parse (void)
+{
+ gld${EMULATION_NAME}_before_parse ();
+
+ config.has_pie = `if test -n "$GENERATE_PIE_SCRIPT" ; then echo true ; else echo false ; fi`;
+}
+
/* Go find if we need to do anything special for overlays. */

static void
@@ -851,5 +859,6 @@

LDEMUL_AFTER_OPEN=spu_after_open
LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
+LDEMUL_BEFORE_PARSE=spu_before_parse
LDEMUL_FINISH=gld${EMULATION_NAME}_finish
LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
diff '--color=auto' -urN a/ld/ld.h b/ld/ld.h
--- a/ld/ld.h 2022-07-08 11:46:48.000000000 +0200
+++ b/ld/ld.h 2023-01-04 22:24:33.832738444 +0100
@@ -229,6 +229,9 @@
parameter. */
bool has_shared;

+ /* If TRUE, -pie is supported. */
+ bool has_pie;
+
/* If TRUE, build constructors. */
bool build_constructors;

diff '--color=auto' -urN a/ld/ldmain.c b/ld/ldmain.c
--- a/ld/ldmain.c 2022-07-08 11:46:48.000000000 +0200
+++ b/ld/ldmain.c 2023-01-04 22:16:46.319346843 +0100
@@ -315,6 +315,7 @@
config.make_executable = true;
config.magic_demand_paged = true;
config.text_read_only = true;
+ config.has_pie = false;
config.print_map_discarded = true;
link_info.disable_target_specific_optimizations = -1;

diff '--color=auto' -urN a/ld/lexsup.c b/ld/lexsup.c
--- a/ld/lexsup.c 2022-07-08 11:46:48.000000000 +0200
+++ b/ld/lexsup.c 2023-01-04 22:17:19.218882047 +0100
@@ -1286,6 +1286,8 @@
if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
}
+ else if (config.has_pie)
+ link_info.type = type_pie;
else
einfo (_("%F%P: -shared not supported\n"));
break;

# Apple Clang 17+ (Xcode 16.3 / macOS 26) defines TARGET_OS_MAC as a builtin.
# zlib then #define fdopen(...) NULL, which breaks the SDK fdopen prototype.
diff --git a/zlib/zutil.h b/zlib/zutil.h
--- a/zlib/zutil.h
+++ b/zlib/zutil.h
@@ -137,7 +137,7 @@
# endif
#endif

-#if defined(MACOS) || defined(TARGET_OS_MAC)
+#if defined(MACOS) || (defined(TARGET_OS_MAC) && !defined(__APPLE__))
# define OS_CODE 7
# ifndef Z_SOLO
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
32 changes: 20 additions & 12 deletions scripts/001-binutils-PPU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -eo pipefail
# binutils-PPU.sh by Naomi Peori (naomi@peori.ca)

BINUTILS="binutils-2.22"
BINUTILS="binutils-2.42"
source ../utils/utils.sh

if [ ! -d ${BINUTILS} ]; then
Expand All @@ -18,7 +18,7 @@ if [ ! -d ${BINUTILS} ]; then
extract "../archives/${BINUTILS}.tar.bz2"

## Patch the source code.
cat ../patches/${BINUTILS}-PS3.patch | patch -p1 -d ${BINUTILS}
cat ../patches/${BINUTILS}-PS3-PPU.patch | patch -p1 -d ${BINUTILS}

## Replace config.guess and config.sub
cp ../archives/config.guess ../archives/config.sub ${BINUTILS}
Expand All @@ -37,18 +37,26 @@ cd ${BINUTILS}/build-ppu

## Configure the build.
../configure --prefix="$PS3DEV/ppu" --target="powerpc64-ps3-elf" \
--disable-nls \
--disable-shared \
--disable-debug \
--disable-dependency-tracking \
--disable-werror \
--enable-64-bit-bfd \
--with-gcc \
--with-gnu-as \
--with-gnu-ld
--with-gcc \
--with-gnu-as \
--with-gnu-ld \
--enable-64-bit-bfd \
--enable-lto \
--disable-nls \
--disable-shared \
--disable-debug \
--disable-dependency-tracking \
--disable-werror \
--disable-gprofng \
--disable-install-libiberty \
--with-system-zlib

## Compile and install.
## Do not override libdir: binutils 2.42 installs libdep.la into
## $libdir/bfd-plugins and libtool requires that path to be absolute.
PROCS="$(nproc --all 2>&1)" || ret=$?
if [ ! -z $ret ]; then PROCS=4; fi
${MAKE:-make} -j $PROCS
${MAKE:-make} libdir=host-libs/lib MULTIOSDIR=. install
${MAKE:-make} install
# Host libiberty can still land under prefix on some configure defaults.
rm -f "$PS3DEV/ppu/lib/libiberty.a" "$PS3DEV/ppu/lib64/libiberty.a"
Loading