From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26C7D606A8B4 for ; Fri, 13 Nov 2026 12:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c80HaghW; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Le1eWc7j; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c80HaghW Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jQwpD69YRz2xyB; Fri, 13 Nov 2026 23:01:24 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1794571284; cv=none; b=UeHrEMChMJeu3Swb2xSkm/0PQ795BGY9qG0Ivde/3Rb4lpKt1YhP/yTCQ+gsFxJPlk0xlamuWDSr63R7NZMIwSXhVN0XraoEjfCZdXMpt4tv3IcPASlxch2Q+VxqULLO+da4XRGm9beb74WhDwkMwz4m+pUg/uIfxUugHltxMMWbNOXpcF/JFADyOxDiB/5Oa8fXYVj7So5KOqG3IKXaEAM9S1lxf6dQMz7wrASiOax0rWL4FkWSxYcsQsqn+QPPuRejgu56PTEQNjJuDSBep0RqojeTP1N/+97aq+EVI/P2D1l8f+IqHPwMYkdzS2wWuEsosBahnVymVDKhQ/qYWg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1794571284; c=relaxed/relaxed; bh=QuDGTGEuVvl3MPiP6Lxh0kED44wnv1RS4KyW/3v5QR0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:content-type; b=dgSvwd2IaigtMfKsc1R6f3KRBANJGrjgRzR/udNtUfXalUpJDPv51LMZC0VBeA/aQ/iDh0hFbRXW1q/IG/AQ4mKtF20A7IZeeg4XyRRvEdY2aNJEemJp4a3o5I54d5WdI4YoJJbYV4xyB7rUl+MKxU8uO6zW05W9cSgqSLu3JCl2UCwzDUM9o26n2Ov6XuFPcsxDjB2lyCGQIIOnaXY0Ddq+nM03nF2AG8E3mtU+t13KqHK1Hz5kO/5y+HkKCnBW4CCNHE42Q4Hixl3NxQ0OLZChY+pmFALDpFXnoDRaQ7g1HzddkbJhoFZFr/WME9IXTJ0m8QGyj6WLlvUKORSrOw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c80HaghW; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Le1eWc7j; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c80HaghW; dkim-atps=neutral; spf=pass (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=thuth@redhat.com; receiver=lists.ozlabs.org) smtp.mailfrom=redhat.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c80HaghW; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Le1eWc7j; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c80HaghW; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=thuth@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4jQwpC4Xbcz2xjP for ; Fri, 13 Nov 2026 23:01:21 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794571277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QuDGTGEuVvl3MPiP6Lxh0kED44wnv1RS4KyW/3v5QR0=; b=c80HaghWaS9GuGbvkgKa/gEgvM/1lCEKnUWYm8i9o4kvrzzpwCaGy2dghbyELyMEZ1B3/S kW0r1NRqI2ESiKgAAZ/naNuwV9g/+QHeHEONWvMfQ95Byxh4nraO1F36oTyVDgqDGbjqxP ovXeAhKigWMa405F+Q+5sC+NzvPcJE8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794571278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QuDGTGEuVvl3MPiP6Lxh0kED44wnv1RS4KyW/3v5QR0=; b=Le1eWc7juD6QGT2or7eLTozZEPdYR6wGjUfeyUgnpP6yvs5dQIVTGLUZkzYD68s0JH7r42 esqzNz+34+RXgb+VE6XEAWx4bULWtMyAU6Y0XzWyJ1wOqrEN7Qt391LyxFEbgJ1vBUtQdj oMjRZWiLvrKYcqshGkZpIcLLqCK6r3Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794571277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QuDGTGEuVvl3MPiP6Lxh0kED44wnv1RS4KyW/3v5QR0=; b=c80HaghWaS9GuGbvkgKa/gEgvM/1lCEKnUWYm8i9o4kvrzzpwCaGy2dghbyELyMEZ1B3/S kW0r1NRqI2ESiKgAAZ/naNuwV9g/+QHeHEONWvMfQ95Byxh4nraO1F36oTyVDgqDGbjqxP ovXeAhKigWMa405F+Q+5sC+NzvPcJE8= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-353-A7ZsTMK1NMyLP5Xu2r78Mg-1; Fri, 13 Nov 2026 07:01:10 -0500 X-MC-Unique: A7ZsTMK1NMyLP5Xu2r78Mg-1 X-Mimecast-MFC-AGG-ID: A7ZsTMK1NMyLP5Xu2r78Mg_1794571268 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4329E1800607; Fri, 13 Nov 2026 12:01:07 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.48.21]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B092418004FC; Fri, 13 Nov 2026 12:01:02 +0000 (UTC) From: Thomas Huth To: Andrew Jones , Paolo Bonzini , kvm@vger.kernel.org Cc: Laurent Vivier , Claudio Imbrenda , Janosch Frank , =?UTF-8?q?Nico=20B=C3=B6hr?= , Chinmay Rath , kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org, Amit Machhiwal Subject: [kvm-unit-tests PATCH] Move position-independant code flags into the target specific Makefiles Date: Fri, 13 Nov 2026 13:01:01 +0100 Message-ID: <20261113120101.145183-1-thuth@redhat.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list X-Archived-By: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-MFC-PROC-ID: t3Uoeu9F3-tLRWP85TyJFcUq2mPrCJqbg4f90yM_Pro_1794571268 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The settings for position-independant code are currently quite a mess: It depends on the target whether we need the flags or rather should even disable PIC / PIE, but currently the settings are spread between the main Makefile (-fno-pic is the default, unless CONFIG_EFI has been set) and the target specific Makefiles. This leads to some weird situations where we have -fno-pic in the CFLAGS, but link with -pie in the LDFLAGS since we still want to get a relocation table, but then again need to add a "-z notext" to the linker flags to avoid warnings about relocation entries in the text segment. Let's face it: Always adding -fno-pic / -no-pie in the main Makefile is a bad idea. Move the settings to the target specific Makefiles instead where we know what we really want, and then we can finally drop the "-z notext" settings, too. Signed-off-by: Thomas Huth --- Makefile | 6 +----- arm/Makefile.arm | 2 ++ arm/Makefile.arm64 | 3 +-- powerpc/Makefile | 5 ++++- riscv/Makefile | 1 + s390x/Makefile | 3 +++ x86/Makefile.common | 5 +++++ 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 8e002043..b0a0b89f 100644 --- a/Makefile +++ b/Makefile @@ -70,8 +70,6 @@ fomit_frame_pointer := $(call cc-option, $(frame-pointer-flag), "") fno_stack_protector := $(call cc-option, -fno-stack-protector, "") fno_stack_protector_all := $(call cc-option, -fno-stack-protector-all, "") wno_frame_address := $(call cc-option, -Wno-frame-address, "") -fno_pic := $(call cc-option, -fno-pic, "") -no_pie := $(call cc-option, -no-pie, "") wclobbered := $(call cc-option, -Wclobbered, "") wunused_but_set_parameter := $(call cc-option, -Wunused-but-set-parameter, "") wmissing_parameter_type := $(call cc-option, -Wmissing-parameter-type, "") @@ -85,8 +83,6 @@ COMMON_CFLAGS += $(wno_frame_address) COMMON_CFLAGS += $(if $(U32_LONG_FMT),-D__U32_LONG_FMT__,) ifeq ($(CONFIG_EFI),y) COMMON_CFLAGS += $(EFI_CFLAGS) -else -COMMON_CFLAGS += $(fno_pic) endif COMMON_CFLAGS += $(wclobbered) COMMON_CFLAGS += $(wunused_but_set_parameter) @@ -103,7 +99,7 @@ CFLAGS += $(LATE_CFLAGS) autodepend-flags = -MMD -MP -MF $(dir $*).$(notdir $*).d -LDFLAGS += -nostdlib $(no_pie) -z noexecstack +LDFLAGS += -nostdlib -z noexecstack $(libcflat): $(cflatobjs) $(AR) rcs $@ $^ diff --git a/arm/Makefile.arm b/arm/Makefile.arm index 7734e17f..7313c843 100644 --- a/arm/Makefile.arm +++ b/arm/Makefile.arm @@ -13,6 +13,8 @@ endif CFLAGS += $(machine) CFLAGS += -mno-unaligned-access +CFLAGS += -fno-pic +LDFLAGS += -no-pie ifeq ($(TARGET),qemu) arch_LDFLAGS = -Ttext=40010000 diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64 index a40c830d..ea0202eb 100644 --- a/arm/Makefile.arm64 +++ b/arm/Makefile.arm64 @@ -7,8 +7,7 @@ bits = 64 ldarch = elf64-littleaarch64 arch_LDFLAGS = -pie -n -arch_LDFLAGS += -z notext -CFLAGS += -mstrict-align +CFLAGS += -fpie -mstrict-align sve_flag := $(call cc-option, -march=armv8.5-a+sve, "") ifneq ($(strip $(sve_flag)),) diff --git a/powerpc/Makefile b/powerpc/Makefile index 41e752b0..eff129b0 100644 --- a/powerpc/Makefile +++ b/powerpc/Makefile @@ -66,6 +66,9 @@ CFLAGS += -ffreestanding CFLAGS += -O2 -msoft-float -mno-altivec $(mabi_no_altivec) CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib CFLAGS += -Wa,-mregnames +CFLAGS += -fpie + +LDFLAGS += -pie # We want to keep intermediate files .PRECIOUS: %.o @@ -78,7 +81,7 @@ include $(SRCDIR)/scripts/asm-offsets.mak FLATLIBS = $(libcflat) $(LIBFDT_archive) %.elf: CFLAGS += $(arch_CFLAGS) -%.elf: LDFLAGS += $(arch_LDFLAGS) -pie -n +%.elf: LDFLAGS += $(arch_LDFLAGS) -n %.elf: %.o $(FLATLIBS) $(SRCDIR)/powerpc/flat.lds $(cstart.o) $(reloc.o) %.aux.o $(LD) $(LDFLAGS) -o $@ \ -T $(SRCDIR)/powerpc/flat.lds --build-id=none \ diff --git a/riscv/Makefile b/riscv/Makefile index 348a30a7..79a9c1ad 100644 --- a/riscv/Makefile +++ b/riscv/Makefile @@ -93,6 +93,7 @@ CFLAGS += -std=gnu99 CFLAGS += -ffreestanding CFLAGS += -O2 CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib -I $(SRCDIR)/riscv +CFLAGS += -fno-pic asm-offsets = lib/riscv/asm-offsets.h riscv/sbi-asm-offsets.h include $(SRCDIR)/scripts/asm-offsets.mak diff --git a/s390x/Makefile b/s390x/Makefile index 97ed0b47..29bea5cc 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -88,7 +88,10 @@ CFLAGS += -O2 CFLAGS += -march=zEC12 CFLAGS += -mbackchain CFLAGS += -fno-delete-null-pointer-checks +CFLAGS += -fno-pic + LDFLAGS += -Wl,--build-id=none +LDFLAGS += -no-pie # We want to keep intermediate files .PRECIOUS: %.o %.lds diff --git a/x86/Makefile.common b/x86/Makefile.common index 054e2391..a0201fcd 100644 --- a/x86/Makefile.common +++ b/x86/Makefile.common @@ -40,6 +40,11 @@ COMMON_CFLAGS += -Wa,--divide endif COMMON_CFLAGS += -O1 +ifneq ($(CONFIG_EFI),y) +CFLAGS += -fno-pic +LDFLAGS += -no-pie +endif + # stack.o relies on frame pointers. KEEP_FRAME_POINTER := y -- 2.56.0