Exception Handling and C++ Libs in Filter Drivers

I am trying to link a lib that contains C++ code and exception handling,
and am having some problems. The first call to the lib that contains the
C++ code crashes io-net. I
am building the lib with the -lang-c++ LD flag set. I am also setting
this
flag when building my filter.

Does anyone have any ideas?

Is io-net succesfully loading the dll?

Have you wrapped your interface functions with extern “C”?

What is the call doing?

Where it dying?

Steven Erickson <sojg@mediaone.net> wrote:

I am trying to link a lib that contains C++ code and exception handling,
and am having some problems. The first call to the lib that contains the
C++ code crashes io-net. I
am building the lib with the -lang-c++ LD flag set. I am also setting
this
flag when building my filter.

Does anyone have any ideas?


cburgess@qnx.com

Here is the whole story.

I am building a filter driver and am statically linking in several libraries.
The libraries are built using the “-shared” flag and linked into an archive
using ar. I add the libs to the “LIBS” line in the filter makefile. When i try
to load the driver into io-net, io-net crashes. I have linked in a single
library successfully, therefore the problem is likely one or more of the
libraries that i am linking in, or due to the number of libs linked in. Io-net
crashes when loading the driver, and execution does not reach my filters init
function. Here are a couple of areas risk areas, that i feel are causing
problems.

When loading the single lib which contains exception handling, io-net loads
the driver properly, but crashes on the first call into the c++ library. The
call is contained within an extern “C” block:

filter.c*

Initialize(“String”);

lib.h file
#ifdef __cplusplus
extern “C”
{
#endif // __cplusplus

int Initialize(const char *pszModulePathName);
void Terminate();

#ifdef __cplusplus
}
#endif // __cplusplus

lib.c file*
int Initialize(const char *pszModulePathName)
{
try
{
lib::Init::Initialize(pszModulePathName);
return 0;
}
catch(std::exception&)
{
return -1;
}
}

When all of my libs are linked in, i don’t even get to that point. Io-net
crashes when loading the driver. I am linking in a manually built version of
the openssl crypto lib, which also may be causing problems. Currently, i do
not know of a openssl crypto library that can build into a shared object and
loadable by io-net. However, i believe that the lib that i have created has
been built corectly. I am currently trying to link the libs in one-by-one and
determine where the problem exists.

Anyway, thanks for any help you could provide.



Colin Burgess wrote:

Is io-net succesfully loading the dll?

Have you wrapped your interface functions with extern “C”?

What is the call doing?

Where it dying?

Steven Erickson <> sojg@mediaone.net> > wrote:
I am trying to link a lib that contains C++ code and exception handling,
and am having some problems. The first call to the lib that contains the
C++ code crashes io-net. I
am building the lib with the -lang-c++ LD flag set. I am also setting
this
flag when building my filter.

Does anyone have any ideas?


cburgess@qnx.com

Ok, the first thing to check is whether or not you have text/readonly data
relocations.

Do a objdump -x on the dll and check for rel.text or rel.rodata sections.
If they are present, then one of your libs is bad.

Steven Erickson <sojg@mediaone.net> wrote:

Here is the whole story.

I am building a filter driver and am statically linking in several libraries.
The libraries are built using the “-shared” flag and linked into an archive
using ar. I add the libs to the “LIBS” line in the filter makefile. When i try
to load the driver into io-net, io-net crashes. I have linked in a single
library successfully, therefore the problem is likely one or more of the
libraries that i am linking in, or due to the number of libs linked in. Io-net
crashes when loading the driver, and execution does not reach my filters init
function. Here are a couple of areas risk areas, that i feel are causing
problems.

When loading the single lib which contains exception handling, io-net loads
the driver properly, but crashes on the first call into the c++ library. The
call is contained within an extern “C” block:

filter.c*

Initialize(“String”);

lib.h file
#ifdef __cplusplus
extern “C”
{
#endif // __cplusplus

int Initialize(const char *pszModulePathName);
void Terminate();

#ifdef __cplusplus
}
#endif // __cplusplus

lib.c file*
int Initialize(const char *pszModulePathName)
{
try
{
lib::Init::Initialize(pszModulePathName);
return 0;
}
catch(std::exception&)
{
return -1;
}
}

When all of my libs are linked in, i don’t even get to that point. Io-net
crashes when loading the driver. I am linking in a manually built version of
the openssl crypto lib, which also may be causing problems. Currently, i do
not know of a openssl crypto library that can build into a shared object and
loadable by io-net. However, i believe that the lib that i have created has
been built corectly. I am currently trying to link the libs in one-by-one and
determine where the problem exists.

Anyway, thanks for any help you could provide.



Colin Burgess wrote:

Is io-net succesfully loading the dll?

Have you wrapped your interface functions with extern “C”?

What is the call doing?

Where it dying?

Steven Erickson <> sojg@mediaone.net> > wrote:
I am trying to link a lib that contains C++ code and exception handling,
and am having some problems. The first call to the lib that contains the
C++ code crashes io-net. I
am building the lib with the -lang-c++ LD flag set. I am also setting
this
flag when building my filter.

Does anyone have any ideas?


cburgess@qnx.com


cburgess@qnx.com

I definitely have those sections.

Is there anyway to figure out which lib is the problem?

Colin Burgess wrote:

Ok, the first thing to check is whether or not you have text/readonly data
relocations.

Do a objdump -x on the dll and check for rel.text or rel.rodata sections.
If they are present, then one of your libs is bad.

Steven Erickson <> sojg@mediaone.net> > wrote:
Here is the whole story.

I am building a filter driver and am statically linking in several libraries.
The libraries are built using the “-shared” flag and linked into an archive
using ar. I add the libs to the “LIBS” line in the filter makefile. When i try
to load the driver into io-net, io-net crashes. I have linked in a single
library successfully, therefore the problem is likely one or more of the
libraries that i am linking in, or due to the number of libs linked in. Io-net
crashes when loading the driver, and execution does not reach my filters init
function. Here are a couple of areas risk areas, that i feel are causing
problems.

When loading the single lib which contains exception handling, io-net loads
the driver properly, but crashes on the first call into the c++ library. The
call is contained within an extern “C” block:

filter.c*

Initialize(“String”);

lib.h file
#ifdef __cplusplus
extern “C”
{
#endif // __cplusplus

int Initialize(const char *pszModulePathName);
void Terminate();

#ifdef __cplusplus
}
#endif // __cplusplus

lib.c file*
int Initialize(const char *pszModulePathName)
{
try
{
lib::Init::Initialize(pszModulePathName);
return 0;
}
catch(std::exception&)
{
return -1;
}
}

When all of my libs are linked in, i don’t even get to that point. Io-net
crashes when loading the driver. I am linking in a manually built version of
the openssl crypto lib, which also may be causing problems. Currently, i do
not know of a openssl crypto library that can build into a shared object and
loadable by io-net. However, i believe that the lib that i have created has
been built corectly. I am currently trying to link the libs in one-by-one and
determine where the problem exists.

Anyway, thanks for any help you could provide.

Colin Burgess wrote:

Is io-net succesfully loading the dll?

Have you wrapped your interface functions with extern “C”?

What is the call doing?

Where it dying?

Steven Erickson <> sojg@mediaone.net> > wrote:
I am trying to link a lib that contains C++ code and exception handling,
and am having some problems. The first call to the lib that contains the
C++ code crashes io-net. I
am building the lib with the -lang-c++ LD flag set. I am also setting
this
flag when building my filter.

Does anyone have any ideas?


cburgess@qnx.com


cburgess@qnx.com

Steven Erickson <sojg@mediaone.net> wrote:

I definitely have those sections.

Is there anyway to figure out which lib is the problem?

I’ve put a utils called readelf in http://staff.qnx.com/~cburgess/gnu

Use this (readelf -r shared.so) to find the address (offset) of
the relocations. Then use that offset to find the location in your
object ( objdump -D shared.so )

Hope this helps,

Colin

Colin Burgess wrote:

Ok, the first thing to check is whether or not you have text/readonly data
relocations.

Do a objdump -x on the dll and check for rel.text or rel.rodata sections.
If they are present, then one of your libs is bad.

Steven Erickson <> sojg@mediaone.net> > wrote:
Here is the whole story.

I am building a filter driver and am statically linking in several libraries.
The libraries are built using the “-shared” flag and linked into an archive
using ar. I add the libs to the “LIBS” line in the filter makefile. When i try
to load the driver into io-net, io-net crashes. I have linked in a single
library successfully, therefore the problem is likely one or more of the
libraries that i am linking in, or due to the number of libs linked in. Io-net
crashes when loading the driver, and execution does not reach my filters init
function. Here are a couple of areas risk areas, that i feel are causing
problems.

When loading the single lib which contains exception handling, io-net loads
the driver properly, but crashes on the first call into the c++ library. The
call is contained within an extern “C” block:

filter.c*

Initialize(“String”);

lib.h file
#ifdef __cplusplus
extern “C”
{
#endif // __cplusplus

int Initialize(const char *pszModulePathName);
void Terminate();

#ifdef __cplusplus
}
#endif // __cplusplus

lib.c file*
int Initialize(const char *pszModulePathName)
{
try
{
lib::Init::Initialize(pszModulePathName);
return 0;
}
catch(std::exception&)
{
return -1;
}
}

When all of my libs are linked in, i don’t even get to that point. Io-net
crashes when loading the driver. I am linking in a manually built version of
the openssl crypto lib, which also may be causing problems. Currently, i do
not know of a openssl crypto library that can build into a shared object and
loadable by io-net. However, i believe that the lib that i have created has
been built corectly. I am currently trying to link the libs in one-by-one and
determine where the problem exists.

Anyway, thanks for any help you could provide.

Colin Burgess wrote:

Is io-net succesfully loading the dll?

Have you wrapped your interface functions with extern “C”?

What is the call doing?

Where it dying?

Steven Erickson <> sojg@mediaone.net> > wrote:
I am trying to link a lib that contains C++ code and exception handling,
and am having some problems. The first call to the lib that contains the
C++ code crashes io-net. I
am building the lib with the -lang-c++ LD flag set. I am also setting
this
flag when building my filter.

Does anyone have any ideas?


cburgess@qnx.com


cburgess@qnx.com


cburgess@qnx.com