RavenBlog
Black:  ravenblack.net | me | games | books | email | wishlist | rss
Blogs:  Angryblog | As Above | MonkyBlog | Nightshade | Journals
Blimey:  SomethingAwful | Advice
Archives: Last 4 Days | June2001 | July2001 | August2001 | September2001 | October2001 | November2001 | December2001 | January2002 | February2002 | March2002 | April2002 | May2002 | June2002 | July2002 | August2002 | September2002 | October2002 | November2002 | December2002 | January2003 | February2003 | March2003 | April2003 | May2003 | June2003 | July2003 | August2003 | September2003 | October2003 | November2003 | December2003 | January2004 | February2004 | March2004 | April2004 | May2004 | June2004 | July2004 | August2004 | September2004 | October2004 | November2004 | December2004 | January2005 | February2005 | March2005 | April2005 | May2005 | June2005 | July2005 | August2005 | September2005 | October2005 | November2005 | January2006 | February2006 | March2006 | April2006 | May2006 | June2006 | July2006 | August2006 | September2006 | October2006 | November2006 | December2006 | January2007 | February2007 | March2007 | April2007 | May2007 | June2007 | July2007 | August2007 | September2007 | October2007 | November2007 | December2007 | January2008 | February2008 | March2008 | April2008 | May2008 | June2008 | July2008 | August2008 | September2008 | October2008 | November2008 | December2008 | January2009 | March2009 | April2009 | May2009 | July2009 | August2009 | September2009 | February2010 | March2010 | June2010 | July2010 | August2010 | September2010 | October2010 | November2010 | December2010 | February2011 | March2011 | April2011 | May2011 | June2011 | July2011 | August2011 | September2011 | October2011 | December2011 | March2012 | April2012 | May2012 | September2012 | December2012 | March2013 | April2013 | May2013 | June2013 | October2021


Comments on Wednesday 24 March 2004:
Ignore this post if you're not a programmer.

In the openssl library, there is a function in rsa_lib.c that looks like this:
int RSA_size(const RSA *r)
 {
 return(BN_num_bytes(r->n));
 }
In my code, there is a function call that looks like this:
int size=RSA_size(rsa);
When the program is compiled and run, the resulting executable is 220K. Now, if I replace that single line of my code with this:
int size=(BN_num_bytes(rsa->n));
Then when the program is compiled and run, the resulting executable is 84K.

I consider it unlikely that an extra function call going onto the stack and off again is 136K of compiled code. What's happening here? Neither call has been replaced by a macro, but for some reason the RSA_size function causes some twenty-odd extra RSA functions to end up in the executable (this gleaned from the .map file). Also of note, both of these functions cause some extra code to end up in the executable even if the function from which they are called is discarded from the executable due to not being called itself (and the "/opt:ref" linker option). This differs from BF_cfb64_encrypt (a function in the same library), which is discarded if the function that calls it is discarded, as it should be.

Any programmery people got an explanation for this odd behaviour? Visual C++ 5 being the compiler, and openssl 0.9.7d using no assembly language being the statically compiled library. [04:11]

Digi
I've no experience with that library, or that compiler, but is it possible that the use of that function is causing VC++ 5 to link a whole load of other stuff, without telling you about it in any very obvious way? "Ooh, he wants that function. Then he wants all these libraries too! Probably, anyway. I won't ask, wouldn't want to bother him". Any relevant #ifdef's you're not mentioning?

Seems pretty far fetched, but like you say, it's not the code. Unless, maybe the code you've got here isn't quite the code you have in the program, because you just typed it, instead of copy-pasting it. I expect you spent about two hours on this, before Bloging, so again, pretty far fetched that you'd do something like that.

What happens when you cut out all the other code from the program, and just test this bit? Same disparity in size? How about a diffrent version of VC++?

Be intresting to know what caused it, when you find out.

RavenBlack
Can't really test just that bit without it being a lot of effort. I tried changing the compiler and linker to those of VC++6 and doing a command-line compile, which had the same result. I've changed library from openssl to libtomcrypt, which is *less* bad, but still has things getting linked in that shouldn't be. In this instance, calling a function with a const structure full of function pointers from the same library (within a function that's never called) causes the effect. Calling the function without the struct, or using the struct without the function (both within my never-called function), does not.

AttackOfTheSpam
Oooh.... numbery things...
Add Comment:
Name:Comment: (max. 2048 characters)
Email:
Show Email: (if no website)
Website:
No HTML tags allowed.
(Antispam) What is 11 + 0?
Archives: Last 4 Days | June2001 | July2001 | August2001 | September2001 | October2001 | November2001 | December2001 | January2002 | February2002 | March2002 | April2002 | May2002 | June2002 | July2002 | August2002 | September2002 | October2002 | November2002 | December2002 | January2003 | February2003 | March2003 | April2003 | May2003 | June2003 | July2003 | August2003 | September2003 | October2003 | November2003 | December2003 | January2004 | February2004 | March2004 | April2004 | May2004 | June2004 | July2004 | August2004 | September2004 | October2004 | November2004 | December2004 | January2005 | February2005 | March2005 | April2005 | May2005 | June2005 | July2005 | August2005 | September2005 | October2005 | November2005 | January2006 | February2006 | March2006 | April2006 | May2006 | June2006 | July2006 | August2006 | September2006 | October2006 | November2006 | December2006 | January2007 | February2007 | March2007 | April2007 | May2007 | June2007 | July2007 | August2007 | September2007 | October2007 | November2007 | December2007 | January2008 | February2008 | March2008 | April2008 | May2008 | June2008 | July2008 | August2008 | September2008 | October2008 | November2008 | December2008 | January2009 | March2009 | April2009 | May2009 | July2009 | August2009 | September2009 | February2010 | March2010 | June2010 | July2010 | August2010 | September2010 | October2010 | November2010 | December2010 | February2011 | March2011 | April2011 | May2011 | June2011 | July2011 | August2011 | September2011 | October2011 | December2011 | March2012 | April2012 | May2012 | September2012 | December2012 | March2013 | April2013 | May2013 | June2013 | October2021