Forum Discussion
Altera_Forum
Honored Contributor
20 years agoGCC
Dear gurus,
I have the following problem. I have built a library which is compiled and linked separately from the rest of software. This library is stored in flash memory as a standalone piece of software. Then I have built an application which uses this library by calling its functions at some defined flash addresses. The application has been compiled and linked separately from the library and it resides at different addresses in flash. Both the library and the application use global variables. These variables are allocated at different ram addresses. Since GCC uses global pointer to reference to global variables, when the application calls a library function, that function is not able to reference its globals because the global pointer is assigned to the application's ram area and not to library's ram area. Can you suggest a way to workaround this problem ? (without suggesting to rewrite the compiler ...) Best Regards /Alessandro2 Replies
- Altera_Forum
Honored Contributor
Hi Alessandro,
> Can you suggest a way to workaround this problem ? Disable use of the global pointer with the -G0 compiler option (for both library and app). If you _must_ use the gp, you can write some fixup code in your library to save/restore the gp. But, depending on your requirements ... it might not be worth the effort. Regards, --Scott - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by alessandro@Feb 28 2006, 07:58 PM can you suggest a way to workaround this problem ? (without suggesting torewrite the compiler ...)
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=12991)
--- quote end ---
--- Quote End --- Another possible workaround could be that the fixed locations of the functions you have to call in reality contains an assembler stub which only swaps the gp pointer value... bye PJ