To
change the entry point of the Program
I want to change the entry point of the program. Here is the sample code for which works fine in DEC. void __init_mystart ()
main ()
This will work fine in DEC because there
is option in ld if the function starts with __init DEC will call the function
before main. If i want to do that in Solaris I have to complie the with
-e options i.e, -e __init_mystart. If i run the program it is give Segmentation
Fault core dump
Thanks...Srini I guess something is wrong with ld.so.1 or the crtx.o's (runtime loader linker). Here is my experience
on the issue:
crt1.o actually defines
main as external and has 'call main' in _start. After main is finished
executing it does exit(main) and then
This I found in notes
that I did not know until I read it today:
In case of 5, in
simple words, compiler just refers to the first function as program entry
point if none of the above are present
Problem of coredump
seems to be in the exit routine that does exit(main). And since main is
not loaded as pgm entry point the
This is all I could
help you with solaris right now. Let me see if I can find you more information
on this issue. This may very well
To see what I'm talking,
play with cc using the '-#' option. This will set the verbose mode in SUNWspro
compiler product, and
Have fun I actually stumbled upon this information while investigating other stuff. Solaris C compiler (SUNWSpro pkg) defines 2 #pragma preprocessor directives that can change the entry and exit point of the program. #pragma init (function ,[...function])
You can have a list here. Sample program below will explain better... #include <stdio.h> void ajay(); #pragma init (ajay)
main() {
} void ajay() { printf("Hello world\n"); } Hope this solves your problem. Have fun.
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|