The .secinfo section contains special tables which contain information needed by startup code to clear sections (Runtime Clear Table), and copy sections from ROM to RAM (Runtime Copy Table).
These two tables are contained within the .secinfo section; the Clear table is bounded by the symbols __ghsbinfo_clear and __ghseinfo_clear, while the Copy table is bounded by the symbols __ghsbinfo_copy and __ghseinfo_copy. The tables each contain zero or more records detailing the action to be taken at startup. By default, the Green Hills C runtime will perform .bss clearing and ROM copying based on this table without user intervention. The remainder of this section only needs to be referred to if you want to override these default actions.
The clear structure is as follows:
void *base; /* pointer to base of memory to clear */
int value; /* value to initialize with (generally zero) */
size_t length; /* number of bytes to clear */
These values are appropriate to be passed directly into the memset() routine within the C runtime library. The default clear code in the C runtime thus is as follows:
{
extern rodata_ptr __ghsbinfo_clear, __ghseinfo_clear;
void **b = (void **) __ghsbinfo_clear;
void **e = (void **) __ghseinfo_clear;
while (b != e) {
void * t; /* target pointer */
ptrdiff_t v; /* value to set */
size_t n; /* set n bytes */
t = (char *)(*b++);
v = *((ptrdiff_t *) b); b++;
n = *((size_t *) b); b++;
memset(t, v, n);
}
}
The copy structure is as follows:
void *dest; /* pointer to base of memory to copy to */
void *src; /* pointer to base of memory to copy from */
size_t length; /* number of bytes to copy */
These values are appropriate to be passed directly into the memcpy() routine within the C runtime library. The default copy code in the C runtime is as follows:
{
extern rodata_ptr __ghsbinfo_copy, __ghseinfo_copy;
void **b = (void **) __ghsbinfo_copy;
void **e = (void **) __ghseinfo_copy;
while (b != e) {
void * t; /* target pointer */
void * s; /* source pointer */
size_t n; /* copy n bytes */
t = (char *)(*b++);
s = (char *)(*b++);
n = *((size_t *) b); b++;
memcpy(t, s, n);
}
}
The actual implementation of the above two routines for your CRT can be found in libsrc/ind_crt0.c in your Green Hills distribution, and differs slightly for PIC/PID support on some targets.
When the linker is performing final symbol resolution for a non-relocatable output file, certain undefined symbol names are recognized as referring to memory addresses in the final section map. These symbol names are constructed by prepending the strings _ _ghsbegin and _ _ghsend to the name of each section in the output file, with any period (.) characters in the section names changed to underscores (_). For a section named .text the symbols _ _ghsbegin_text would resolve to the virtual address of the start, and _ _ghsend_text to the virtual address of the end, of that section.
{
.text 0x100000 :
.data 0x300000 :
.bss1 0x400000 :
.bss :
}
main.c:
extern char _ _ghsbegin_bss1[], _ _ghsend_bss1[], _ _ghsbegin_bss[];
main() {
memset(_ _ghsbegin_bss1, 0, _ _ghsend_bss1 -
_ _ghsbegin_bss1);
_ _ghsbegin_bss[0] = 0xff;
}
If the size of section .bss1 is 0x100, then the linker will resolve _ _ghsbegin_bss1 to be 0x400000, _ _ghsend_bss1 to be 0x400100, and _ _ghsbegin_bss to be 0x400100.