linux-postmarketos-stable: Temporarily patch for LLVM-only build on ppc64le
See previous commit for details [ci:skip-vercheck]: let's not rebuild all the architectures when we're only touching ppc64le that isn't building in BPO Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/8072>
This commit is contained in:
parent
ab005ffc19
commit
c99c4271d7
4 changed files with 320 additions and 1 deletions
|
|
@ -0,0 +1,229 @@
|
|||
From 1036fc931dcd28ea093949a07873545665b0c520 Mon Sep 17 00:00:00 2001
|
||||
From: Nathan Chancellor <nathan@kernel.org>
|
||||
Date: Fri, 21 Jan 2022 11:53:52 -0700
|
||||
Subject: [PATCH 1/3] WIP: arch/powerpc/boot: Support LLVM=1 in wrapper script
|
||||
|
||||
When LLVM=1 is set, pass through the make variables, as they will
|
||||
generally be multi-targeted.
|
||||
|
||||
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
|
||||
---
|
||||
arch/powerpc/boot/Makefile | 11 +++++-
|
||||
arch/powerpc/boot/wrapper | 72 +++++++++++++++++++++++++++++---------
|
||||
2 files changed, 66 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
|
||||
index f1a4761ebd44..655750126ce9 100644
|
||||
--- a/arch/powerpc/boot/Makefile
|
||||
+++ b/arch/powerpc/boot/Makefile
|
||||
@@ -264,6 +264,15 @@ CROSSWRAP := -C "$(CROSS_COMPILE)"
|
||||
endif
|
||||
endif
|
||||
|
||||
+ifneq ($(LLVM),)
|
||||
+WRAPTOOLS := --ld $(LD)
|
||||
+WRAPTOOLS += --nm $(NM)
|
||||
+WRAPTOOLS += --objcopy $(OBJCOPY)
|
||||
+WRAPTOOLS += --objdump $(OBJDUMP)
|
||||
+# No $(STRINGS)
|
||||
+WRAPTOOLS += --strings llvm-strings
|
||||
+endif
|
||||
+
|
||||
compressor-$(CONFIG_KERNEL_GZIP) := gz
|
||||
compressor-$(CONFIG_KERNEL_XZ) := xz
|
||||
compressor-$(CONFIG_KERNEL_LZMA) := lzma
|
||||
@@ -272,7 +281,7 @@ compressor-$(CONFIG_KERNEL_LZO) := lzo
|
||||
# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
|
||||
quiet_cmd_wrap = WRAP $@
|
||||
cmd_wrap =$(CONFIG_SHELL) $(wrapper) -Z $(compressor-y) -c -o $@ -p $2 \
|
||||
- $(CROSSWRAP) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \
|
||||
+ $(CROSSWRAP) $(WRAPTOOLS) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \
|
||||
vmlinux
|
||||
|
||||
image-$(CONFIG_PPC_PSERIES) += zImage.pseries
|
||||
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
|
||||
index 1efd1206fcab..8dabcf5406b2 100755
|
||||
--- a/arch/powerpc/boot/wrapper
|
||||
+++ b/arch/powerpc/boot/wrapper
|
||||
@@ -167,6 +167,31 @@ while [ "$#" -gt 0 ]; do
|
||||
compression=
|
||||
uboot_comp=none
|
||||
;;
|
||||
+ --ld)
|
||||
+ shift
|
||||
+ [ "$#" -gt 0 ] || usage
|
||||
+ ld="$1"
|
||||
+ ;;
|
||||
+ --nm)
|
||||
+ shift
|
||||
+ [ "$#" -gt 0 ] || usage
|
||||
+ nm="$1"
|
||||
+ ;;
|
||||
+ --objcopy)
|
||||
+ shift
|
||||
+ [ "$#" -gt 0 ] || usage
|
||||
+ objcopy="$1"
|
||||
+ ;;
|
||||
+ --objdump)
|
||||
+ shift
|
||||
+ [ "$#" -gt 0 ] || usage
|
||||
+ objdump="$1"
|
||||
+ ;;
|
||||
+ --strings)
|
||||
+ shift
|
||||
+ [ "$#" -gt 0 ] || usage
|
||||
+ strings="$1"
|
||||
+ ;;
|
||||
-?)
|
||||
usage
|
||||
;;
|
||||
@@ -178,6 +203,21 @@ while [ "$#" -gt 0 ]; do
|
||||
shift
|
||||
done
|
||||
|
||||
+if [ -z "$ld" ]; then
|
||||
+ ld=${CROSS}ld
|
||||
+fi
|
||||
+if [ -z "$nm" ]; then
|
||||
+ nm=${CROSS}nm
|
||||
+fi
|
||||
+if [ -z "$objcopy" ]; then
|
||||
+ objcopy=${CROSS}objcopy
|
||||
+fi
|
||||
+if [ -z "$objdump" ]; then
|
||||
+ objdump=${CROSS}objdump
|
||||
+fi
|
||||
+if [ -z "$strings" ]; then
|
||||
+ strings=${CROSS}strings
|
||||
+fi
|
||||
|
||||
if [ -n "$dts" ]; then
|
||||
if [ ! -r "$dts" -a -r "$object/dts/$dts" ]; then
|
||||
@@ -193,7 +233,7 @@ if [ -z "$kernel" ]; then
|
||||
kernel=vmlinux
|
||||
fi
|
||||
|
||||
-LC_ALL=C elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`"
|
||||
+LC_ALL=C elfformat="`$objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`"
|
||||
case "$elfformat" in
|
||||
elf64-powerpcle) format=elf64lppc ;;
|
||||
elf64-powerpc) format=elf32ppc ;;
|
||||
@@ -230,7 +270,7 @@ nodl="--no-dynamic-linker"
|
||||
|
||||
# suppress some warnings in recent ld versions
|
||||
nowarn="-z noexecstack"
|
||||
-if "${CROSS}ld" -v --no-warn-rwx-segments >/dev/null 2>&1; then
|
||||
+if $ld -v --no-warn-rwx-segments >/dev/null 2>&1; then
|
||||
nowarn="$nowarn --no-warn-rwx-segments"
|
||||
fi
|
||||
|
||||
@@ -369,7 +409,7 @@ epapr)
|
||||
link_address='0x20000000'
|
||||
pie=-pie
|
||||
notext='-z notext'
|
||||
- rodynamic=$(if ${CROSS}ld -V 2>&1 | grep -q LLD ; then echo "-z rodynamic"; fi)
|
||||
+ rodynamic=$(if $ld -V 2>&1 | grep -q LLD ; then echo "-z rodynamic"; fi)
|
||||
;;
|
||||
mvme5100)
|
||||
platformo="$object/fixed-head.o $object/mvme5100.o"
|
||||
@@ -385,7 +425,7 @@ esac
|
||||
vmz="$tmpdir/`basename \"$kernel\"`.$ext"
|
||||
|
||||
# Calculate the vmlinux.strip size
|
||||
-${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
|
||||
+$objcopy $objflags "$kernel" "$vmz.$$"
|
||||
strip_size=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$vmz.$$")
|
||||
|
||||
if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then
|
||||
@@ -438,14 +478,14 @@ fi
|
||||
|
||||
# Extract kernel version information, some platforms want to include
|
||||
# it in the image header
|
||||
-version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \
|
||||
+version=`$strings "$kernel" | grep '^Linux version [-0-9.]' | \
|
||||
head -n1 | cut -d' ' -f3`
|
||||
if [ -n "$version" ]; then
|
||||
uboot_version="-n Linux-$version"
|
||||
fi
|
||||
|
||||
# physical offset of kernel image
|
||||
-membase=`${CROSS}objdump -p "$kernel" | grep -m 1 LOAD | awk '{print $7}'`
|
||||
+membase=`$objdump -p "$kernel" | grep -m 1 LOAD | awk '{print $7}'`
|
||||
|
||||
case "$platform" in
|
||||
uboot)
|
||||
@@ -460,7 +500,7 @@ uboot)
|
||||
esac
|
||||
|
||||
addsec() {
|
||||
- ${CROSS}objcopy $4 $1 \
|
||||
+ $objcopy $4 $1 \
|
||||
--add-section=$3="$2" \
|
||||
--set-section-flags=$3=contents,alloc,load,readonly,data
|
||||
}
|
||||
@@ -490,18 +530,18 @@ if [ "$platform" != "miboot" ]; then
|
||||
text_start="-Ttext $link_address"
|
||||
fi
|
||||
#link everything
|
||||
- ${CROSS}ld -m $format -T $lds $text_start $pie $nodl $nowarn $rodynamic $notext -o "$ofile" $map \
|
||||
+ $ld -m $format -T $lds $text_start $pie $nodl $nowarn $rodynamic $notext -o "$ofile" $map \
|
||||
$platformo $tmp $object/wrapper.a
|
||||
rm $tmp
|
||||
fi
|
||||
|
||||
# Some platforms need the zImage's entry point and base address
|
||||
-base=0x`${CROSS}nm "$ofile" | grep ' _start$' | cut -d' ' -f1`
|
||||
-entry=`${CROSS}objdump -f "$ofile" | grep '^start address ' | cut -d' ' -f3`
|
||||
+base=0x`$nm "$ofile" | grep ' _start$' | cut -d' ' -f1`
|
||||
+entry=`$objdump -f "$ofile" | grep '^start address ' | cut -d' ' -f3`
|
||||
|
||||
if [ -n "$binary" ]; then
|
||||
mv "$ofile" "$ofile".elf
|
||||
- ${CROSS}objcopy -O binary "$ofile".elf "$ofile"
|
||||
+ $objcopy -O binary "$ofile".elf "$ofile"
|
||||
fi
|
||||
|
||||
# post-processing needed for some platforms
|
||||
@@ -510,7 +550,7 @@ pseries|chrp)
|
||||
$objbin/addnote "$ofile"
|
||||
;;
|
||||
coff)
|
||||
- ${CROSS}objcopy -O aixcoff-rs6000 --set-start "$entry" "$ofile"
|
||||
+ $objcopy -O aixcoff-rs6000 --set-start "$entry" "$ofile"
|
||||
$objbin/hack-coff "$ofile"
|
||||
;;
|
||||
cuboot*)
|
||||
@@ -538,18 +578,18 @@ ps3)
|
||||
# copied to offset 0x100. At runtime the bootwrapper program copies
|
||||
# the data at __system_reset_kernel back to addr 0x100.
|
||||
|
||||
- system_reset_overlay=0x`${CROSS}nm "$ofile" \
|
||||
+ system_reset_overlay=0x`$nm "$ofile" \
|
||||
| grep ' __system_reset_overlay$' \
|
||||
| cut -d' ' -f1`
|
||||
system_reset_overlay=`printf "%d" $system_reset_overlay`
|
||||
- system_reset_kernel=0x`${CROSS}nm "$ofile" \
|
||||
+ system_reset_kernel=0x`$nm "$ofile" \
|
||||
| grep ' __system_reset_kernel$' \
|
||||
| cut -d' ' -f1`
|
||||
system_reset_kernel=`printf "%d" $system_reset_kernel`
|
||||
overlay_dest="256"
|
||||
overlay_size="512"
|
||||
|
||||
- ${CROSS}objcopy -O binary "$ofile" "$ofile.bin"
|
||||
+ $objcopy -O binary "$ofile" "$ofile.bin"
|
||||
|
||||
run_cmd dd if="$ofile.bin" of="$ofile.bin" conv=notrunc \
|
||||
skip=$overlay_dest seek=$system_reset_kernel \
|
||||
@@ -567,7 +607,7 @@ ps3)
|
||||
# reached, then enter the system reset vector of the partially decompressed
|
||||
# image. No warning is issued.
|
||||
rm -f "$odir"/{otheros,otheros-too-big}.bld
|
||||
- size=$(${CROSS}nm --no-sort --radix=d "$ofile" | grep -E ' _end$' | cut -d' ' -f1)
|
||||
+ size=$($nm --no-sort --radix=d "$ofile" | grep -E ' _end$' | cut -d' ' -f1)
|
||||
bld="otheros.bld"
|
||||
if [ $size -gt $((0x1000000)) ]; then
|
||||
bld="otheros-too-big.bld"
|
||||
--
|
||||
2.53.0
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From b5cf37159427f2589632e30789488e993a725e0c Mon Sep 17 00:00:00 2001
|
||||
From: Nathan Chancellor <nathan@kernel.org>
|
||||
Date: Fri, 21 Jan 2022 12:39:58 -0700
|
||||
Subject: [PATCH 2/3] WIP: arch/powerpc/boot: Use '-z notext' for pseries image
|
||||
|
||||
Same reason as commit 4c078c86b4a4 ("powerpc/boot/wrapper: Add "-z
|
||||
notext" flag to disable diagnostic").
|
||||
|
||||
ld.lld: error: relocation R_PPC64_ADDR64 cannot be used against symbol '_start'; recompile with -fPIC
|
||||
>>> referenced by crt0.o:(.text+0x8) in archive arch/powerpc/boot/wrapper.a
|
||||
|
||||
ld.lld: error: relocation R_PPC64_ADDR64 cannot be used against symbol '_etext'; recompile with -fPIC
|
||||
>>> referenced by crt0.o:(.text+0x10) in archive arch/powerpc/boot/wrapper.a
|
||||
|
||||
ld.lld: error: relocation R_PPC64_ADDR64 cannot be used against symbol '__bss_start'; recompile with -fPIC
|
||||
>>> referenced by crt0.o:(.text+0x18) in archive arch/powerpc/boot/wrapper.a
|
||||
|
||||
ld.lld: error: relocation R_PPC64_ADDR64 cannot be used against symbol '_end'; recompile with -fPIC
|
||||
>>> referenced by crt0.o:(.text+0x20) in archive arch/powerpc/boot/wrapper.a
|
||||
make[2]: *** [arch/powerpc/boot/Makefile:400: arch/powerpc/boot/zImage.pseries] Error 1
|
||||
|
||||
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
|
||||
---
|
||||
arch/powerpc/boot/wrapper | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
|
||||
index 8dabcf5406b2..2a28695d5bd6 100755
|
||||
--- a/arch/powerpc/boot/wrapper
|
||||
+++ b/arch/powerpc/boot/wrapper
|
||||
@@ -302,6 +302,7 @@ pseries)
|
||||
if [ "$format" != "elf32ppc" ]; then
|
||||
link_address=
|
||||
pie=-pie
|
||||
+ notext='-z notext'
|
||||
fi
|
||||
make_space=n
|
||||
;;
|
||||
--
|
||||
2.53.0
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
From 445dd03e6d4c8ba8bbc0525d82f77ede2f89355e Mon Sep 17 00:00:00 2001
|
||||
From: Nathan Chancellor <nathan@kernel.org>
|
||||
Date: Fri, 21 Jan 2022 14:15:08 -0700
|
||||
Subject: [PATCH 3/3] WIP: arch/powerpc/boot: Add '-z norelro'
|
||||
|
||||
ld.bfd defaults to '-z norelro', whereas ld.lld defaults to '-z relro',
|
||||
which results in an error when building cuImages:
|
||||
|
||||
ld.lld: error: section: .dynamic is not contiguous with other relro sections
|
||||
|
||||
Commit a538d184e3f0 ("powerpc/boot: Move the .got section to after the
|
||||
.dynamic section") previously worked around this in the boot wrapper by
|
||||
shuffling the sections but other areas of the kernel have just disabled
|
||||
the relro program header altogether (see commit 3b92fa7485eb ("arm64:
|
||||
link with -z norelro regardless of CONFIG_RELOCATABLE") and
|
||||
commit 0cda9bc15dfc ("ARM: 9038/1: Link with '-z norelro'")).
|
||||
|
||||
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
|
||||
---
|
||||
arch/powerpc/boot/wrapper | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
|
||||
index 2a28695d5bd6..1e4f4fbd3948 100755
|
||||
--- a/arch/powerpc/boot/wrapper
|
||||
+++ b/arch/powerpc/boot/wrapper
|
||||
@@ -531,7 +531,7 @@ if [ "$platform" != "miboot" ]; then
|
||||
text_start="-Ttext $link_address"
|
||||
fi
|
||||
#link everything
|
||||
- $ld -m $format -T $lds $text_start $pie $nodl $nowarn $rodynamic $notext -o "$ofile" $map \
|
||||
+ $ld -m $format -T $lds $text_start $pie $nodl $nowarn $rodynamic $notext -z norelro -o "$ofile" $map \
|
||||
$platformo $tmp $object/wrapper.a
|
||||
rm $tmp
|
||||
fi
|
||||
--
|
||||
2.53.0
|
||||
|
||||
|
|
@ -48,10 +48,18 @@ makedepends="
|
|||
"
|
||||
replaces="linux-stable"
|
||||
|
||||
# Source
|
||||
# powerpc boot wrapper patches:
|
||||
# Necessary for compilation without cross GCC in PATH, cherry-picked from
|
||||
# Nathan's fork, he does not have time to upstream them right now but would be
|
||||
# happy if someone else did:
|
||||
# https://lore.kernel.org/linuxppc-dev/aXs8sgAcci9FKKpx@luna/
|
||||
source="
|
||||
linux-$_kver.tar.xz::https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kver.tar.xz
|
||||
|
||||
0001-WIP-arch-powerpc-boot-Support-LLVM-1-in-wrapper-scri.patch
|
||||
0002-WIP-arch-powerpc-boot-Use-z-notext-for-pseries-image.patch
|
||||
0003-WIP-arch-powerpc-boot-Add-z-norelro.patch
|
||||
|
||||
config-stable.aarch64
|
||||
config-stable.armv7
|
||||
config-stable.loongarch64
|
||||
|
|
@ -114,6 +122,9 @@ package() {
|
|||
sha512sums="
|
||||
bcc0f5c7239f973b9c41a4ea99bd10a3df70f34c78f3f22b60098f41cca16c872563b2764e239fa49ba7a9a67c4f2c52f37684239ed93d22f8d08d3affb3daea patch-6.19.6.patch.xz
|
||||
01b29c7f4e5bc0c9802794c2cd027fece825f90417be229a71e60eefce530010d5d301749c54ae744e9d4a483518e769e2bb7e6e9209687681ad7fff11c3ed86 linux-6.19.tar.xz
|
||||
1f11df2480e9f691573283597160b4c806e492cdca4825f3acb3afb70bde43abfab487bcde1f5553b431a702a0039479d041b0ce7859970e706b5a51d2ad8fb0 0001-WIP-arch-powerpc-boot-Support-LLVM-1-in-wrapper-scri.patch
|
||||
26521a9c9ea769534095dc4e306babadc8bcbaf03d7faa523c377e41ba0f742ecd0490fa27791d895f729c3ae8845297dca59b4db2475e7f078e689c447430bc 0002-WIP-arch-powerpc-boot-Use-z-notext-for-pseries-image.patch
|
||||
302c20c85559fc9b3b2420ed25be1bfbb76c87f2a470e4141c32e9542cf1f5c6b3b5a7847231a3eaa0f6bc0e5942d0c1599e807175dcf5e63469704c3d6adde3 0003-WIP-arch-powerpc-boot-Add-z-norelro.patch
|
||||
ba4821e5036df37212ae1a59929c9e6ac92d51ff1061eac241426860af0540b1816e8fd6e82bed0d7c127354fc8da5cbda82b1c726384e408b093300b123ece0 config-stable.aarch64
|
||||
d41f0c73329959d1a69011001718266ab76d1b884c75a85ef3393831442e2c609e2476a324e26db75aa07ffd3c15ce1bc995b50ae47c452b46c7cf0e8864ec22 config-stable.armv7
|
||||
2687ef98db28ea6509633121d3d701fbed68e0aea558745a4d2fcc6eb879808078f32f819b1f8bc43912194b0ab5ab74d0c75492461ab921a1684975b06f8b62 config-stable.loongarch64
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue