- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 /AlessandroLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by alessandro@Feb 28 2006, 07:58 PM can you suggest a way to workaround this problem ? (without suggesting to
rewrite 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

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