Back to index

glibc  2.9
dl-lookupcfg.h
Go to the documentation of this file.
00001 /* Configuration of lookup functions.
00002    Copyright (C) 2000, 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 #define ELF_FUNCTION_PTR_IS_SPECIAL
00021 #define DL_UNMAP_IS_SPECIAL
00022 
00023 #include <dl-fptr.h>
00024 
00025 /* Forward declaration.  */
00026 struct link_map;
00027 
00028 void *_dl_symbol_address (struct link_map *map, const ElfW(Sym) *ref);
00029 
00030 #define DL_SYMBOL_ADDRESS(map, ref) _dl_symbol_address(map, ref)
00031 
00032 Elf32_Addr _dl_lookup_address (const void *address);
00033 
00034 /* Clear the bottom two bits so generic code can find the fdesc entry */
00035 #define DL_LOOKUP_ADDRESS(addr) \
00036   (_dl_lookup_address ((void *)((unsigned long)addr & ~3)))
00037 
00038 void _dl_unmap (struct link_map *map);
00039 
00040 #define DL_UNMAP(map) _dl_unmap (map)
00041 
00042 #define DL_AUTO_FUNCTION_ADDRESS(map, addr)                           \
00043 ({                                                             \
00044   unsigned int fptr[2];                                               \
00045   fptr[0] = (unsigned int) (addr);                             \
00046   fptr[1] = (map)->l_info[DT_PLTGOT]->d_un.d_ptr;                     \
00047   /* Set bit 30 to indicate to $$dyncall that this is a PLABEL. */    \
00048   (ElfW(Addr))((unsigned int)fptr | 2);                               \
00049 })
00050 
00051 #define DL_STATIC_FUNCTION_ADDRESS(map, addr)                         \
00052 ({                                                             \
00053   static unsigned int fptr[2];                                        \
00054   fptr[0] = (unsigned int) (addr);                             \
00055   fptr[1] = (map)->l_info[DT_PLTGOT]->d_un.d_ptr;                     \
00056   /* Set bit 30 to indicate to $$dyncall that this is a PLABEL. */    \
00057   (ElfW(Addr))((unsigned int)fptr | 2);                               \
00058 })
00059 
00060 
00061 /* The test for "addr & 2" below is to accomodate old binaries which
00062    violated the ELF ABI by pointing DT_INIT and DT_FINI at a function
00063    descriptor.  */
00064 #define DL_DT_INIT_ADDRESS(map, addr) \
00065   ((Elf32_Addr)(addr) & 2 ? (addr) : DL_AUTO_FUNCTION_ADDRESS (map, addr))
00066 #define DL_DT_FINI_ADDRESS(map, addr) \
00067   ((Elf32_Addr)(addr) & 2 ? (addr) : DL_AUTO_FUNCTION_ADDRESS (map, addr))
00068 
00069 /* The type of the return value of fixup/profile_fixup */
00070 #define DL_FIXUP_VALUE_TYPE struct fdesc
00071 
00072 /* Construct a fixup value from the address and linkmap */
00073 #define DL_FIXUP_MAKE_VALUE(map, addr) \
00074    ((struct fdesc) { (addr), (map)->l_info[DT_PLTGOT]->d_un.d_ptr })
00075 
00076 /* Extract the code address from a fixup value */
00077 #define DL_FIXUP_VALUE_CODE_ADDR(value) ((value).ip)
00078 #define DL_FIXUP_VALUE_ADDR(value) ((uintptr_t) &(value))
00079 #define DL_FIXUP_ADDR_VALUE(addr) (*(struct fdesc *) (addr))
00080