This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

calling function in .init and .fini gives problem


I tried to run following program, but is giving "Illegal instruction" error
after function premain is called. Can somebody correct me, what I am doing
wrong?


#include <stdio.h>

int __attribute__((__section__(".init"))) premain(void) {
    printf("it should appear before main!!!\n");
    return 0;
}

int main(void) {
    printf("******************\n");
    printf("in main\n");
    printf("main is returning\n");
    printf("******************\n");
    return 0;
}

static int __attribute__((__section__(".fini"))) postmain(void) {
    printf("it should appear after main!!!\n");
    return 0;
}


Regards
Mohanlal

P.S. Please cc me in reply, I am not subscribed to list.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]