How to obtain IAR segments' pointers

Hi,

I have solid background on GNU tools -but IAR... anyway

How to extract a HEAP pointer in IAR C/C++? I have my own malloc routines (i don't use stdlib), so I need that value from xlink.

Trick like

-D_hea=3DHEAP

and in C extern _hea; .=2E .=2E printf("%x",&_hea);

doesn't work :) (but it works for -D_hea=3D123)

Maybe someone with bigger IAR background could help. Thanks for any hint. Arch is AT91sam7 but I think this is irrevelant.

Pawe=B3

Reply to
Pawel.Rozanski
Loading thread data ...

Hello,

Enable language extensions and try the following:

#pragma segment=3D"HEAP"

int main ( void ) {

unsigned int startOfHeap =3D __sfb("HEAP"); unsigned int endOfHeap =3D __sfe("HEAP"); unsigned int heapSegSize =3D __sfsize("HEAP");

printf("Start of heap: %x\n", startOfHeap); printf("End of heap: %x\n", endOfHeap); printf("Heap size: %x\n", heapSegSize);

return 0;

}

This assumes you defined HEAP as a segment in the linker command file or using the "@" symbol.

n> Hi,

Reply to
David Ziman

Reply to
David Ziman

Reply to
David Ziman

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.