If the code you supply has been sufficiently derived away from the original source, then you may not be able to do that. On the other hand, if someone takes this:
int longname = 42;
int othername = 3;
double largenumber = 0.5;
for(int i = 0; i < x; i++)
{
largeNumber *= longname + othername;
}
and rewrites it as:
int l = 42;
int o = 3;
double n = 0.5;
for(int i = 0; i < x; i++)
{
n = n * l + o;
}
it will generate exactly the same binary code (obviously, only if you use the same version of the same compiler with the same settings)
So, if you have some fairly complex and unique code in your software package, I'm pretty certain that it's difficult to disguise that without a fair amount of effort - it would probably be easier to rewrite the code completely, just using your general ideas (which of course they could have done in the first place).
Is there at tool that can trivially tell you that "this binary contains this bit of code, as produced by gcc 4.7.3"? Possibly one could be constructed if you do some really specific types of calculations using a set of constants.
If there is enough money in it, you could certainly have an expert reverse engineer look into it, and produce a legal witness statement (probably in the form of a document and then examination by other experts, etc) in court saying that "It is my belief that this code can only have come about by using the source code from Company X".
Now, can you make that stand up in court? That's for a judge and jury to decide. I don't think it's at all easy to do this. But it's not impossible either.
Is there a completely foolproof way to assure this? No, absolutely not. But that applies to just about everything. If you have a contract with someone that says you should do this, mustn't do that, does that mean they aren't physically able to do that? No, it's a legal contract, you take them to court if they break it. Same applies to software. You then have to prove in court that they did what they shouldn't do (or didn't do what they should do), and if your evidence is good enough, you win. If the other guy can defend himself well enough, you lose. Typically, these cases end up being "the one with the most money wins", because there's ways to say "I want this tried in the next level court", and then you end up spending more money on just proving the same thing again (but with more expensive lawyers this time).