From: Don Zickus <dzic...@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 <dzic...@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_CFLAGS="%{?build_hostcflags}" 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
_______________________________________________
kernel mailing list -- kernel@lists.fedoraproject.org
To unsubscribe send an email to kernel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to