This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Determine start-end of memory regions at runtime


Hi

> I do see __bss_start and __bss_end defined in vectors.S, however I am not sure

well, actually these symbols are not defined within vectors.S but
referenced from there

> how I can find start-end for global/shared data. Also __heap1 is the start of
> heap, but is there a way to determine where it ends at any time at runtime??

When you take a look into the linker-script of your generated
ecos-system (filename <install_dir>/lib/target.ld), you find that such
a linker script consists of several SECTION-statements. Within these
SECTION-statements you can find statements like

__bss_end = .

This means the linker will create a symbol '__bss_end' and assign the
value '.' to it, while '.' is an address. As an example

SECTIONS {
  .mysec : { __mysec_start = .; *(.mysec*); __mysec_end = . }
}

Here the value of __mysec_start is the start address of section .mysec
and the value of __mysec_end is the end address of section .mysec.
For any of these statements in the linker script, you can do the
following within your programm:

extern CYG_ADDRESS _bss_end;

(please note that there's one leading underscore missing in the
declaration of this variable). This way you can access these symbols
from a C-programm and therefore also the boundary addresses of you
sections, but you possibly have to insert appropriate statements in
your linker script. For more info see the GNU ld info pages.

Ciao, Fabian

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]