On Wed, Apr 18, 2012 at 11:50 AM, grischka
<address@hidden> wrote:
I pushed a small patch that should allow using tcc_get_symbol also
for older states. Please test.
http://repo.or.cz/w/tinycc.git/commitdiff/f98c2306a0857ad3f8800f91e0554a27adc7f675
Current state of multiple TCCStates usage summary:
There are now two things you can do with TCCStates after tcc_relocate:
- run the ccde
- get symbol addresses
There is one thing you cannot do _before_ tcc_relocate:
- create another TCCState
Also, tcc_relocate can be called only once for each state.
--- grischka
David Mertens wrote:
Milutin, all -
Yes, you were absolutely correct. Once I recompiled tcc as a shared library, the issue went away. That lesson has been learned. :-)
However, my main question remains unanswered, and my suspicions have been confirmed with new tests. To recap, here is my original question:
Is there a good reason symtab_section is a global variable? In
addition to the issue that I encountered, what if I want to have
multiple compiler states? It looks to me like the pointer for
symtab_section will be overwritten for each call to the constructor.
Won't this lead to trouble? And is there any reason we don't have a
field in the TCCState struct to store the location of symtab_section?
Whether or not this is the source, I have indeed encountered issues under a few circumstances:
1) Using a single compiler state, compiling+relocating multiple times. When I do this, I cannot call any functions from the first relocation after the second relocation.
2) Using two states, I cannot call any functions from the first state after I have compiled+relocated the second state. Using the *first* state, I *can* retrieve symbols from the compilation of the second state!
So, it looks like there's a global variable for some sort of symbol table machinations.
Thoughts?
David