From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mengyan1223.wang (mengyan1223.wang [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 4B12D3858D28 for ; Sat, 18 Dec 2021 17:53:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4B12D3858D28 Received: from [IPv6:240e:358:1145:f700:9fab:c7ca:145a:d653] (unknown [IPv6:240e:358:1145:f700:9fab:c7ca:145a:d653]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@mengyan1223.wang) by mengyan1223.wang (Postfix) with ESMTPSA id 504536598B; Sat, 18 Dec 2021 12:53:28 -0500 (EST) Message-ID: Subject: Re: [PATCH v3 04/12] LoongArch Port: Machine description C files and .h files. From: Xi Ruoyao To: Chenghua Xu , gcc-patches@gcc.gnu.org Cc: yangyujie@loongson.cn, chenglulu@loongson.cn Date: Sun, 19 Dec 2021 01:53:21 +0800 In-Reply-To: <20211210074359.988056-5-xuchenghua@loongson.cn> References: <20211210074359.988056-1-xuchenghua@loongson.cn> <20211210074359.988056-5-xuchenghua@loongson.cn> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3031.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, JMQ_SPF_NEUTRAL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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, 18 Dec 2021 17:53:34 -0000 On Fri, 2021-12-10 at 15:43 +0800, Chenghua Xu wrote: > +#undef TARGET_ASM_CODE_END > +#define TARGET_ASM_CODE_END loongarch_code_end /* snip */ > +static void > +loongarch_code_end (void) > +{ > + if (NEED_INDICATE_EXEC_STACK) > + /* Add .note.GNU-stack. */ > + file_end_indicate_exec_stack (); > +} > + Hi Chenghua, I think this should be put into TARGET_ASM_FILE_END (like how MIPS and ARM port do this) instead of TARGET_ASM_CODE_END. Consider compiling a "hello world" program with -flto -g: $ loongarch64-linux-gnu-gcc hw.c -flto -g During the LTO pass, a file containing debug info named "a- hw.o.debug.temp.o" is created. This file does not contain any code. But .note.GNU-stack should still be emitted into it, or when it's linked into a.out, a.out will have executable stack which is bad for security. Now I get 650 files in /usr/bin with executable stack in my 5th Linux >From Scratch build on LoongArch! Will start over and do 6th. -- Xi Ruoyao School of Aerospace Science and Technology, Xidian University