This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc/ld init section and libraries
- From: Falk Hueffner <falk at debian dot org>
- To: "John Donoghue" <john dot donoghue at ieee dot org>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 11 Aug 2006 15:00:50 +0200
- Subject: Re: gcc/ld init section and libraries
- References: <20060811123233.EC7EA33EE76@mail.sa.chariot.net.au>
"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() {
puts("foo");
}
int main() {
puts("bar");
return 0;
}
--
Falk