From patchwork Tue Sep 1 22:25:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 1355441 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bh1vd6Zg2z9sTM for ; Wed, 2 Sep 2020 08:29:17 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=G1fcxj7N; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4Bh1vd5r3mzDqYW for ; Wed, 2 Sep 2020 08:29:17 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--ndesaulniers.bounces.google.com (client-ip=2607:f8b0:4864:20::b49; helo=mail-yb1-xb49.google.com; envelope-from=3ympoxwwkddeaqrfnhyavreftbbtyr.pbzyvahkccp-qriyvfgf.bmynof.bet@flex--ndesaulniers.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=G1fcxj7N; dkim-atps=neutral Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) (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 4Bh1qb43YkzDqDQ for ; Wed, 2 Sep 2020 08:25:41 +1000 (AEST) Received: by mail-yb1-xb49.google.com with SMTP id p138so2812174yba.12 for ; Tue, 01 Sep 2020 15:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=1Vm2QqyX/OUi6RR2IULKGjS+daCT8Blmd+/gKY17G40=; b=G1fcxj7NZ2HKC3O3tMp7OaMWLaYHaeE9KsxbMa4zRsJJVBwflae1qaQvhTrD9ZrJKX 8uxzDbP9UDghqhvAq0e/p57waEeBVCZp7eZsU0L/Iil4/f58FCSkNr0QUELw0+sdJm6h 9hNL1cAJRg+9Lf6PDKIX25eLT/Cwx/RrCkrslPykkYujMCe+LxOhh8pzlUeaoInYxUfK R9Sw0QwRRwHq9avL6LlzpI0vtTMG23d+i+ypHwy8d3KRRF3lB5tAK+UIImMkMCY4hCSr 3ys0h9VjnvAfa/z0G8Y7tXq9BSVMTq0jEtayzVpuu6d0aGlBultoPKdf8EDn+n0Wq7Hz aoJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=1Vm2QqyX/OUi6RR2IULKGjS+daCT8Blmd+/gKY17G40=; b=LhTRA1CgcHuGIwAki86g+0mE7rxTVCJ0uVE40xBt5eBp/wn46PHUlKDs24Ffw5TG36 KNhw7dsGRBibE/0MFVvED46J5lF0yFdStwaVj8qp67vOi7GPyzEphM/f26E/z4ZMkRkd kaAU0hjA88BzWRGmo1VmTWL5GF8M12iFdo5XK9px6sLWRwqB00J0XiQfphghAnrZZBLQ VBoZc40oVIiCi2n8ZOb+APWogSghCnDEF6n7Rtx6QopC272jX7UP8MDyU7DFhZ9WXly8 sCnHdq7nXlVkjefnSEjSsuqNHfjkajTyYc/1hLcLNvGt1UGTD1hkFmVxmhIgtWSJ9/SW HKVg== X-Gm-Message-State: AOAM533GmEa5pp9pCkAOho9BJjq/SGLS592/whtbPV19f5aW1knnShaY tn5b8Vzfga5mAoh6i6P/kIGxH4QaTSvwECCmY14= X-Google-Smtp-Source: ABdhPJx5yf3WNW7Q5w2bD1WYoDV7Na2wjlaEIzL4kF+ReKd10GAYtHjsF7mnqYQo7KV+jgGCvau1EGlVhk8NOTuv0R4= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:f693:9fff:fef4:4d25]) (user=ndesaulniers job=sendgmr) by 2002:a25:7509:: with SMTP id q9mr5300885ybc.317.1598999136478; Tue, 01 Sep 2020 15:25:36 -0700 (PDT) Date: Tue, 1 Sep 2020 15:25:22 -0700 In-Reply-To: <20200901222523.1941988-1-ndesaulniers@google.com> Message-Id: <20200901222523.1941988-2-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200901222523.1941988-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH 1/2] powerpc/vdso64: link vdso64 with linker From: Nick Desaulniers To: Michael Ellerman , Nicholas Piggin X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe Leroy , Joe Lawrence , Kees Cook , Fangrui Song , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Paul Mackerras , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Rather than invoke the compiler as the driver, use the linker. That way we can check --orphan-handling=warn support correctly, as cc-ldoption was removed in commit 055efab3120b ("kbuild: drop support for cc-ldoption"). Painstakingly compared the output between `objdump -a` before and after this change. Now function symbols have the correct type of FUNC rather than NONE, and the entry is slightly different (which doesn't matter for the vdso). Binary size is the same. Fixes: commit f2af201002a8 ("powerpc/build: vdso linker warning for orphan sections") Link: https://lore.kernel.org/lkml/CAKwvOdnn3wxYdJomvnveyD_njwRku3fABWT_bS92duihhywLJQ@mail.gmail.com/ Signed-off-by: Nick Desaulniers --- arch/powerpc/include/asm/vdso.h | 17 ++--------------- arch/powerpc/kernel/vdso64/Makefile | 8 ++++++-- arch/powerpc/kernel/vdso64/vdso64.lds.S | 1 - 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/include/asm/vdso.h b/arch/powerpc/include/asm/vdso.h index 2ff884853f97..11b2ecf49f79 100644 --- a/arch/powerpc/include/asm/vdso.h +++ b/arch/powerpc/include/asm/vdso.h @@ -24,19 +24,7 @@ int vdso_getcpu_init(void); #else /* __ASSEMBLY__ */ -#ifdef __VDSO64__ -#define V_FUNCTION_BEGIN(name) \ - .globl name; \ - name: \ - -#define V_FUNCTION_END(name) \ - .size name,.-name; - -#define V_LOCAL_FUNC(name) (name) -#endif /* __VDSO64__ */ - -#ifdef __VDSO32__ - +#if defined(__VDSO32__) || defined (__VDSO64__) #define V_FUNCTION_BEGIN(name) \ .globl name; \ .type name,@function; \ @@ -46,8 +34,7 @@ int vdso_getcpu_init(void); .size name,.-name; #define V_LOCAL_FUNC(name) (name) - -#endif /* __VDSO32__ */ +#endif /* __VDSO{32|64}__ */ #endif /* __ASSEMBLY__ */ diff --git a/arch/powerpc/kernel/vdso64/Makefile b/arch/powerpc/kernel/vdso64/Makefile index 38c317f25141..7ea3ce537d0a 100644 --- a/arch/powerpc/kernel/vdso64/Makefile +++ b/arch/powerpc/kernel/vdso64/Makefile @@ -32,9 +32,13 @@ $(obj)/%.so: OBJCOPYFLAGS := -S $(obj)/%.so: $(obj)/%.so.dbg FORCE $(call if_changed,objcopy) +ldflags-y := -shared -soname linux-vdso64.so.1 \ + $(call ld-option, --eh-frame-hdr) \ + $(call ld-option, --orphan-handling=warn) -T + # actual build commands -quiet_cmd_vdso64ld = VDSO64L $@ - cmd_vdso64ld = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) $(call cc-ldoption, -Wl$(comma)--orphan-handling=warn) +quiet_cmd_vdso64ld = LD $@ + cmd_vdso64ld = $(cmd_ld) # install commands for the unstripped file quiet_cmd_vdso_install = INSTALL $@ diff --git a/arch/powerpc/kernel/vdso64/vdso64.lds.S b/arch/powerpc/kernel/vdso64/vdso64.lds.S index 4e3a8d4ee614..58c33b704b6a 100644 --- a/arch/powerpc/kernel/vdso64/vdso64.lds.S +++ b/arch/powerpc/kernel/vdso64/vdso64.lds.S @@ -11,7 +11,6 @@ OUTPUT_FORMAT("elf64-powerpcle", "elf64-powerpcle", "elf64-powerpcle") OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc") #endif OUTPUT_ARCH(powerpc:common64) -ENTRY(_start) SECTIONS { From patchwork Tue Sep 1 22:25:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 1355442 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bh1y15qSXz9sTN for ; Wed, 2 Sep 2020 08:31:21 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=CgqVD+cU; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4Bh1xz0DpBzDqTh for ; Wed, 2 Sep 2020 08:31:19 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--ndesaulniers.bounces.google.com (client-ip=2607:f8b0:4864:20::74a; helo=mail-qk1-x74a.google.com; envelope-from=3yspoxwwkddmcsthpjacxtghvddvat.rdbaxcjmeer-stkaxhih.doapqh.dgv@flex--ndesaulniers.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=CgqVD+cU; dkim-atps=neutral Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) (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 4Bh1qc50LczDqDQ for ; Wed, 2 Sep 2020 08:25:42 +1000 (AEST) Received: by mail-qk1-x74a.google.com with SMTP id 196so2002202qkn.6 for ; Tue, 01 Sep 2020 15:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=xFF5qxswQ8XcvkvdvfVY4/mMkz+/5Nm8uIdW/HNF4l0=; b=CgqVD+cUWdzWbxzhIKI7RaHd9LEyOmQtSIfGxSeTZx3wjhQwa49KpJeXWTcaf02UaT 1t1h7E4GQ51bnUwDBSLFbqTvq29wGC4ct4Zyu8vgZtkM46eQJN1UsEKFm/8Of7YG8Kv5 A/r8lJXFwwttWKEbrul9OMFa6vSTWwUvt9OXf+wEX4A0aUKS8+RiOBiIr+8uA9ECs8bN Vl03pCefqLV6Bj+L87/WKvPDlpeTmXl597+8SYhKOlLzzvbsd2ifJ5UoyxVWQbs3AK3v u1F1qssZJ/KbKpGQp1c2MiRQlak+5cFS+kkOb5rIh5b0yPkY6YgNgyaHrOEJD4WpCq9p 3+Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xFF5qxswQ8XcvkvdvfVY4/mMkz+/5Nm8uIdW/HNF4l0=; b=N2NLhYHuIPxkMfBm+MrkuefosNjELZHS1A4lpKMAeXk6QQwhPD0i+wXd+hnqHvciOh 58CpcKxeFszlGWJITGZu2uQDGs2sJwiuMiWgsSNio05ZWlfu03ebdx9gxaAv11gnpEcO yr1CdcbQmTxr/JHz8FP5HMs+mvHC6awNnZd4w8iXVFro6DosRw0o7j+2SzDLjJI7ygbt 5TB6gFwwRv6S1NTAo1+gjJXVuQOmbWZgdmCwYgdD94s8U8Wb1OAsvrWzXfISBLKo2nU+ q3nzZtZBUDnK7Si2+i9QYL8T3fWZHa69uMV67hGhep7vFyUyT9gl7UHLHvbxM2ovvoz1 Auqw== X-Gm-Message-State: AOAM53304bJMiLUEBSFK8x85yza90nLsn6LBt5XNM77hXNX3O+NS4/2v LEXREWLQZ+RPRD4xgQ66RZh4yooTjxGp5NKu630= X-Google-Smtp-Source: ABdhPJxyzoZmVuOGUXyZqPhNEmq3n7shEn4qdfzq8u7nGZfUD+VJvMmXZlfbSSn7oT0RWF6YqEQvDoRsCL3W6Eb4Rbc= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:f693:9fff:fef4:4d25]) (user=ndesaulniers job=sendgmr) by 2002:a05:6214:10e8:: with SMTP id q8mr4223437qvt.59.1598999138727; Tue, 01 Sep 2020 15:25:38 -0700 (PDT) Date: Tue, 1 Sep 2020 15:25:23 -0700 In-Reply-To: <20200901222523.1941988-1-ndesaulniers@google.com> Message-Id: <20200901222523.1941988-3-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200901222523.1941988-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH 2/2] powerpc/vdso32: link vdso64 with linker From: Nick Desaulniers To: Michael Ellerman , Nicholas Piggin X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe Leroy , Joe Lawrence , Kees Cook , Fangrui Song , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Paul Mackerras , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Rather than invoke the compiler as the driver, use the linker. That way we can check --orphan-handling=warn support correctly, as cc-ldoption was removed in commit 055efab3120b ("kbuild: drop support for cc-ldoption"). Requires dropping the .got section. I couldn't find how it was used in the vdso32. Fixes: commit f2af201002a8 ("powerpc/build: vdso linker warning for orphan sections") Link: https://lore.kernel.org/lkml/CAKwvOdnn3wxYdJomvnveyD_njwRku3fABWT_bS92duihhywLJQ@mail.gmail.com/ Signed-off-by: Nick Desaulniers --- Not sure removing .got is a good idea or not. Otherwise I observe the following link error: powerpc-linux-gnu-ld: warning: orphan section `.got' from `arch/powerpc/kernel/vdso32/sigtramp.o' being placed in section `.got' powerpc-linux-gnu-ld: _GLOBAL_OFFSET_TABLE_ not defined in linker created .got powerpc-linux-gnu-ld: final link failed: bad value sigtramp.c doesn't mention anything from the GOT AFAICT, and doesn't look like it contains relocations that do, so I'm not sure where references to _GLOBAL_OFFSET_TABLE_ are coming from. arch/powerpc/kernel/vdso32/Makefile | 7 +++++-- arch/powerpc/kernel/vdso32/vdso32.lds.S | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile index 87ab1152d5ce..611a5951945a 100644 --- a/arch/powerpc/kernel/vdso32/Makefile +++ b/arch/powerpc/kernel/vdso32/Makefile @@ -27,6 +27,9 @@ UBSAN_SANITIZE := n ccflags-y := -shared -fno-common -fno-builtin -nostdlib \ -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both asflags-y := -D__VDSO32__ -s +ldflags-y := -shared -soname linux-vdso32.so.1 \ + $(call ld-option, --eh-frame-hdr) \ + $(call ld-option, --orphan-handling=warn) -T obj-y += vdso32_wrapper.o extra-y += vdso32.lds @@ -49,8 +52,8 @@ $(obj-vdso32): %.o: %.S FORCE $(call if_changed_dep,vdso32as) # actual build commands -quiet_cmd_vdso32ld = VDSO32L $@ - cmd_vdso32ld = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ $(call cc-ldoption, -Wl$(comma)--orphan-handling=warn) -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) +quiet_cmd_vdso32ld = LD $@ + cmd_vdso32ld = $(cmd_ld) quiet_cmd_vdso32as = VDSO32A $@ cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $< diff --git a/arch/powerpc/kernel/vdso32/vdso32.lds.S b/arch/powerpc/kernel/vdso32/vdso32.lds.S index 4c985467a668..0ccdebad18b8 100644 --- a/arch/powerpc/kernel/vdso32/vdso32.lds.S +++ b/arch/powerpc/kernel/vdso32/vdso32.lds.S @@ -61,7 +61,6 @@ SECTIONS .fixup : { *(.fixup) } .dynamic : { *(.dynamic) } :text :dynamic - .got : { *(.got) } :text .plt : { *(.plt) } _end = .; @@ -108,7 +107,9 @@ SECTIONS .debug_varnames 0 : { *(.debug_varnames) } /DISCARD/ : { + *(.got) *(.note.GNU-stack) + *(.branch_lt) *(.data .data.* .gnu.linkonce.d.* .sdata*) *(.bss .sbss .dynbss .dynsbss) *(.glink .iplt .plt .rela*)