From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id DAD933857405 for ; Thu, 12 May 2022 16:52:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DAD933857405 Received: by mail-pj1-x1034.google.com with SMTP id cq17-20020a17090af99100b001dc0386cd8fso5401537pjb.5 for ; Thu, 12 May 2022 09:52:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=huEJEogI45mAXEVW3DIkgUeAJRDuyFa21FSfdzzh0LQ=; b=NEO7JSQSxCyLaeW4Nr2XZ1imRakcKXeRmT6ISTBt2U4DtENTVpbY7tWC8YS3diIHru CvTJNxkdEe0tUIHLgTDyrhYdqYu/riDsE3Abh4lriFeHNcrA6zoY21BlOWbDb+2875xH 7XcSQ2EKVH/TxH23Xc1LXmt7XlEGiuurA4iaFCnQe3isg5MsGnzry3pVDobRGmSitvOB fDTO0FGsJNRWdHRhi/59s7quYB0A7hpzRUBShHoI6GyHvUuq4gjNHeAjdhkdI214o234 auok5cvdMLOvJzvHX9HEa9NkLdzKcDV289H4LGidzCmQELDJ7cLb+xLOwuI62r+zKkS4 wWRA== X-Gm-Message-State: AOAM533ffu3krvjHCpG9zL0A3guB8JyD5ELRwwohSkXe6uJKcGsdXvm8 f02+dsYltbzIfnd0l+5qlGi0eyHe0U0jvg== X-Google-Smtp-Source: ABdhPJx9OiRk7+KC4XDqnoYeUnirA+8nGysF6/3bnvW6LuZY/DI2GPnS3qKOQNwFmcwTmWmzTCRDJw== X-Received: by 2002:a17:902:d541:b0:15e:ba3a:90d2 with SMTP id z1-20020a170902d54100b0015eba3a90d2mr458520plf.11.1652374343823; Thu, 12 May 2022 09:52:23 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:e892:f9c7:57f5:14db]) by smtp.gmail.com with ESMTPSA id s18-20020a170903201200b0015e8d4eb23esm129067pla.136.2022.05.12.09.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 09:52:23 -0700 (PDT) Date: Thu, 12 May 2022 09:52:20 -0700 From: Fangrui Song To: Adhemerval Zanella Cc: libc-alpha@sourceware.org, "H.J. Lu" Subject: Re: [PATCH v2 1/4] Add declare_object_symbol_alias for assembly codes (BZ #28128) Message-ID: <20220512165220.cdiovt4d2zeyv5nv@google.com> References: <20220512125931.523712-1-adhemerval.zanella@linaro.org> <20220512125931.523712-2-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20220512125931.523712-2-adhemerval.zanella@linaro.org> X-Spam-Status: No, score=-26.5 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2022 16:52:26 -0000 On 2022-05-12, Adhemerval Zanella wrote: >From: "H.J. Lu" > >There are 2 problems in: > > #define declare_symbol_alias(symbol, original, type, size) \ > declare_symbol_alias_1 (symbol, original, type, size) > #ifdef __ASSEMBLER__ > # define declare_symbol_alias_1(symbol, original, type, size) \ > strong_alias (original, symbol); \ > .type C_SYMBOL_NAME (symbol), %##type; \ > .size C_SYMBOL_NAME (symbol), size > >1. .type and .size are substituted by arguments. >2. %##type is expanded to "% type" due to the GCC bug: > >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101613 > >But assembler doesn't support "% type". > >Workaround BZ #28128 by > >1. Don't define declare_symbol_alias for assembly codes. >2. Define declare_object_symbol_alias for assembly codes. Interesting. clang -E can expand https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101613 correctly. Reviewed-by: Fangrui Song >--- > include/libc-symbols.h | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > >diff --git a/include/libc-symbols.h b/include/libc-symbols.h >index 662bd118b1..4bb3d8c7ba 100644 >--- a/include/libc-symbols.h >+++ b/include/libc-symbols.h >@@ -324,14 +324,16 @@ for linking") > This is only necessary when defining something in assembly, or playing > funny alias games where the size should be other than what the compiler > thinks it is. */ >-#define declare_symbol_alias(symbol, original, type, size) \ >- declare_symbol_alias_1 (symbol, original, type, size) > #ifdef __ASSEMBLER__ >-# define declare_symbol_alias_1(symbol, original, type, size) \ >- strong_alias (original, symbol); \ >- .type C_SYMBOL_NAME (symbol), %##type; \ >- .size C_SYMBOL_NAME (symbol), size >+# define declare_object_symbol_alias(symbol, original, size) \ >+ declare_object_symbol_alias_1 (symbol, original, size) >+# define declare_object_symbol_alias_1(symbol, original, s_size) \ >+ strong_alias (original, symbol) ASM_LINE_SEP \ >+ .type C_SYMBOL_NAME (symbol), %object ASM_LINE_SEP \ >+ .size C_SYMBOL_NAME (symbol), s_size ASM_LINE_SEP > #else /* Not __ASSEMBLER__. */ >+# define declare_symbol_alias(symbol, original, type, size) \ >+ declare_symbol_alias_1 (symbol, original, type, size) > # define declare_symbol_alias_1(symbol, original, type, size) \ > asm (".globl " __SYMBOL_PREFIX #symbol \ > "\n\t" declare_symbol_alias_1_alias (symbol, original) \ >-- >2.34.1 >