- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My project need to read current heap pointer, but I don't know how to implement it.
In NiosII IDE, Variables Window, you can add a global variables for watching, and I find heap_end which is the one I looking for. but when I try to use it in my C code, the compiler report that heap_end undeclared. Anyone help? DavidLink Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi David_Cai,
maybe heap_end is declared in the linker script? If you want to use symbols declared by the assembler or linker you can add an 'extern' declaration to your c code: e.g.extern int heap_end;
Hope that helps, Wolfgang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have tried it, but it doesn't work...
Thanks anyway... I'm confusing, I can see it in the global variables list, why I can't use it... Anyone help... David- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi David_Cai,
I've looked some more at this problem. The symbol 'heap_end' is defined in nios2_60\bin\nios2-gnutools\src\newlib\libgloss\nios2\nosys_sbrk. It's definition is 'static char *heap_end;' A static symbol is only visible (for the toolchain) in the current file. If you generate an objdump listing of your executable you can see that heap_end is listed as a local symbol. So, if you try to reference this symbol in another file, it's the same as it wasn't defined at all. => >>undefined reference to `heap_end'<< Hope this helps, Wolfgang- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm very appreciated for your kindly reply...
Could you kindly tell me how can you find the answer? I hope to learn fishing skill and not only fishes.http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/happy.gif Thanks again... David- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by david_cai@Aug 11 2006, 07:01 AM could you kindly tell me how can you find the answer?
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=17538)
--- quote end ---
--- Quote End --- Hmm, let's see ... 1. I created a sample project to see if I would get the same problem. 2. I looked in the objdump file if the symbol was indeed defined (it was) (If you want to know anything about an elf (file format used by gcc) executable/object file look at it with objdump) 3. I googled 'heap_end'. a promising hit 'told' me that heap_end was defined by the c-library. 4. I searched the c-lib sources in my local filesystem for 'heap_end' (I didn't use the explorer for that. I did use a program that searches the content of all files for 'heap_end'). 5. Voilá, file found => static definition. 6. I know that static symbols are visible only in the current file. You know, experience is difficult to explain... Wolfgang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks very very very much......
Your answer is very helpful for me. In fact, I have done something like you, the only difference is that when I search on web , I can't get the info that heap_end is defined in c library.http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/happy.gif Thanks again for your kindly reply, David
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page