|
@@ -160,7 +160,20 @@ unsigned cmLibOpen( cmLibH_t h, const cmChar_t* libFn )
|
160
|
160
|
|
161
|
161
|
if( _cmLibIsNull(lH) )
|
162
|
162
|
{
|
163
|
|
- cmErrMsg(&p->err,kOpenFailLibRC,"Library load failed. System Message: %s", _cmLibSysError() );
|
|
163
|
+ // There is apparently no way to get an error code which indicates that the
|
|
164
|
+ // file load attempt failed because the file was not a shared library -
|
|
165
|
+ // which should not generate an error message - therefore
|
|
166
|
+ // we must match the end of the the error string returned by dlerror() with
|
|
167
|
+ // 'invalid ELF header'.
|
|
168
|
+ const char* errMsg = _cmLibSysError();
|
|
169
|
+ const char* s = "invalid ELF header";
|
|
170
|
+ unsigned sn = strlen(s);
|
|
171
|
+ unsigned mn = strlen(errMsg);
|
|
172
|
+ if( errMsg!=NULL && mn>sn && strcmp(errMsg+mn-sn,s)==0 )
|
|
173
|
+ cmErrSetRC(&p->err,kOpenFailLibRC ); // signal error but no error message
|
|
174
|
+ else
|
|
175
|
+ cmErrMsg(&p->err,kOpenFailLibRC,"Library load failed. System Message: %s", errMsg );
|
|
176
|
+
|
164
|
177
|
return cmInvalidId;
|
165
|
178
|
}
|
166
|
179
|
|