469,611 Members | 1,714 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,611 developers. It's quick & easy.

Exporting Symbols From C++ Object File

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 ..!!!
Jul 22 '05 #1
3 3629

"chetan" <ro****@indiatimes.com> wrote in message
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

Jul 22 '05 #2
ro****@indiatimes.com (chetan) wrote in news:4cb1a40c.0409222045.9e8b674
@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
Jul 22 '05 #3

"chetan" <ro****@indiatimes.com> wrote in message
news:4c*************************@posting.google.co m...
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

Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Torbak | last post: by
1 post views Thread by Torbak | last post: by
47 posts views Thread by Pierre Barbier de Reuille | last post: by
1 post views Thread by mark.heyden | last post: by
3 posts views Thread by Bilgehan.Balban | last post: by
6 posts views Thread by Notre Poubelle | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.