Back to index

glibc  2.9
dl-static.c
Go to the documentation of this file.
00001 /* Variable initialization.  IA-64 version.
00002    Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <ldsodefs.h>
00021 
00022 #ifdef SHARED
00023 
00024 void
00025 _dl_var_init (void *array[])
00026 {
00027   /* It has to match "variables" below. */
00028   enum
00029     {
00030       DL_PAGESIZE = 0,
00031       DL_CLKTCK
00032     };
00033 
00034   GLRO(dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
00035   GLRO(dl_clktck) = *((int *) array[DL_CLKTCK]);
00036 }
00037 
00038 #else
00039 #include <bits/libc-lock.h>
00040 
00041 __libc_lock_define_initialized_recursive (static, _dl_static_lock)
00042 
00043 static void *variables[] =
00044 {
00045   &GLRO(dl_pagesize),
00046   &GLRO(dl_clktck)
00047 };
00048 
00049 void
00050 _dl_static_init (struct link_map *map)
00051 {
00052   const ElfW(Sym) *ref = NULL;
00053   lookup_t loadbase;
00054   void (*f) (void *[]);
00055 
00056   __libc_lock_lock_recursive (_dl_static_lock);
00057 
00058   loadbase = _dl_lookup_symbol_x ("_dl_var_init", map, &ref,
00059                               map->l_local_scope, NULL, 0, 1, NULL);
00060   if (ref != NULL)
00061     {
00062       f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
00063       f (variables);
00064     }
00065 
00066   __libc_lock_unlock_recursive (_dl_static_lock);
00067 }
00068 
00069 #endif