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
How to obtain IAR segments' pointers
Started by ●January 3, 2007
Reply by ●January 3, 20072007-01-03
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. ninjew On Jan 3, 3:26 am, Pawel.Rozan...@gmail.com wrote:> 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; > .. > .. > 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. >=20 > Pawe=B3
Reply by ●January 3, 20072007-01-03
Sorry, one correction, change __sfsize to __sfs On Jan 3, 3:40 pm, "David Ziman" <nin...@gmail.com> wrote:> 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. > > ninjew > > On Jan 3, 3:26 am, Pawel.Rozan...@gmail.com wrote: > > > 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; > > .. > > .. > > 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. >=20 > > Pawe=B3
Reply by ●January 3, 20072007-01-03
And you may want to cast the pointers returned b __sfb and __sfe to pointers before assigning them to their appropriate locals. On Jan 3, 3:40 pm, "David Ziman" <nin...@gmail.com> wrote:> 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. > > ninjew > > On Jan 3, 3:26 am, Pawel.Rozan...@gmail.com wrote: > > > 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; > > .. > > .. > > 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. >=20 > > Pawe=B3