Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3779008pxy; Mon, 26 Apr 2021 09:31:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzorXizzdeDpiFQMQNdbB+Imu5TM0/NUvV5Am8V61LYmsU7Mh3f3sCqDNvTUl2FFJTibwTh X-Received: by 2002:a63:4559:: with SMTP id u25mr214743pgk.93.1619454671165; Mon, 26 Apr 2021 09:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619454671; cv=none; d=google.com; s=arc-20160816; b=dIHDLBsVCcAscixAABOq1veMKXYzQijgGBtRjO4ZkqdUpEGIDnOy4BEjGI+enirn8W MshJz7AtVadZKsuHNxmQkl5A6zfIX78UDfGB3KgZNs04H3KAxsAUIJ7p/JM+Fp6CuJrJ Goad/lJxSieqjgbkAzhZK3Yz7x0iFf/+wl8xEXEBbYuNp2FMbyAnzxzRR/W/uqHh+5Zm 7HRtcXY95XWsnWA0rqMjDjZP802YLH1imuv+S0PpzfciU9yP2h0vaq3vTy3hRKHoLtNU i3/qCIjh4zp4Tm3lhECNciS9vlmvia2L0pNFpC1Sz/wfUNaMzwb64ea1wzqj5YjlQmE5 Vo3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=qwJB76TBNHkWENBY8Fsauk6AZ+kOn0Ka4OvKB1fagVk=; b=gmGzr/8ceAyyUciYJJaxwfDhOxTSoOOAMcSuqN2rcQhwVV9QIXmbhmwPT3tzy8hxNx O4ofwqEvBpENYIo1j78HsXFPF6rNQM/yHQgcAqIhxYHVEJGXRct38A7ZTfz1TU/oey+H 0EsNJhlUBKQML/7L+lY2vnxaW7f8TwGJVYfHkurr9xB4tGAQDpdI35eDL18PnBbhRadt 1RJwREiJ2p5VHtnCp99rTt2j9OLu+Xv4Zw2WGucFOGQQiwKyzgFVIbVsWE+mgoALmkxh pqPGdXYjb4BI2xWtZmBsZA9oEpEUzGvPh4xEIHwWW2ITwazFOZ0gN68jDrd/vBxr0HN4 aEoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Ub/EN49m"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-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. [23.128.96.18]) by mx.google.com with ESMTP id d15si192821pjr.171.2021.04.26.09.30.49; Mon, 26 Apr 2021 09:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Ub/EN49m"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-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 S234365AbhDZQbK (ORCPT + 99 others); Mon, 26 Apr 2021 12:31:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234108AbhDZQbJ (ORCPT ); Mon, 26 Apr 2021 12:31:09 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D6A3C061574 for ; Mon, 26 Apr 2021 09:30:28 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id t2-20020a6344420000b02901fc26d75405so18071553pgk.20 for ; Mon, 26 Apr 2021 09:30:28 -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=qwJB76TBNHkWENBY8Fsauk6AZ+kOn0Ka4OvKB1fagVk=; b=Ub/EN49mU2BOHY5wVySpTczmneT9YBqKLpTak1v8liVsYTdbnVI40kYVFsCSGRpaZ8 Jm3BKSRr6fk/gdivQqOyBtcoFuiXkx2paYyEidOmh92hfj7m6d/CnhG5TFen9UcUpgJY 53HCFWpDlDzCXzcFqSI01u3eOPGFYsUMaYnePqxSsGet2cEH8OO1urZg4CRXa3CN+YaA XaHkFDKqHCQGSB5APQtszArOouhiDTEnjeSW1rO6IlIg2KeNxKLI2jeEfMFLyQzMhODS vc1u1IMdEb9OgoTFMavIEX4sQl1SreaXnWAWzXm2VUcC70ATe5Q8CFIEp2RpPsc2hQO0 x9lA== 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=qwJB76TBNHkWENBY8Fsauk6AZ+kOn0Ka4OvKB1fagVk=; b=no/vRZDcnwmoIv6lOlaHwh336aslLNiDooVblIKAht75zXV3xDJJQdkmltN7TIuoRS cft7AavE8ybLTSc4I/SA2OjhUyFrcjglyXs2PW4gspgPu+h6NyBf0Q54UIGwnsH3D1R5 R2odIgXqzo5eTE6NjWZcRRkFCmNgLjAu59QzpbZEtApOu6SfYK5jZpG8xHBujCCKYIbf q5XFlsNGAvfAtJxiT8TLwwpheUMirkWHQnsV267NX05B9SsVPBXMIgYzc96Kl+uEENx8 wZaUgioeaXAUucEkJom0hNbv1jSyhHaHr0+YKEG3wSrWS8B2zIwJoz2Zyx9shNpYU2kb KVeg== X-Gm-Message-State: AOAM532wqCIIUo7CWig+94V0jxrQPGOhUrnzuTujplJ0SsWg6XyZaqPO 69lAqJJXyi5PoG4Dz+xujwwmwIR+v/kPRrlM X-Received: from manoj.svl.corp.google.com ([2620:15c:2ce:0:2b5d:c38b:f03d:9410]) (user=manojgupta job=sendgmr) by 2002:a17:90a:730c:: with SMTP id m12mr23423979pjk.111.1619454627559; Mon, 26 Apr 2021 09:30:27 -0700 (PDT) Date: Mon, 26 Apr 2021 09:30:21 -0700 In-Reply-To: <20210422182545.726897-1-manojgupta@google.com> Message-Id: <20210426163021.3594482-1-manojgupta@google.com> Mime-Version: 1.0 References: <20210422182545.726897-1-manojgupta@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH v2] iw: set retain atrribute on sections From: Manoj Gupta To: Johannes Berg , Johannes Berg Cc: llozano@google.com, manojgupta@google.com, linux-wireless@vger.kernel.org, Fangrui Song , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org LLD 13 and GNU ld 2.37 support -z start-stop-gc which allows garbage collection of C identifier name sections despite the __start_/__stop_ references. Simply set the retain attribute so that GCC 11 (if configure-time binutils is 2.36 or newer)/Clang 13 will set the SHF_GNU_RETAIN section attribute to prevent garbage collection. Without the patch, there are linker errors like the following with -z start-stop-gc: ld.lld: error: undefined symbol: __stop___cmd >>> referenced by iw.c:418 >>> iw.o:(__handle_cmd) Suggested-by: Fangrui Song Cc: stable@vger.kernel.org Signed-off-by: Manoj Gupta --- Changes v1 -> v2: Apply the retain attribute to all places with attribute used. iw.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/iw.h b/iw.h index 7f7f4fc..8ca8e44 100644 --- a/iw.h +++ b/iw.h @@ -118,8 +118,9 @@ struct chandef { .parent = _section, \ .selector = (_sel), \ }; \ + _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ static struct cmd *__cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden ## _p \ - __attribute__((used,section("__cmd"))) = \ + __attribute__((used,retain,section("__cmd"))) = \ &__cmd ## _ ## _symname ## _ ## _handler ## _ ## _nlcmd ## _ ## _idby ## _ ## _hidden #define __ACMD(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel, _alias)\ __COMMAND(_section, _symname, _name, _args, _nlcmd, _flags, _hidden, _idby, _handler, _help, _sel);\ @@ -141,16 +142,18 @@ struct chandef { .handler = (_handler), \ .help = (_help), \ }; \ + _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ static struct cmd *__section ## _ ## _name ## _p \ - __attribute__((used,section("__cmd"))) = &__section ## _ ## _name + __attribute__((used,retain,section("__cmd"))) = &__section ## _ ## _name #define SECTION(_name) \ struct cmd __section ## _ ## _name = { \ .name = (#_name), \ .hidden = 1, \ }; \ + _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ static struct cmd *__section ## _ ## _name ## _p \ - __attribute__((used,section("__cmd"))) = &__section ## _ ## _name + __attribute__((used,retain,section("__cmd"))) = &__section ## _ ## _name #define DECLARE_SECTION(_name) \ extern struct cmd __section ## _ ## _name; @@ -162,13 +165,14 @@ struct vendor_event { }; #define VENDOR_EVENT(_id, _subcmd, _callback) \ + _Pragma("GCC diagnostic ignored \"-Wattributes\"") \ const struct vendor_event \ vendor_event_ ## _id ## _ ## _subcmd = { \ .vendor_id = _id, \ .subcmd = _subcmd, \ .callback = _callback, \ }, * const vendor_event_ ## _id ## _ ## _subcmd ## _p \ - __attribute__((used,section("vendor_event"))) = \ + __attribute__((used,retain,section("vendor_event"))) = \ &vendor_event_ ## _id ## _ ## _subcmd extern const char iw_version[]; -- 2.31.1.498.g6c1eba8ee3d-goog