Exporting Symbols From C++ Object File

C

chetan

Hi ,
myself Chetan

Is There anybody could help me ?

I am working on the project in c++ ,, I am in great confusion that
should I export c++ member functions OR methods to create objects of
that class OR
previously cretaed objects .. So those can be used by users by using
the header file ... of my " class "

But by exporting member functions of C++ class user would not
understand
which are the private // public functions and would get compilation
error ..!!!
OR may simply change the header file from private to public and would
use
private functions ....!!!

So I need information that how compiler checks that a perticular
symbol is private and won't allow us to call it by object from
anywhere ...

Because simply looking at the symbol table from ELF file it's not
getting clear diffrence between the public and private
functionss...!!!


So help ..!!!
 
S

Sharad Kala

chetan said:
Hi ,
myself Chetan

I could guess from the header of your posting :)
Is There anybody could help me ?

Sure, dozens out here.
I am working on the project in c++ ,, I am in great confusion that
should I export c++ member functions OR methods to create objects of
that class OR
previously cretaed objects .. So those can be used by users by using
the header file ... of my " class "

I am also in great confusion as to what exactly you meant in the above
lines. Care to give an example ?
But by exporting member functions of C++ class user would not
understand
which are the private // public functions and would get compilation
error ..!!!
OR may simply change the header file from private to public and would
use
private functions ....!!!

So I need information that how compiler checks that a perticular
symbol is private and won't allow us to call it by object from
anywhere ...

Because simply looking at the symbol table from ELF file it's not

What is an ELF file ?
getting clear diffrence between the public and private
functionss...!!!

Honestly I don't understand your question quite well (may be others might
feel the same). In that case it would be better that you present your
problem clearly with an example.

Sharad
 
G

Gregg

(e-mail address removed) (chetan) wrote in @posting.google.com:
I am working on the project in c++ ,, I am in great confusion that
should I export c++ member functions OR methods to create objects of
that class OR
previously cretaed objects .. So those can be used by users by using
the header file ... of my " class "

It sounds like you want to put a class in a library that users can link
with. Is that correct?

Unlike C, there is no industry standard for storing C++ symbol
information in an object file (like "ELF") that is compatible with all
compilers. You will probably therefore have to use the same compiler for
both the library and the client code if you want to link symbolically.

The alternative that is commonly done is to export an extern "C" function
that is responsible for creating the object, which must have all virtual
functions. The client then invokes functions through an abstract
interface so it does not need to link symbolically. This is basically
what COM does in Windows.
But by exporting member functions of C++ class user would not
understand
which are the private // public functions and would get compilation
error ..!!!
OR may simply change the header file from private to public and would
use
private functions ....!!!

The public/private stuff is not represented in the binary file because it
is only used at compile time, not run time. The client compiler will know
which is private and which is public from the header file. You are right
that the user could edit the header file, the access modes could be
chcanged. That is the case even without libraries. It is only a compile-
time mechanism.

Gregg
 
J

John Harrison

chetan said:
Hi ,
myself Chetan

Is There anybody could help me ?

I am working on the project in c++ ,, I am in great confusion that
should I export c++ member functions OR methods to create objects of
that class OR
previously cretaed objects .. So those can be used by users by using
the header file ... of my " class "

But by exporting member functions of C++ class user would not
understand
which are the private // public functions and would get compilation
error ..!!!
OR may simply change the header file from private to public and would
use
private functions ....!!!

Is that a problem? Why do you care? Are you being paranoid?
So I need information that how compiler checks that a perticular
symbol is private and won't allow us to call it by object from
anywhere ...

It looks in the header file. If the header file has been changed by the user
there is not a lot you can do.
Because simply looking at the symbol table from ELF file it's not
getting clear diffrence between the public and private
functionss...!!!

There is no answer to your problem. Public and private are meant to help the
programmer, there are not a security system to stop the unauthorized
execution of code. If that is what you are trying to do then you are going
to have to look elsewhere.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top