How to obtain IAR segments' pointers

Jan 03, 2007 3 Replies

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



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,

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required