wrapping main method

wrapping main method

Post by Dal Magro Clement » Sat, 03 May 2003 03:23:15



hello to all

i have a problem that sounds trivial, but it's not at all (for me).
in my application i link a library containing the main method.
the problem is now, that i need access to the parameters passed
to my application. but how can i get them when the main
function is part of the library?

it is possible with the ps command but only if the parameterlist is
not to long, else i only get partial parameter data.

i wonder now, if it might be possible to wrap the main method.
normally, the compiler links the runtime-file to the application
to make it runnable under the system. is there a way to tell the
compiler/linker that another function than main() should be used
as the entering point?

i appreciate any kind of help.

thanx in advance, clemi.

 
 
 

wrapping main method

Post by p.. » Sat, 03 May 2003 15:02:57



Quote:> hello to all
> i have a problem that sounds trivial, but it's not at all (for me).
> in my application i link a library containing the main method.
> the problem is now, that i need access to the parameters passed
> to my application. but how can i get them when the main
> function is part of the library?
> it is possible with the ps command but only if the parameterlist is
> not to long, else i only get partial parameter data.
> i wonder now, if it might be possible to wrap the main method.
> normally, the compiler links the runtime-file to the application
> to make it runnable under the system. is there a way to tell the
> compiler/linker that another function than main() should be used
> as the entering point?
> i appreciate any kind of help.
> thanx in advance, clemi.

Well, then stop placing code in shared libraries and distribute statically
linked binaries.

The world would be a better place if you do so.

( shared libraries is ok for "system stuff, libc etc, but applications
should not do this in my opinion)

--
Peter H?kanson        
        IPSec  Sverige      ( At Gothenburg Riverside )
           Sorry about my e-mail address, but i'm trying to keep spam out,
           remove "icke-reklam" if you feel for mailing me. Thanx.

 
 
 

wrapping main method

Post by Dal Magro Clement » Tue, 06 May 2003 02:55:59


hi

Quote:> Well, then stop placing code in shared libraries and distribute statically
> linked binaries.

it's a third party library, not my one.

clemi.

 
 
 

wrapping main method

Post by Kartika Gar » Wed, 07 May 2003 21:04:12


Hi,
There is a way to change the entry point of your program.You'll have to look at
the options available with your linker.

For ld on Solaris -e option does the trick.

Thanx
Kartika


> hello to all

> i have a problem that sounds trivial, but it's not at all (for me).
> in my application i link a library containing the main method.
> the problem is now, that i need access to the parameters passed
> to my application. but how can i get them when the main
> function is part of the library?

> it is possible with the ps command but only if the parameterlist is
> not to long, else i only get partial parameter data.

> i wonder now, if it might be possible to wrap the main method.
> normally, the compiler links the runtime-file to the application
> to make it runnable under the system. is there a way to tell the
> compiler/linker that another function than main() should be used
> as the entering point?

> i appreciate any kind of help.

> thanx in advance, clemi.

 
 
 

wrapping main method

Post by Alexandre CHARTR » Wed, 07 May 2003 21:37:01


  You can also access the arguments via the /proc filesystem.

  On Solaris 9, there is the command "pargs" which uses /proc
and gives the arguments of a process.

alex.


> Hi,
> There is a way to change the entry point of your program.You'll have to look at
> the options available with your linker.

> For ld on Solaris -e option does the trick.

> Thanx
> Kartika


>>hello to all

>>i have a problem that sounds trivial, but it's not at all (for me).
>>in my application i link a library containing the main method.
>>the problem is now, that i need access to the parameters passed
>>to my application. but how can i get them when the main
>>function is part of the library?

>>it is possible with the ps command but only if the parameterlist is
>>not to long, else i only get partial parameter data.

>>i wonder now, if it might be possible to wrap the main method.
>>normally, the compiler links the runtime-file to the application
>>to make it runnable under the system. is there a way to tell the
>>compiler/linker that another function than main() should be used
>>as the entering point?

>>i appreciate any kind of help.

>>thanx in advance, clemi.

 
 
 

wrapping main method

Post by Surinder Kuma » Thu, 08 May 2003 22:28:19


Hi,
         The option -e<entry_point>  is there on AIX also.

         So, probably u can link the code using
        1.
            # ld -e new_main   local_obj.o  .. -l and -L for library.
        2.
        And from the new entry point call the original entry point.
        new_main() {
            get the args()
            call main()
        }

Regards
SurInder Kumar


Quote:> Hi,
> There is a way to change the entry point of your program.You'll have to
look at
> the options available with your linker.

> For ld on Solaris -e option does the trick.

> Thanx
> Kartika

.