From: Don Zickus dzickus@redhat.com
Fix binutils breakage
The binutils package in Rawhide has stricter checks about PIE/PIC code and will start reporting errors if it detects mixing and matching no-PIE with PIE binaries (especially around bpf binaries).
Example errors look like:
/usr/bin/ld: /tmp/ccL7dkfR.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status
Fix this by adding more CFLAGS to force PIE/PIC generated binaries to bpf releated selftests, tools and samples.
This patch was provided by Carlos O'Donell and understands how it works. I am just the middle man.
All -fPIE errors are resolved except for one about libbpf.a. The static version of the library doesn't take CFLAGS so it can't be forced to build with PIE/PIC. This error is ignored by the spec file, so it is ignored by this patch too.
Signed-off-by: Don Zickus dzickus@redhat.com
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template index blahblah..blahblah 100644 --- a/redhat/kernel.spec.template +++ b/redhat/kernel.spec.template @@ -2769,7 +2769,7 @@ if [ ! -f include/generated/autoconf.h ]; then %{make} %{?_smp_mflags} modules_prepare fi
-%{make} %{?_smp_mflags} ARCH=$Arch V=1 M=samples/bpf/ VMLINUX_H="${RPM_VMLINUX_H}" || true +%{make} %{?_smp_mflags} TPROGS_USER_CFLAGS="%{?build_hostcflags}" TPROGS_USER_LDFLAGS="%{?build_hostldflags}" EXTRA_CFLAGS="%{?build_hostcflags}" EXTRA_LDFLAGS="%{?build_hostldflags}" ARCH=$Arch V=1 M=samples/bpf/ VMLINUX_H="${RPM_VMLINUX_H}" || true
# Prevent bpf selftests to build bpftool repeatedly: export BPFTOOL=$(pwd)/tools/bpf/bpftool/bpftool @@ -2783,7 +2783,7 @@ pushd tools/testing/selftests force_targets="" %endif
-%{make} %{?_smp_mflags} ARCH=$Arch V=1 TARGETS="bpf mm livepatch net net/forwarding net/mptcp netfilter tc-testing memfd drivers/net/bonding" SKIP_TARGETS="" $force_targets INSTALL_PATH=%{buildroot}%{_libexecdir}/kselftests VMLINUX_H="${RPM_VMLINUX_H}" install +%{make} %{?_smp_mflags} USERCFLAGS="%{?build_hostcflags}" USERLDFLAGS="%{?build_hostldflags}" ARCH=$Arch V=1 TARGETS="bpf mm livepatch net net/forwarding net/mptcp netfilter tc-testing memfd drivers/net/bonding" SKIP_TARGETS="" $force_targets INSTALL_PATH=%{buildroot}%{_libexecdir}/kselftests VMLINUX_H="${RPM_VMLINUX_H}" install
# 'make install' for bpf is broken and upstream refuses to fix it. # Install the needed files manually.
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2749
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2749#note_1636180...
@vmalikrh - i just pushed v3, can you double check it matches your expectations?
From: Viktor Malik on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2749#note_1636610...
I believe that we decided to replace the `EXTRA_` flags by a custom bpftool, otherwise there were errors:
```suggestion:-0+0 %{make} %{?_smp_mflags} TPROGS_USER_CFLAGS="%{?build_hostcflags}" TPROGS_USER_LDFLAGS="%{?build_hostldflags}" BPFTOOL="$(pwd)/tools/bpf/bpftool/bpftool" ARCH=$Arch V=1 M=samples/bpf/ VMLINUX_H="${RPM_VMLINUX_H}" || true ```
With this, samples/bpf should compile with PIE.
FWIW, it should suffice to move the below lines
```plaintext 2774 # Prevent bpf selftests to build bpftool repeatedly: 2775 export BPFTOOL=$(pwd)/tools/bpf/bpftool/bpftool ```
above this command, but when I tried that, the bpftool in samples still attempted to build and errors occurred.
From: Viktor Malik on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2749#note_1636610...
There's still one change necessary. Closing this thread and opening another one.
From: Tony Camuso on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2749#note_1777360...
For ... ipmi input i2c leds
Approve
From: Marcelo Ricardo Leitner on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2749#note_2049471...
Hi. Is this MR still needed?
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2749#note_2049735...
i think this was resolved upstream and after 10 months clearly isn't needed. Closing.
kernel@lists.fedoraproject.org