[lsb-discuss] atexit()

Robert Schweikert robert.schweikert at mathworks.com
Fri Oct 19 07:08:12 PDT 2007


I ran a quick trial and there is definitely some magic going on with 
gcc. The magic happens at link time. Consider the following simple code:

-> cat atExistTest.c
#include <stdlib.h>

void myExitFunc()
{
}

int callExitFunc()
{
    return atexit(myExitFunc);
}

When compiled to an object file the atexit() call remains:

-> nm -Bg atExistTest.o | grep atexit
                 U atexit

taking this a step further to the assembly level atexit still shows up.

->  cat atExistTest.s | grep atexit
        call    atexit

However, once we generate the executable (or so) the plain atexit 
disappears:

-> nm -Bg atexitLib.so | grep atexit
                 U __cxa_atexit@@GLIBC_2.2.5

Thus atexit() appears to have a weird state with respect to the LSB 
specification, looks like we should map the atexit() source interface to 
__cxa_atexit binary interface w.r.t. appchk. I don't like specifying 
anything starting with __ but we may not have a choice here since the 
symbol does show up and appchk would certainly complain.

Robert

-- 
Robert Schweikert                       MAY THE SOURCE BE WITH YOU
(robert.schweikert at mathworks.com)                 LINUX
The MathWorks Inc.
Phone : 508-647-2042






More information about the lsb-discuss mailing list