From patchwork Tue Aug 27 20:40:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 172300 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp6308610ily; Tue, 27 Aug 2019 13:40:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwO1Vo6DsnP7FGr2Ss65DZWO+/HlOWeboOld2JQqpwXly29rH3V09oeBWS5Qw0rG/q4LAtJ X-Received: by 2002:a17:902:fe11:: with SMTP id g17mr855250plj.154.1566938457597; Tue, 27 Aug 2019 13:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566938457; cv=none; d=google.com; s=arc-20160816; b=PllAsA2f52cYBtBG5TIwjXRsyC5FW/UjPi2IHQKYSk4/3hY4jC52mh4xQ9Nh1u4Yq6 c7TaqXVl6iGi4ZKBuTuzNmhQjyMojbdwWCdpSU+Ght3DZTh339rLQTQC6hKa7End+RbJ LroaDe5ame9LAIbWpJHyKt04VSWerHGY725MtcTuOz0F6qBf/KfS99Za22t6V1DqCAP/ GLPgaoXYlRWMGkSzY7aqdjeBnHThO39CbuQPP6toC9N70+ThxElprnAO4XgP1SQBFBhI CJYgBTzKT2suvncAh8g2QsPZ8Kxq9+iT+gxYDf+2RkNIHfqGytQbk7pTx8JulYmSsFET Nj/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=Ywx7jCXsKEfuHAj2q8Y6vNlDnApWLp+V93ssN5FszZc=; b=0BYKhZ1TZ6j7ipL/lvDRDV+rFjtw8Uqs6Tnm9JI6oQDxtAWLTqDYgb0wYI5YMz5K8Z n4UoR22p1j0MoZQyDxB2xX7X+gGW9Ns3LWN89IHdQQl1Y4KXncBE0OeA9S9WC+FT/cnU UeWOzythoPqBlWSBS19xYRKlcoP8POigAPNBDXBqu5IQMD1iQv5Lm9NsbqTSgFD24gVY 1YUK+1jOAw6C+p4ZoFICrSo8g4ViRwT0GYZjvgOByp3MYH2TN4uRSs/VmL3AbSJABSxV 9GlOHKuN/VeF5V4+gp6nvnn+1L9DeXm3ofP87/w7MKqj8gB/oTUdK7iyieAtI0/9cdMN 9MGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oZVG6SfX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6si337482pgb.206.2019.08.27.13.40.57; Tue, 27 Aug 2019 13:40:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oZVG6SfX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730763AbfH0Uk4 (ORCPT + 28 others); Tue, 27 Aug 2019 16:40:56 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:47450 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730221AbfH0Ukx (ORCPT ); Tue, 27 Aug 2019 16:40:53 -0400 Received: by mail-pg1-f202.google.com with SMTP id l11so217096pgc.14 for ; Tue, 27 Aug 2019 13:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Ywx7jCXsKEfuHAj2q8Y6vNlDnApWLp+V93ssN5FszZc=; b=oZVG6SfXr9wmXQ8Rkz+CrFhNt9Bn+kim+2iyLqD1AZfdOXST1eTSwraH9ntOGJtoL4 qzAqH61z46Z31dZYp7HSK+kOIFNuMyXCOoF2W7QyHO2oquClG6cjfUgSu/ObSXmM6X1A Cei4K2LrukVqse/fjZhwZbnw+QhyJe40JUJ2O4aHhEJHu49hCPdxdLpHgLA9D+UvFbzy +1mYlLMPIqjWDdIYpcR+xquKD04F0Gt6y3hGFoH9wj7/F4Ip5cm6kLjZgR35p3q1XySY vnrGwHuV2tVpoAGHcy7OJTTSCCALCdu7KEEllQeg2O53Nh1QIFdYsbxqdMvrgdTpQa9O dMHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Ywx7jCXsKEfuHAj2q8Y6vNlDnApWLp+V93ssN5FszZc=; b=VywmHXDBVIUwPWvfOwyERXc9wmKiUHWx/7udwB2HKQphtKN35DvTFQVGv015zJE84i 90wws1aR/8oHFXMMi6oLewchWIpLn7ArVhMd9uSfSHBFcwyyKWS0l/d+88MW4rOFGv9o nIjvZ6cXPDGMOSmTnzccRHAWPmL994PAcar1pLC6kCpLOVf03p9jIyt0GCSjIduNMJmK dbneYRzkWY6R9Rnw+c3tDi+HBa4zZKA6rU3Z6Ew2+qUFB8n7OPpgevFvyDvxY0n0ONBA 9U4GnA7q6+Qm4M1mNMRIErgpFAOAUT8romZky9/LEnEyGkHWQA2yULxCsPCpsIgL+eOH USQA== X-Gm-Message-State: APjAAAX+02+S4jcClGSaFZgADnSpYKQ8M2u67LE4c7DNN3ELLlkRoeww /B2IbHsd+722zpofpuxJvYC+YH8P6FBL+LP7irU= X-Received: by 2002:a63:6206:: with SMTP id w6mr281844pgb.428.1566938452324; Tue, 27 Aug 2019 13:40:52 -0700 (PDT) Date: Tue, 27 Aug 2019 13:40:02 -0700 In-Reply-To: <20190827204007.201890-1-ndesaulniers@google.com> Message-Id: <20190827204007.201890-10-ndesaulniers@google.com> Mime-Version: 1.0 References: <20190827204007.201890-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v2 09/14] powerpc: prefer __section and __printf from compiler_attributes.h From: Nick Desaulniers To: miguel.ojeda.sandonis@gmail.com Cc: sedat.dilek@gmail.com, will@kernel.org, jpoimboe@redhat.com, naveen.n.rao@linux.vnet.ibm.com, davem@davemloft.net, paul.burton@mips.com, clang-built-linux@googlegroups.com, linux-kernel@vger.kernel.org, Nick Desaulniers Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GCC unescapes escaped string section names while Clang does not. Because __section uses the `#` stringification operator for the section name, it doesn't need to be escaped. Instead, we should: 1. Prefer __section(.section_name_no_quotes). 2. Only use __attribute__((__section(".section"))) when creating the section name via C preprocessor (see the definition of __define_initcall in arch/um/include/shared/init.h). This antipattern was found with: $ grep -e __section\(\" -e __section__\(\" -r See the discussions in: Link: https://bugs.llvm.org/show_bug.cgi?id=42950 Link: https://marc.info/?l=linux-netdev&m=156412960619946&w=2 Reported-by: Sedat Dilek Suggested-by: Josh Poimboeuf Signed-off-by: Nick Desaulniers --- arch/powerpc/boot/main.c | 3 +-- arch/powerpc/boot/ps3.c | 6 ++---- arch/powerpc/include/asm/cache.h | 2 +- arch/powerpc/kernel/btext.c | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) -- 2.23.0.187.g17f5b7556c-goog diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c index 102cc546444d..3ccc84e06fc4 100644 --- a/arch/powerpc/boot/main.c +++ b/arch/powerpc/boot/main.c @@ -150,8 +150,7 @@ static struct addr_range prep_initrd(struct addr_range vmlinux, void *chosen, * edit the command line passed to vmlinux (by setting /chosen/bootargs). * The buffer is put in it's own section so that tools may locate it easier. */ -static char cmdline[BOOT_COMMAND_LINE_SIZE] - __attribute__((__section__("__builtin_cmdline"))); +static char cmdline[BOOT_COMMAND_LINE_SIZE] __section(__builtin_cmdline); static void prep_cmdline(void *chosen) { diff --git a/arch/powerpc/boot/ps3.c b/arch/powerpc/boot/ps3.c index c52552a681c5..70b2ed82d2de 100644 --- a/arch/powerpc/boot/ps3.c +++ b/arch/powerpc/boot/ps3.c @@ -24,8 +24,7 @@ extern int lv1_get_repository_node_value(u64 in_1, u64 in_2, u64 in_3, #ifdef DEBUG #define DBG(fmt...) printf(fmt) #else -static inline int __attribute__ ((format (printf, 1, 2))) DBG( - const char *fmt, ...) {return 0;} +static inline int __printf(1, 2) DBG(const char *fmt, ...) { return 0; } #endif BSS_STACK(4096); @@ -35,8 +34,7 @@ BSS_STACK(4096); * The buffer is put in it's own section so that tools may locate it easier. */ -static char cmdline[BOOT_COMMAND_LINE_SIZE] - __attribute__((__section__("__builtin_cmdline"))); +static char cmdline[BOOT_COMMAND_LINE_SIZE] __section(__builtin_cmdline); static void prep_cmdline(void *chosen) { diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h index 45e3137ccd71..9114495855eb 100644 --- a/arch/powerpc/include/asm/cache.h +++ b/arch/powerpc/include/asm/cache.h @@ -91,7 +91,7 @@ static inline u32 l1_cache_bytes(void) isync #else -#define __read_mostly __attribute__((__section__(".data..read_mostly"))) +#define __read_mostly __section(.data..read_mostly) #ifdef CONFIG_PPC_BOOK3S_32 extern long _get_L2CR(void); diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c index 6dfceaa820e4..f57712a55815 100644 --- a/arch/powerpc/kernel/btext.c +++ b/arch/powerpc/kernel/btext.c @@ -26,7 +26,7 @@ static void scrollscreen(void); #endif -#define __force_data __attribute__((__section__(".data"))) +#define __force_data __section(.data) static int g_loc_X __force_data; static int g_loc_Y __force_data;