Back to index

glibc  2.9
tst-array5.c
Go to the documentation of this file.
00001 #include <string.h>
00002 #include <unistd.h>
00003 
00004 static void
00005 preinit_0 (int argc __attribute__ ((unused)), char **argv)
00006 {
00007   char *p = strrchr (argv [0], '/');
00008 
00009   if (p == NULL)
00010       return;
00011 
00012   p++;
00013   size_t len = strlen (p);
00014   write (STDOUT_FILENO, "preinit array in executable: ", 29);
00015   write (STDOUT_FILENO, p, len);
00016   write (STDOUT_FILENO, "\n", 1);
00017 }
00018 
00019 void (*const preinit_array []) (int, char **)
00020      __attribute__ ((section (".preinit_array"), aligned (sizeof (void *)))) =
00021 {
00022   &preinit_0,
00023 };
00024 
00025 static void
00026 init_0 (int argc __attribute__ ((unused)), char **argv)
00027 {
00028   char *p = strrchr (argv [0], '/');
00029 
00030   if (p == NULL)
00031       return;
00032 
00033   p++;
00034   size_t len = strlen (p);
00035   write (STDOUT_FILENO, "init array in executable: ", 26);
00036   write (STDOUT_FILENO, p, len);
00037   write (STDOUT_FILENO, "\n", 1);
00038 }
00039 
00040 void (*const init_array []) (int, char **)
00041      __attribute__ ((section (".init_array"), aligned (sizeof (void *)))) =
00042 {
00043   &init_0,
00044 };
00045 
00046 int
00047 main (void)
00048 {
00049   return 0;
00050 }