From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id D1D2F3858C00 for ; Sat, 30 Jul 2022 03:13:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D1D2F3858C00 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from [10.20.4.52] (unknown [10.20.4.52]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxCeHGoeRi1sFDAA--.30840S2; Sat, 30 Jul 2022 11:13:11 +0800 (CST) Subject: Re: [PATCH v3] LoongArch: add addr_global attribute To: Xi Ruoyao , gcc-patches@gcc.gnu.org Cc: Jinyang He , xuchenghua@loongson.cn, Huacai Chen , Youling Tang , Wang Xuerui References: <9b6b0e68cfb7e87ae961ef8a7bb7987f534da19c.camel@xry111.site> From: Lulu Cheng Message-ID: <285f23f7-55d6-e185-dbd9-f69ed09e4286@loongson.cn> Date: Sat, 30 Jul 2022 11:13:10 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <9b6b0e68cfb7e87ae961ef8a7bb7987f534da19c.camel@xry111.site> Content-Language: en-US X-CM-TRANSID: AQAAf9AxCeHGoeRi1sFDAA--.30840S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KF1UXryDWrW3CrWfArWDurg_yoW8Ww1xpF ZIgFW5Kr45Ja1v9a1kA3WxWry0gw4UGr9xJrn5tw47Za42v3srZF1jka1aqFZFqr9Ygw42 q3yjvr17ta45Z37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvI14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr 0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21lYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0E x4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwACjI8F5V A0II8E6IAqYI8I648v4I1l7480Y4vEI4kI2Ix0rVAqx4xJMxk0xIA0c2IEe2xFo4CEbIxv r21lc2xSY4AK6svPMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I 0E5I8CrVAFwI0_JrI_JrWlx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWU AVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcV CY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv 67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf 9x0JUtkuxUUUUU= X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HTML_MESSAGE, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jul 2022 03:13:20 -0000 在 2022/7/30 上午1:17, Xi Ruoyao 写道: > Change v2 to v3: > - Disable section anchor for addr_global symbols. > - Use -O2 in test to make sure section anchor is disabled. > > -- > > Background: > https://lore.kernel.org/loongarch/d7670b60-2782-4642-995b-7baa01779a66@loongson.cn/T/#e1d47e2fe185f2e2be8fdc0784f0db2f644119379 > > Question: Do you have a better name than "addr_global"? I think the name can be changed to "get_through_got".What do you think of it? > > Alternatives: > > 1. Just use "-mno-explicit-relocs -mla-local-with-abs" for kernel > modules. It's stupid IMO. > 2. Implement a "-maddress-local-with-got" option for GCC and use it for > kernel modules. It seems too overkill: we might create many unnecessary > GOT entries. > 3. For all variables with a section attribute, consider it global. It > may make sense, but I just checked x86_64 and riscv and they don't do > this. > 4. Implement -mcmodel=extreme and use it for kernel modules. To me > "extreme" seems really too extreme. > 5. More hacks in kernel. (Convert relocations against .data..percpu with > objtool? But objtool is not even implemented for LoongArch yet.) > > Note: I'll be mostly AFK in the following week. My attempt to finish > the kernel support for new relocs before going AFK now failed miserably > :(. > > -- >8 -- > > A linker script and/or a section attribute may locate a local object in > some way unexpected by the code model, leading to a link failure. This > happens when the Linux kernel loads a module with "local" per-CPU > variables. > > Add an attribute to explicitly mark an variable with the address > unlimited by the code model so we would be able to work around such > problems. > Others I think are ok.