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 D6A973858C60 for ; Mon, 20 Sep 2021 10:35:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D6A973858C60 Received: from localhost.localdomain (localhost [127.0.0.1]) (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 32C38661A2; Mon, 20 Sep 2021 06:35:47 -0400 (EDT) Message-ID: Subject: Re: gcc sections From: Xi Ruoyao To: Giacomo Dal Sasso , "gcc-help@gcc.gnu.org" Date: Mon, 20 Sep 2021 18:35:46 +0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3031.7 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-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Sep 2021 10:35:52 -0000 On Mon, 2021-09-20 at 09:50 +0000, Giacomo Dal Sasso wrote: > Hi, > > I'm compiling some bare metal code for a risc-v core using gcc. > I see before the linking stage the object file generated contains .sbss > and .srodata sections. > I expected .bss and .rodata sections. > Where I can find documentation of these sections and in general about > sections generated by gcc before the linking stage ? > I mean, linker script maps input sections in output sections but who are > and what data contains input section gcc provide to the linker ? (.data > .bss .rodata .text). > I know what those sections contain but I'm looking for official > documentation. Some architectures (for e.g. MIPS, RISC-V, and IA64) have a special register called "global pointer" (GP). The content of .sbss, .sdata, and .srodata will be put into the data area available by GP-relative addressing, so it's possible to use less instructions to load the data in those sections. For MIPS and IA64, the rationale of .sbss is documented in their ELF psABI. But the RISC-V psABI doesn't mention .sbss at all. I think it's problematic but I don't use RISC-V anyway. Maybe you can raise an issue in https://github.com/riscv-non-isa/riscv-elf-psabi-doc/ and convince them to make an explanation. -- Xi Ruoyao School of Aerospace Science and Technology, Xidian University