This is the mail archive of the
mailing list for the GCC project.
Re: at exit alternative for AIX
I need more help on this project.
collect2 is dying when it calls ld for the first time because __dso_handle is not defined. It is being reference from the calls to __cxa_atexit.
What I had planned to do was define it in the small .c stub that collect2 creates but that doesn't get created until later. I have added __cxa_atexit and __cxa_finalize in the libstdc++ library instead of the libgcc library because it is only used by g++ and not gcc. I don't mind changing that but I have other problems. Also, adding things to libgcc (looking at the build stuff) is much more confusing.
The help I need is how to initialize __dso_handle. The approach I had planned was to either add:
void *__dso_handle = &__dso_handle;
void *__dso_handle = 0;
to the .c stub depending up the value shared_obj. This would cause __cxa_finalize to act correctly in both the case of it being called when a shared object is being unloaded (the argument is not null) and when it is called when main is exiting (the argument is null).
__dso_handle can't be defined in libgcc or any other library. It needs to be local to the main or the shared object. But I don't know how to get the first ld to pass.