gcc_lib_dynamque
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
gcc_lib_dynamque [2007/03/27 23:23] – thierry | gcc_lib_dynamque [2007/03/28 13:37] (Version actuelle) – I don't like colored code thierry | ||
---|---|---|---|
Ligne 4: | Ligne 4: | ||
== Creer une librairie simple: == | == Creer une librairie simple: == | ||
- | | + | < |
- | #include < | + | #include < |
- | #include < | + | #include < |
- | | + | #include < |
- | static int lib_load = 0; | + | |
- | | + | static int lib_load = 0; |
- | unsigned int my_inc( unsigned int *value ) | + | |
- | { | + | unsigned int my_inc( unsigned int *value ) |
- | | + | { |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | | |
- | return( 0 ); | + | |
- | } | + | |
- | | + | } |
- | int my_stat( void ) | + | |
- | { | + | int my_stat( void ) |
- | | + | { |
- | } | + | |
- | | + | } |
- | void __attribute__ ((constructor)) onload( void ) | + | |
- | { | + | void __attribute__ ((constructor)) onload( void ) |
- | | + | { |
- | } | + | |
- | | + | } |
- | void __attribute__ ((destructor)) onunload( void ) | + | |
- | { | + | void __attribute__ ((destructor)) onunload( void ) |
- | | + | { |
- | } | + | |
+ | } | ||
+ | </ | ||
Pour compiler: | Pour compiler: | ||
Ligne 43: | Ligne 45: | ||
'' | '' | ||
- | == Demonstration | + | == Démonstration |
- | #include < | + | < |
- | #include < | + | #include < |
- | #include < | + | #include < |
- | + | #include < | |
- | int main( int argc, char *argv[] ) | + | |
- | { | + | int main( int argc, char *argv[] ) |
- | | + | { |
- | | + | |
- | | + | |
- | + | | |
- | | + | |
- | | + | |
- | printf(" | + | |
- | return EXIT_FAILURE; | + | printf(" |
- | | + | return EXIT_FAILURE; |
- | + | | |
- | | + | |
- | | + | |
- | printf(" | + | |
- | return EXIT_FAILURE; | + | printf(" |
- | | + | return EXIT_FAILURE; |
- | + | | |
- | | + | |
- | + | | |
- | | + | |
- | | + | |
- | printf(" | + | |
- | return EXIT_FAILURE; | + | printf(" |
- | | + | return EXIT_FAILURE; |
- | + | | |
- | | + | |
- | | + | |
- | + | | |
- | | + | |
- | + | | |
- | | + | |
- | } | + | |
+ | } | ||
+ | </ | ||
+ | |||
+ | Compiler: | ||
+ | $ gcc -g -Wall -o mytest mytest.c -ldl | ||
+ | |||
+ | A l' | ||
+ | $ ./mytest | ||
+ | my stat= 1 | ||
+ | v= 501 | ||
+ | Et voila pour les premiers tests... |
gcc_lib_dynamque.1175037835.txt.gz · Dernière modification : 2007/03/27 23:23 de thierry