From patchwork Wed Aug 28 22:55:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 172502 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1396114ily; Wed, 28 Aug 2019 15:56:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaY8ixhp32r2vMeqRp6xrpeZVzG4Hhxh1s18TELKgu1pBtVM4CmR7fOmNUNase1/NTQZYI X-Received: by 2002:a17:902:a58c:: with SMTP id az12mr6904951plb.129.1567032998346; Wed, 28 Aug 2019 15:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567032998; cv=none; d=google.com; s=arc-20160816; b=X1+9YMTLJr32A6tQP99p9fzlt/MtNENAF9ELDhAa5vua5QWl/WqiVONqMalY8B1trF C1Q5JUVU3SQ6+BJAK5hLkRDSne+1PKL+nplGvjwMxYv1NSaaEjDz2LuDX9+XjQVV2+KQ 3SD1vKVt6m7W5AVB+1q4Can/ewVAvEsYa2L71bRMbCuaY3tmwwCCWiwWhHxcsVfkLAqY ZjSLESSd7WO/e3hS6mVrzUh9eM0QKdyDX9YNwxSMbLC7HbE8PKeV//mdyKnc/VZJQWno Vps75ea6Ro8Z4G6ez4oYBO0+Y6ZcZ8mk5D/plBV/9ql/u2hoxPxfMNG/ohFdX83G+2Fm o4MA== 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=LzcRbLdLn8n10++XwDQc5vyYA3PF12gHibA7BtY6a0Q=; b=kyAoFCy0Ti5rVIBXzjKxb+CTAOiFMqrxm2RbKuAwf8egKEZadlUNFIwXGiRWkAXmj2 QFk2vxEreJTraBepwA/6t5BfNZWo3NDzpOgQMexIr50w0x5AW0eR4z5aRECVYOzoP35A dA1lUMXwOXHhLLfJtLw0NXlrWjp2JCLGxPYwLhOYl2zX6wvkZh3jOvG0+46A5TUlq/YQ NVIQd0Eyvj0UTM4QDCuWV6y8y79/Xy9DRPqjmazxjwhxIu2brSgJQRklvWiS+w/lVC7P HnEyFgGc/Q6wQK9HvrXqlEHKxOrJ9cvmXaB4l03DmNBbsg1MmL/lFN3ze/r5jj7bZo8O 3FTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=K8RHoPgM; 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 72si609176pfx.268.2019.08.28.15.56.38; Wed, 28 Aug 2019 15:56:38 -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=K8RHoPgM; 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 S1727635AbfH1W4h (ORCPT + 28 others); Wed, 28 Aug 2019 18:56:37 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:39731 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727521AbfH1W4e (ORCPT ); Wed, 28 Aug 2019 18:56:34 -0400 Received: by mail-qt1-f201.google.com with SMTP id z15so1409081qtq.6 for ; Wed, 28 Aug 2019 15:56:34 -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=LzcRbLdLn8n10++XwDQc5vyYA3PF12gHibA7BtY6a0Q=; b=K8RHoPgM+mJAwqXlvEcSR/kuV73Nvjs0NviMvA+6/v0063urVipIsN+d8mlpENBRzA AIukuHkBYMxwEyNRQHbmPq/nktcLZUEzaTIHtmSEaLFMToKN8Bxjr+nWG4R2tJ/LnYOt 9n/pUgMBMpf76Jt7D0dXCQVThxHNybR+6+omky9JLxGLVpYxP/GO535I3f3GaQzlOCj1 pSVTjTbhZVosKLfoak/7Vdf4TFkOQCAFvrWNPlLcI0gT+Q0otmxwA3geurBCbjcyHt3S h/BlerhzfZusOFatfX7QUJX5mAIdGff06HBCjzEfOmhXm4JitbWIVjIz8ABXnaCNrW7S /Mag== 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=LzcRbLdLn8n10++XwDQc5vyYA3PF12gHibA7BtY6a0Q=; b=GAXtC+k4Qfx+gQqAEi+VgCVUCxah0l8DBzCyc7uTQJGOD/8YuacNxTJliAQZC3n4N7 Ctj3Tn7MYHFT3pU8zPbOJXz2kAKAlusRUkIjW0HmsVdYBragwY8dLn+KMbtnqbNxrnIt 8A+D7cn4hBglHxCcqebZraXX2skVubP+ic3EpOnpeYp3OS6xbV4Qb7xZMjLW2vsS2vGO gkzlpox7zFpD5Be/ygBw5ztQ6P/ddMzK5Qhajw6abwb0MWbxFFdzKcB8C/RjW45uQMOP thwQcJFeq7jvEnzkGgiBf7oe0y0Mi1pd94q3t5C+OW+uev5WtTFRqkF5JjRrCnKA9nho oX+w== X-Gm-Message-State: APjAAAXTSXDZwbiqc2IglyJgG72QcQOmPrKOT6bkA2lTp3lk2o4ZGk5i DTzPWWQdv8M+QZRz6Da4FZxY2gcaQYqM1Oeb4/Q= X-Received: by 2002:a05:620a:130d:: with SMTP id o13mr6782091qkj.285.1567032993987; Wed, 28 Aug 2019 15:56:33 -0700 (PDT) Date: Wed, 28 Aug 2019 15:55:35 -0700 In-Reply-To: <20190828225535.49592-1-ndesaulniers@google.com> Message-Id: <20190828225535.49592-15-ndesaulniers@google.com> Mime-Version: 1.0 References: <20190828225535.49592-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v3 14/14] compiler_attributes.h: add note about __section 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 Link: https://github.com/ClangBuiltLinux/linux/issues/619 Tested-by: Sedat Dilek Signed-off-by: Nick Desaulniers --- include/linux/compiler_attributes.h | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.23.0.187.g17f5b7556c-goog diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index 6b318efd8a74..f8c008d7f616 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -225,6 +225,16 @@ #define __pure __attribute__((__pure__)) /* + * Note: Since this macro makes use of the "stringification operator" `#`, a + * quoted string literal should not be passed to it. eg. + * prefer: + * __section(.foo) + * to: + * __section(".foo") + * unless the section name is dynamically built up, in which case the + * verbose __attribute__((__section__(".foo" x))) should be preferred. + * See also: https://bugs.llvm.org/show_bug.cgi?id=42950 + * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-section-function-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-section-variable-attribute * clang: https://clang.llvm.org/docs/AttributeReference.html#section-declspec-allocate