Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

I put up my thumb... and it blotted out the planet Earth. -- Neil Armstrong


devel / comp.arch.embedded / Re: gcc: NOLOAD and .noinit

SubjectAuthor
* gcc: NOLOAD and .noinitpozz
+* Re: gcc: NOLOAD and .noinitDavid Brown
|`* Re: gcc: NOLOAD and .noinitpozz
| `- Re: gcc: NOLOAD and .noinitDavid Brown
+* Re: gcc: NOLOAD and .noinitHans-Bernhard Bröker
|`* Re: gcc: NOLOAD and .noinitpozz
| `- Re: gcc: NOLOAD and .noinitTauno Voipio
`- Re: gcc: NOLOAD and .noinitKent Dickey

1
gcc: NOLOAD and .noinit

<t13v61$b72$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=836&group=comp.arch.embedded#836

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: pozzu...@gmail.com (pozz)
Newsgroups: comp.arch.embedded
Subject: gcc: NOLOAD and .noinit
Date: Sat, 19 Mar 2022 08:02:23 +0100
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <t13v61$b72$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Mar 2022 07:02:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="45f8288871b0e996764f1cb87d2d5718";
logging-data="11490"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wK7lRhKhdkL5tySU3laNvyOf5kz6KC30="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:RFPoJC+BZVRtKf1fVirZiI/qCuE=
 by: pozz - Sat, 19 Mar 2022 07:02 UTC

I usually don't touch linker script of my development system, sincerely
I can't read every details of a linker script, so I'm in trouble now.

As explained in my previous post, I need to avoid zeroing a static big
variable, because it is allocated in SDRAM and SDRAM isn't available
when zeroing of bss sections (and initialization of data sections) occurs.

My development system allows me to use .noinit section, so I'm studying
how it works.

MCUXpresso IDE generates complete linker scripts that automatically
manages .noinit sections. These sections aren't added to section table
that startup code reads to reset sections of RAM.

What I don't understand is the presence of NOLOAD directive in the
linker script:

[...]
The linker will process the section normally, but will
mark it so that a program loader will not load it into
memory.

In embedded systems we don't have program loader, at least in my case
there isn't any program loader. Code and constant variables are already
at the right addresses at startup (Flash is already written). Only
variables that changes at runtime must be initialized in RAM, but this
is done by startup code, not by a program loader.

So, if startup code doesn't reset .noinit sections (because they aren't
added in bss section table by the linker script), what's the exact
purpose of NOLOAD directive?

I was tempted to remove NOLOAD directive from the linker script
generated by MCUXpresso, but it re-generates it at every build.

Re: gcc: NOLOAD and .noinit

<t14bi6$c07$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=837&group=comp.arch.embedded#837

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch.embedded
Subject: Re: gcc: NOLOAD and .noinit
Date: Sat, 19 Mar 2022 11:33:41 +0100
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <t14bi6$c07$1@dont-email.me>
References: <t13v61$b72$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Mar 2022 10:33:42 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c5adcdfafd2ebc60801594841d7fe9b9";
logging-data="12295"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SOEF+uoqpJ/69k4y7Qc7DijzJngdrX5M="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:oik4Mwsz/zrew3Nxo4m/REVr1T4=
In-Reply-To: <t13v61$b72$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Sat, 19 Mar 2022 10:33 UTC

On 19/03/2022 08:02, pozz wrote:
> I usually don't touch linker script of my development system, sincerely
> I can't read every details of a linker script, so I'm in trouble now.
>
> As explained in my previous post, I need to avoid zeroing a static big
> variable, because it is allocated in SDRAM and SDRAM isn't available
> when zeroing of bss sections (and initialization of data sections) occurs.
>
> My development system allows me to use .noinit section, so I'm studying
> how it works.
>
> MCUXpresso IDE generates complete linker scripts that automatically
> manages .noinit sections. These sections aren't added to section table
> that startup code reads to reset sections of RAM.
>
> What I don't understand is the presence of NOLOAD directive in the
> linker script:
>
>     [...]
>     The linker will process the section normally, but will
>     mark it so that a program loader will not load it into
>     memory.
>
> In embedded systems we don't have program loader, at least in my case
> there isn't any program loader. Code and constant variables are already
> at the right addresses at startup (Flash is already written). Only
> variables that changes at runtime must be initialized in RAM, but this
> is done by startup code, not by a program loader.
>
> So, if startup code doesn't reset .noinit sections (because they aren't
> added in bss section table by the linker script), what's the exact
> purpose of NOLOAD directive?
>
> I was tempted to remove NOLOAD directive from the linker script
> generated by MCUXpresso, but it re-generates it at every build.
>

"NOLOAD" basically means the section is not part of the binary image
that gets loaded to the device - such as by jtag download or other
programs that use the "elf" file. When you use objcopy to generate
".hex" or ".bin" files, NOLOAD sections are omitted (unless you go out
of your way to include them). For the commonly used sections, both
".bss" and ".noinit" sections will be marked "NOLOAD", whereas ".text",
".readonly" and ".data" sections will be "LOAD". (Variables in the
".data" sections have two sets of addresses - their "load" addresses for
the address in flash or other images of the initial value, and their
"link" addresses for their run-time variable address.)

Re: gcc: NOLOAD and .noinit

<j9lu4oFemsdU1@mid.dfncis.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=838&group=comp.arch.embedded#838

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail
From: HBBroe...@t-online.de (Hans-Bernhard Bröker)
Newsgroups: comp.arch.embedded
Subject: Re: gcc: NOLOAD and .noinit
Date: Sat, 19 Mar 2022 12:46:26 +0100
Lines: 44
Message-ID: <j9lu4oFemsdU1@mid.dfncis.de>
References: <t13v61$b72$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.dfncis.de AqiaAWlN2SecT3/qahce6gTpBfUp3Z5MqmjRWoCb8c99L5qJFe9AG+5R5o
Cancel-Lock: sha1:BSRnjLa1zP1qsQJ9L3gQHPtlmBM=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-US
In-Reply-To: <t13v61$b72$1@dont-email.me>
 by: Hans-Bernhard Bröke - Sat, 19 Mar 2022 11:46 UTC

Am 19.03.2022 um 08:02 schrieb pozz:

> In embedded systems we don't have program loader, at least in my case
> there isn't any program loader.

There is a loader; it's just not running on the target. A linker for an
embedded target is actually three tools in one, which traditionally
where thought of as separate: the actual linker, the locator, and (part
of) the loader.

The linker proper just has the job of connecting symbols referenced by
some modules, to matching symbol definitions in other modules.

The next phase, the locator, positions the resulting sections where they
have to go in available memory, and resolves symbolic addresses to
actual places in target memory space.

The job of the loader is split between the tool we usually just call a
linker, the raw/hex file extraction tool, flash programmers, and the
debugger. They share the job of moving the contents of the code and
data sections from the locator's output into actual target memory.

To that end the locator has to mark which sections the loader should
load, and which it doesn't have to handle. That's kept as a "LOAD"
attribute you can find, e.g. in the section headers of the generated ELF
file. You can inspect these attributes by 'objdump -h'. BSS-style
sections never get the LOAD attribute, because they're not part of the
program image that the flasher or debugger has to transfer to the
hardware --- they only exist at run-time.

Desktop linkers, OTOH, will usually perform just parts of those three
phases, depending on the type of executable and operating environment.
E.g. linking an MS-DOS "COM" program does almost all of it, leaving out
only the actual transfer from disk to memory. That's almost exactly
what an embedded linker usually does.

If instead you build an MS-DOS EXE file, it stops early in the locator
phase, leaving the task of placing the sections in memory, and the bulk
of replacing virtual addresses by actual ones to DOS. The file on disk
is a collection of memory sections to be loaded, and recipes for
patching up references from one to the other (called "relocations"). A
linker producing a typical program for, e.g. Windows or Linux does not
even fully complete the linker stage, because it cannot finally resolve
links to dynamically linked, shared libraries.

Re: gcc: NOLOAD and .noinit

<t14sbr$em8$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=840&group=comp.arch.embedded#840

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: pozzu...@gmail.com (pozz)
Newsgroups: comp.arch.embedded
Subject: Re: gcc: NOLOAD and .noinit
Date: Sat, 19 Mar 2022 16:20:27 +0100
Organization: A noiseless patient Spider
Lines: 97
Message-ID: <t14sbr$em8$1@dont-email.me>
References: <t13v61$b72$1@dont-email.me> <t14bi6$c07$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Mar 2022 15:20:27 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="45f8288871b0e996764f1cb87d2d5718";
logging-data="15048"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WTvBQF/xvYJKxQbTxQglWp2Qhqq2iHkU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:BteQNBPfINRKRDZacjumOTJr8RU=
In-Reply-To: <t14bi6$c07$1@dont-email.me>
 by: pozz - Sat, 19 Mar 2022 15:20 UTC

Il 19/03/2022 11:33, David Brown ha scritto:
> On 19/03/2022 08:02, pozz wrote:
>> I usually don't touch linker script of my development system, sincerely
>> I can't read every details of a linker script, so I'm in trouble now.
>>
>> As explained in my previous post, I need to avoid zeroing a static big
>> variable, because it is allocated in SDRAM and SDRAM isn't available
>> when zeroing of bss sections (and initialization of data sections) occurs.
>>
>> My development system allows me to use .noinit section, so I'm studying
>> how it works.
>>
>> MCUXpresso IDE generates complete linker scripts that automatically
>> manages .noinit sections. These sections aren't added to section table
>> that startup code reads to reset sections of RAM.
>>
>> What I don't understand is the presence of NOLOAD directive in the
>> linker script:
>>
>>     [...]
>>     The linker will process the section normally, but will
>>     mark it so that a program loader will not load it into
>>     memory.
>>
>> In embedded systems we don't have program loader, at least in my case
>> there isn't any program loader. Code and constant variables are already
>> at the right addresses at startup (Flash is already written). Only
>> variables that changes at runtime must be initialized in RAM, but this
>> is done by startup code, not by a program loader.
>>
>> So, if startup code doesn't reset .noinit sections (because they aren't
>> added in bss section table by the linker script), what's the exact
>> purpose of NOLOAD directive?
>>
>> I was tempted to remove NOLOAD directive from the linker script
>> generated by MCUXpresso, but it re-generates it at every build.
>>
>
> "NOLOAD" basically means the section is not part of the binary image
> that gets loaded to the device - such as by jtag download or other
> programs that use the "elf" file. When you use objcopy to generate
> ".hex" or ".bin" files, NOLOAD sections are omitted (unless you go out
> of your way to include them).

So NOLOAD is just an "attribute" of a section, but doesn't change
allocation and addresses computed by the linker, isn't it?

This attribute is used by JTAG programmer that will avoid programming
sections marked as NOLOAD.
However this arises another question. What about .bss sections? They are
in RAM, but they shouldn't be "loaded" by the programmer (they will be
zeroed during startup code). How the JTAG/SWD probe know .bss sections
shouldn't be loaded?

> For the commonly used sections, both
> ".bss" and ".noinit" sections will be marked "NOLOAD",

Really? In my case .bss sections aren't marked as NOLOAD (from this my
previous question).

/* MAIN BSS SECTION */
.bss : ALIGN(4)
{
_bss = .;
PROVIDE(__start_bss_RAM = .) ;
PROVIDE(__start_bss_SRAM_UPPER = .) ;
*(.bss*)
*(COMMON)
. = ALIGN(4) ;
_ebss = .;
PROVIDE(__end_bss_RAM = .) ;
PROVIDE(__end_bss_SRAM_UPPER = .) ;
PROVIDE(end = .);
} > SRAM_UPPER AT> SRAM_UPPER

I think there's a big difference between .bss and .data sections: .data
sections are associated to real data (numbers that are init values for
that part of memory). These numbers are present and written in the
output executable object file.

On the contrary, .bss sections aren't associated to concrete numbers,
because they are uninitialized (they will be simply zeroed by startup code).

If a .data section has an address, a size and some numbers, .bss has
only an address and a size.

So this could be the reason why my build system doesn't use NOLOAD for
..bss sections: a JTAG programmer will skip loading/programming of .bss
sections, because there aren't any numbers to write for them.

> whereas ".text",
> ".readonly" and ".data" sections will be "LOAD". (Variables in the
> ".data" sections have two sets of addresses - their "load" addresses for
> the address in flash or other images of the initial value, and their
> "link" addresses for their run-time variable address.)

Re: gcc: NOLOAD and .noinit

<t14sp4$i2g$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=841&group=comp.arch.embedded#841

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: pozzu...@gmail.com (pozz)
Newsgroups: comp.arch.embedded
Subject: Re: gcc: NOLOAD and .noinit
Date: Sat, 19 Mar 2022 16:27:33 +0100
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <t14sp4$i2g$1@dont-email.me>
References: <t13v61$b72$1@dont-email.me> <j9lu4oFemsdU1@mid.dfncis.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Mar 2022 15:27:32 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="45f8288871b0e996764f1cb87d2d5718";
logging-data="18512"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/z39R0GCGSV/gNCOoXEK2VC/SHU7VXsJk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:3g/QhLwhCb/uJuX0iawX22Jkybg=
In-Reply-To: <j9lu4oFemsdU1@mid.dfncis.de>
 by: pozz - Sat, 19 Mar 2022 15:27 UTC

Il 19/03/2022 12:46, Hans-Bernhard Bröker ha scritto:
> Am 19.03.2022 um 08:02 schrieb pozz:
>
>> In embedded systems we don't have program loader, at least in my case
>> there isn't any program loader.
>
> There is a loader; it's just not running on the target.  A linker for an
> embedded target is actually three tools in one, which traditionally
> where thought of as separate: the actual linker, the locator, and (part
> of) the loader.
>
> The linker proper just has the job of connecting symbols referenced by
> some modules, to matching symbol definitions in other modules.
>
> The next phase, the locator, positions the resulting sections where they
> have to go in available memory, and resolves symbolic addresses to
> actual places in target memory space.
>
> The job of the loader is split between the tool we usually just call a
> linker, the raw/hex file extraction tool, flash programmers, and the
> debugger.  They share the job of moving the contents of the code and
> data sections from the locator's output into actual target memory.
>
> To that end the locator has to mark which sections the loader should
> load, and which it doesn't have to handle.  That's kept as a "LOAD"
> attribute you can find, e.g. in the section headers of the generated ELF
> file.  You can inspect these attributes by 'objdump -h'.  BSS-style
> sections never get the LOAD attribute, because they're not part of the
> program image that the flasher or debugger has to transfer to the
> hardware --- they only exist at run-time.

You're right, .bss has only ALLOC attribute, while .text and .data have
LOAD attribute too.

It's strange because, as I wrote to David, my linker script doesn't use
NOLOAD for .bss sections.

> Desktop linkers, OTOH, will usually perform just parts of those three
> phases, depending on the type of executable and operating environment.
> E.g. linking an MS-DOS "COM" program does almost all of it, leaving out
> only the actual transfer from disk to memory.  That's almost exactly
> what an embedded linker usually does.
>
> If instead you build an MS-DOS EXE file, it stops early in the locator
> phase, leaving the task of placing the sections in memory, and the bulk
> of replacing virtual addresses by actual ones to DOS.  The file on disk
> is a collection of memory sections to be loaded, and recipes for
> patching up references from one to the other (called "relocations").  A
> linker producing a typical program for, e.g. Windows or Linux does not
> even fully complete the linker stage, because it cannot finally resolve
> links to dynamically linked, shared libraries.

Thank you for wasting your time for this description of loaders.

Re: gcc: NOLOAD and .noinit

<t14u1e$t1u$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=842&group=comp.arch.embedded#842

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch.embedded
Subject: Re: gcc: NOLOAD and .noinit
Date: Sat, 19 Mar 2022 16:49:02 +0100
Organization: A noiseless patient Spider
Lines: 133
Message-ID: <t14u1e$t1u$1@dont-email.me>
References: <t13v61$b72$1@dont-email.me> <t14bi6$c07$1@dont-email.me>
<t14sbr$em8$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Mar 2022 15:49:02 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="19800427afa2e30c565e80ecc60bb36f";
logging-data="29758"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qcxFP4sWs32+52F4RvTyS3dUJ+GIe5kU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:/EdgjAq8ULvCcBaEsZBY6L+56ao=
In-Reply-To: <t14sbr$em8$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Sat, 19 Mar 2022 15:49 UTC

On 19/03/2022 16:20, pozz wrote:
> Il 19/03/2022 11:33, David Brown ha scritto:
>> On 19/03/2022 08:02, pozz wrote:
>>> I usually don't touch linker script of my development system, sincerely
>>> I can't read every details of a linker script, so I'm in trouble now.
>>>
>>> As explained in my previous post, I need to avoid zeroing a static big
>>> variable, because it is allocated in SDRAM and SDRAM isn't available
>>> when zeroing of bss sections (and initialization of data sections)
>>> occurs.
>>>
>>> My development system allows me to use .noinit section, so I'm studying
>>> how it works.
>>>
>>> MCUXpresso IDE generates complete linker scripts that automatically
>>> manages .noinit sections. These sections aren't added to section table
>>> that startup code reads to reset sections of RAM.
>>>
>>> What I don't understand is the presence of NOLOAD directive in the
>>> linker script:
>>>
>>>      [...]
>>>      The linker will process the section normally, but will
>>>      mark it so that a program loader will not load it into
>>>      memory.
>>>
>>> In embedded systems we don't have program loader, at least in my case
>>> there isn't any program loader. Code and constant variables are already
>>> at the right addresses at startup (Flash is already written). Only
>>> variables that changes at runtime must be initialized in RAM, but this
>>> is done by startup code, not by a program loader.
>>>
>>> So, if startup code doesn't reset .noinit sections (because they aren't
>>> added in bss section table by the linker script), what's the exact
>>> purpose of NOLOAD directive?
>>>
>>> I was tempted to remove NOLOAD directive from the linker script
>>> generated by MCUXpresso, but it re-generates it at every build.
>>>
>>
>> "NOLOAD" basically means the section is not part of the binary image
>> that gets loaded to the device - such as by jtag download or other
>> programs that use the "elf" file.  When you use objcopy to generate
>> ".hex" or ".bin" files, NOLOAD sections are omitted (unless you go out
>> of your way to include them). 
>
> So NOLOAD is just an "attribute" of a section, but doesn't change
> allocation and addresses computed by the linker, isn't it?
>

Correct.

> This attribute is used by JTAG programmer that will avoid programming
> sections marked as NOLOAD.
> However this arises another question. What about .bss sections? They are
> in RAM, but they shouldn't be "loaded" by the programmer (they will be
> zeroed during startup code). How the JTAG/SWD probe know .bss sections
> shouldn't be loaded?

You could always look at the manual:

<https://sourceware.org/binutils/docs/ld/Output-Section-Type.html>

".bss" sections will already be marked "NOLOAD" by the compiler. But
your new ".noinit" sections are not standard compiler-generated
sections, and probably default to normal loaded sections.

>
>
>> For the commonly used sections, both
>> ".bss" and ".noinit" sections will be marked "NOLOAD",
>
> Really? In my case .bss sections aren't marked as NOLOAD (from this my
> previous question).

They will be marked NOLOAD in their input sections in the object file,
so the output section does not need to be marked explicitly in the
linker file. It would do no harm to mark it as such.

You can see the attributes of the input sections by using "objdump -h"
on the object file. There you'll see ".text" sections marked as
"CONTENTS, ALLOC, LOAD, READONLY, CODE", ".data" sections as "CONTENTS,
ALLOC, LOAD, DATA", and ".bss" sections as "ALLOC". A manually
specified ".noinit" section will likely be marked like ".data" sections,
so you want to add the "NOLOAD" flag explicitly in the linker file.

>
>     /* MAIN BSS SECTION */
>     .bss : ALIGN(4)
>     {
>         _bss = .;
>         PROVIDE(__start_bss_RAM = .) ;
>         PROVIDE(__start_bss_SRAM_UPPER = .) ;
>         *(.bss*)
>         *(COMMON)
>         . = ALIGN(4) ;
>         _ebss = .;
>         PROVIDE(__end_bss_RAM = .) ;
>         PROVIDE(__end_bss_SRAM_UPPER = .) ;
>         PROVIDE(end = .);
>     } > SRAM_UPPER AT> SRAM_UPPER
>
> I think there's a big difference between .bss and .data sections: .data
> sections are associated to real data (numbers that are init values for
> that part of memory). These numbers are present and written in the
> output executable object file.

Correct.

>
> On the contrary, .bss sections aren't associated to concrete numbers,
> because they are uninitialized (they will be simply zeroed by startup
> code).
>
> If a .data section has an address, a size and some numbers, .bss has
> only an address and a size.
>
> So this could be the reason why my build system doesn't use NOLOAD for
> .bss sections: a JTAG programmer will skip loading/programming of .bss
> sections, because there aren't any numbers to write for them.
>

It skips them because the section is NOLOAD from the input section
flags, giving the same effect as NOLOAD in the linker file.

>
>> whereas ".text",
>> ".readonly" and ".data" sections will be "LOAD".  (Variables in the
>> ".data" sections have two sets of addresses - their "load" addresses for
>> the address in flash or other images of the initial value, and their
>> "link" addresses for their run-time variable address.)

Re: gcc: NOLOAD and .noinit

<t15219$7re$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=843&group=comp.arch.embedded#843

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tauno.vo...@notused.fi.invalid (Tauno Voipio)
Newsgroups: comp.arch.embedded
Subject: Re: gcc: NOLOAD and .noinit
Date: Sat, 19 Mar 2022 18:57:10 +0200
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <t15219$7re$1@dont-email.me>
References: <t13v61$b72$1@dont-email.me> <j9lu4oFemsdU1@mid.dfncis.de>
<t14sp4$i2g$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Mar 2022 16:57:13 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f1d20587da5306fc39867d92ede2e5c3";
logging-data="8046"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+v5vriZDn4mfFJSbZuCJEgNw3UZty02ik="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.7.0
Cancel-Lock: sha1:rNNPls30+/42r+W2zvJecGM6V6E=
In-Reply-To: <t14sp4$i2g$1@dont-email.me>
 by: Tauno Voipio - Sat, 19 Mar 2022 16:57 UTC

On 19.3.22 17.27, pozz wrote:
>
> You're right, .bss has only ALLOC attribute, while .text and .data have
> LOAD attribute too.
>
> It's strange because, as I wrote to David, my linker script doesn't use
> NOLOAD for .bss sections.

Please look at the unlinked .o file of some module accessing the
..bss section. The LOAD attribute is missing there, also.

An example:

tauno@ubuntu:~/sandbox/lm3/app$ arm-none-eabi-objdump -h stest.o

stest.o: file format elf32-littlearm

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00001428 00000000 00000000 00000038 2**3
ALLOC
3 .text.boot_thr 00000098 00000000 00000000 00000038 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
4 .text.net_thread 00000004 00000000 00000000 000000d0 2**1
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
5 .text.startup.main 0000008c 00000000 00000000 000000d4 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
6 .rodata 00000020 00000000 00000000 00000160 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
7 .comment 0000005a 00000000 00000000 00000180 2**0
CONTENTS, READONLY
8 .ARM.attributes 0000002d 00000000 00000000 000001da 2**0
CONTENTS, READONLY

It is the assembly phase of the compilation (GNU as) which knows
about the .bss section and leaves the LOAD bit off.

--

-TV

Re: gcc: NOLOAD and .noinit

<t18vq5$ff3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=844&group=comp.arch.embedded#844

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: keg...@provalid.com (Kent Dickey)
Newsgroups: comp.arch.embedded
Subject: Re: gcc: NOLOAD and .noinit
Date: Mon, 21 Mar 2022 04:43:50 -0000 (UTC)
Organization: provalid.com
Lines: 25
Message-ID: <t18vq5$ff3$1@dont-email.me>
References: <t13v61$b72$1@dont-email.me>
Injection-Date: Mon, 21 Mar 2022 04:43:50 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f1288bda00eec9148e3d4adf8d8304de";
logging-data="15843"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+eUXb/xcVIOI06iSh+u3/F"
Cancel-Lock: sha1:Tmj2JJNLLl3SXr5NeKKqpJfYaB8=
Originator: kegs@provalid.com (Kent Dickey)
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
 by: Kent Dickey - Mon, 21 Mar 2022 04:43 UTC

In article <t13v61$b72$1@dont-email.me>, pozz <pozzugno@gmail.com> wrote:
>I usually don't touch linker script of my development system, sincerely
>I can't read every details of a linker script, so I'm in trouble now.
>
>As explained in my previous post, I need to avoid zeroing a static big
>variable, because it is allocated in SDRAM and SDRAM isn't available
>when zeroing of bss sections (and initialization of data sections) occurs.
>
>My development system allows me to use .noinit section, so I'm studying
>how it works.

I suspect you can come up with a linker-based solution, but I think you may
want to look at your problem differently.

In C/C++, you can form a pointer to any location you want. So if your SDRAM
is at 0x2000_0000, just do:

char *sdram_ptr = (char *)0x20000000;

(For 64-bit systems, this will need to be 0x20000000L or something similar).

And then just use sdram_ptr[offset] to access whatever SDRAM location you
want--after SDRAM has been initialized.

Kent

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor