NB_SSL_SUPPORTED and Code Size Problem

Discussion to talk about software related topics only.
Post Reply
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

NB_SSL_SUPPORTED and Code Size Problem

Post by ecasey »

On a MOD5270B using version 2.9.5 I have a small subroutine for extracting data from the bottom of a std::list.

Code: Select all

struct GraphData{
	time_t time;
	std::vector <float> value;};
	
float Graph::GetLastValue(int index){
	list<GraphData>::reverse_iterator D_it = plotData.rbegin();
	lastSavedMonth = gmtime(&D_it->time)->tm_mon;
	lastSavedHour = gmtime(&D_it->time)->tm_hour;
	return  D_it->value[index];
}
The "gmtime(&D_it->time)" lines cause a problem:

If I make the project with NB_SSL_SUPPORTED (1) commented out in predef.h I get 51 errors, mostly like:

C:\nburn\lib\cryptolib.a(wc_port.o): In function `wc_InitAndAllocMutex':
C:\nburn\system\cryptolib/wolfcrypt/src/wc_port.c:613: undefined reference to `wc_InitMutex'
C:\nburn\lib\cryptolib.a(ecc.o): In function `ecc_mul2add':
C:\nburn\system\cryptolib/wolfcrypt/src/ecc.c:8987: undefined reference to `wc_LockMutex'
C:\nburn\system\cryptolib/wolfcrypt/src/ecc.c:9075: undefined reference to `wc_UnLockMutex'
C:\nburn\system\cryptolib/wolfcrypt/src/ecc.c:8984: undefined reference to `wc_InitMutex'
C:\nburn\system\cryptolib/wolfcrypt/src/ecc.c:9075: undefined reference to `wc_UnLockMutex'
C:\nburn\system\cryptolib/wolfcrypt/src/ecc.c:9075: undefined reference to `wc_UnLockMutex'
C:\nburn\system\cryptolib/wolfcrypt/src/ecc.c:9075: undefined reference to `wc_UnLockMutex'

If I enable the NB_SSL_SUPPORTED in predef.h, the code compiles to 131% of flash memory. I can get it down to 128% with optimization for size, but that is about it. The app compiles to 89% in version 2.8.6. Linker stripping is on in both cases.

Is there anything I can do to get this to compile with 2.9.5?
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: NB_SSL_SUPPORTED and Code Size Problem

Post by pbreed »

Are you using TLS/SSL?
If not I don't understand how that causes the Wolf ssl stuff to link.
Can you send a map file of the one that is 131% and open a support ticket?
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: NB_SSL_SUPPORTED and Code Size Problem

Post by ecasey »

Support ticket with map file sent.
It is definitely invoking cryptolib.a for the gmtime() function at line 327 in the map file:

C:\nburn\lib\cryptolib.a(wc_port.o)
Graph.o (gmtime)
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: NB_SSL_SUPPORTED and Code Size Problem

Post by ecasey »

Just for clarity, I am not using SSL/TLS.
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: NB_SSL_SUPPORTED and Code Size Problem

Post by pbreed »

This is an error, that should not be there.
Try using gmtime_r
You have to pass in your struct tm so its not globally allocated....and thus thread safe.
struct tm *gmtime_r(const time_t *clock, struct tm *result);
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: NB_SSL_SUPPORTED and Code Size Problem

Post by ecasey »

Thanks Paul,
It complies and links using gmtime_r() at 91.79% of flash with -O2 optimization and 88.98% with -Os.
I also found that it worked with localtime(), but that would require some work-arounds for daylight savings time to get back to GMT from EST/EDT.

Good point about thread-safe. That is a separate issue to gmtime() not working; I should hit gmtime() or gmtime_r() only once in that function. That will probably save me some grief down the road.

Ed
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: NB_SSL_SUPPORTED and Code Size Problem

Post by pbreed »

We will pull gmtime out of that location so it does not pull in the crypto world.
(I think there is a gmtime in the newlib as well... but its choosing the crypto one so... ):-(
Post Reply