From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from spam02.hesby.net (spam01.hesby.net [81.29.32.152]) by sourceware.org (Postfix) with ESMTP id 13E193858D28 for ; Sat, 26 Feb 2022 18:57:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 13E193858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hesbynett.no Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hesbynett.no Received: from [192.168.4.227] (247.92-221-34.customer.lyse.net [92.221.34.247]) by spam02.hesby.net (Halon) with ESMTPSA id e0c44be9-9735-11ec-920b-506b8dfa0e58; Sat, 26 Feb 2022 19:57:00 +0100 (CET) Subject: Re: Constant at fixed address To: Henrique Coser , Martin Sebor , "gcc-help@gcc.gnu.org" References: <723b5ea5-7cbb-a36e-0734-9cae443eda70@gmail.com> From: David Brown Message-ID: <16a27a10-fef4-c561-a01a-dbd3a03d1e8f@hesbynett.no> Date: Sat, 26 Feb 2022 19:57:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3033.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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: Sat, 26 Feb 2022 18:57:03 -0000 On 25/02/2022 22:37, Henrique Coser wrote: > Martin and David, thank you for your answers. > > Attached is the linker script that I use. > > In Keil, where I did the first version of the boot loader I can assure you that a constant value is placed and correctly filled when use __attribute__((at(0x0401000))) > I don't know how they do this but they do! > > I would be grateful If you could help me editting this script. > > Thank you very much. > > The length of your "rom" space in sam3s4b_flash.ld does not make much sense. I haven't used Atmel's SAM devices, but I'd be surprised to see one with a little under 12 K flash. The linker files you attached are not, I think, the ones you used when you got the link error - they don't have any mention of the ".bootversion" section. So all I can do is show a typical way to have this set up in a linker file. Your "rom" section starts with : .text : { . = ALIGN(4); _sfixed = .; KEEP(*(.vectors .vectors.*)) *(.text .text.* .gnu.linkonce.t.*) ... } > rom That will put the ".vectors" section(s) first, at the start of rom, then everything after it. What you need to have is the fixed sections, then everything that can be freely allocated: .headers : { FILL(0xff) . = ALIGN(4); _sfixed = .; KEEP(*(.vectors .vectors.*)) . = 0x1000; KEEP(*(.bootversion .bootversion.*)) } > rom .text : { . = ALIGN(4); *(.text .text.* .gnu.linkonce.t.*) ... } > rom Then the main ".text" and other flash sections get put after the bootversion section, and you don't get an overlap. This wastes the space between the vectors and the fixed .bootversion section, but you could put other data there if you like (maybe some of the arrays used for constructors or initialisation). Don't bother unless you are tight for space.