gcc/ld init section and libraries

Falk Hueffner falk@debian.org
Fri Aug 11 13:01:00 GMT 2006

"John Donoghue" <john.donoghue@ieee.org> writes:

> Im not sure if this question belong in this list but ...
> I have a cross compiling suite for m68k-elf I am using for a small
> 68332 board and want to add some code that will be run (initialize
> some stuff for me) when the program runs.

You could try to use the "constructor" attribute:

#include <stdio.h>

void __attribute__((constructor)) f() {

int main() {
    return 0;


More information about the Gcc-help mailing list