tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] symtab_section


From: David Mertens
Subject: Re: [Tinycc-devel] symtab_section
Date: Wed, 18 Apr 2012 14:22:50 -0500

Wow, excellent! I looked over the patch and the changes were minimal, but they are 90% of what needs to happen. More importantly, I ran your code against my Perl bindings' test suite and it passed, where before it failed. I would still like to be able to have multiple not-yet-relocated TCCStates, and I will focus my energy on that when I get a round tuit, but at this point if I really need to, I can control how my Perl code accesses TCC with a singleton.

Sorry I didn't actually get around to implementing this work, and thanks for beating me too it. I have lots of projects and some of them got my attention in the last few weeks.

Thank you thank you thank you!
David :-D

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



_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel



--
 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]