From 805e2b6172f5522a94e071d488076d5bb6c2871e Mon Sep 17 00:00:00 2001 From: Vladis Dronov Date: Wed, 1 Feb 2023 00:23:35 +0100 Subject: [PATCH] Get rid of text relocations in -fPIE build Fedora build system forces a PIE build with -fPIE indirectly via gcc spec /usr/lib/rpm/redhat/redhat-hardened-cc1. This does not work for assembly sources, so a PIC-aware assembly code won't be built as PIC (PIE implies PIC). rdrand_asm.S is PIC-aware in 32bit mode, so force PIC for it, fixing the following build warning: /usr/bin/ld: rdrand_asm.o: warning: relocation in read-only section `.text' /usr/bin/ld: warning: creating DT_TEXTREL in a PIE --- rng-tools.spec | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rng-tools.spec b/rng-tools.spec index 27ed689..6783d6b 100644 --- a/rng-tools.spec +++ b/rng-tools.spec @@ -63,6 +63,12 @@ TPM, jitter) and supplies entropy from them to a kernel entropy pool. %endif ./autogen.sh +# a dirty hack to force PIC for a PIC-aware assembly code for i686 +# /usr/lib/rpm/redhat/redhat-hardened-cc1 in Koji/Brew does not +# force PIC for assembly sources as of now +%ifarch i386 i686 +sed -i -e '/^#define RDRAND_RETRY_LIMIT\t10/a#define __PIC__ 1' rdrand_asm.S +%endif # a dirty hack so libdarn_impl_a_CFLAGS overrides common CFLAGS sed -i -e 's/$(libdarn_impl_a_CFLAGS) $(CFLAGS)/$(CFLAGS) $(libdarn_impl_a_CFLAGS)/' Makefile.in %configure %{?_without_pkcs11} %{?_without_rtlsdr}