xref: /utopia/UTPA2-700.0.x/projects/tools/lint/mips-linux-gnu_include/link.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1*53ee8cc1Swenshuai.xi /* Data structure for communication from the run-time dynamic linker for
2*53ee8cc1Swenshuai.xi    loaded ELF shared objects.
3*53ee8cc1Swenshuai.xi    Copyright (C) 1995-2001, 2004, 2005, 2006 Free Software Foundation, Inc.
4*53ee8cc1Swenshuai.xi    This file is part of the GNU C Library.
5*53ee8cc1Swenshuai.xi 
6*53ee8cc1Swenshuai.xi    The GNU C Library is free software; you can redistribute it and/or
7*53ee8cc1Swenshuai.xi    modify it under the terms of the GNU Lesser General Public
8*53ee8cc1Swenshuai.xi    License as published by the Free Software Foundation; either
9*53ee8cc1Swenshuai.xi    version 2.1 of the License, or (at your option) any later version.
10*53ee8cc1Swenshuai.xi 
11*53ee8cc1Swenshuai.xi    The GNU C Library is distributed in the hope that it will be useful,
12*53ee8cc1Swenshuai.xi    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*53ee8cc1Swenshuai.xi    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*53ee8cc1Swenshuai.xi    Lesser General Public License for more details.
15*53ee8cc1Swenshuai.xi 
16*53ee8cc1Swenshuai.xi    You should have received a copy of the GNU Lesser General Public
17*53ee8cc1Swenshuai.xi    License along with the GNU C Library; if not, write to the Free
18*53ee8cc1Swenshuai.xi    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19*53ee8cc1Swenshuai.xi    02111-1307 USA.  */
20*53ee8cc1Swenshuai.xi 
21*53ee8cc1Swenshuai.xi #ifndef	_LINK_H
22*53ee8cc1Swenshuai.xi #define	_LINK_H	1
23*53ee8cc1Swenshuai.xi 
24*53ee8cc1Swenshuai.xi #include <features.h>
25*53ee8cc1Swenshuai.xi #include <elf.h>
26*53ee8cc1Swenshuai.xi #include <dlfcn.h>
27*53ee8cc1Swenshuai.xi #include <sys/types.h>
28*53ee8cc1Swenshuai.xi 
29*53ee8cc1Swenshuai.xi /* We use this macro to refer to ELF types independent of the native wordsize.
30*53ee8cc1Swenshuai.xi    `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'.  */
31*53ee8cc1Swenshuai.xi #define ElfW(type)	_ElfW (Elf, __ELF_NATIVE_CLASS, type)
32*53ee8cc1Swenshuai.xi #define _ElfW(e,w,t)	_ElfW_1 (e, w, _##t)
33*53ee8cc1Swenshuai.xi #define _ElfW_1(e,w,t)	e##w##t
34*53ee8cc1Swenshuai.xi 
35*53ee8cc1Swenshuai.xi #include <bits/elfclass.h>		/* Defines __ELF_NATIVE_CLASS.  */
36*53ee8cc1Swenshuai.xi #include <bits/link.h>
37*53ee8cc1Swenshuai.xi 
38*53ee8cc1Swenshuai.xi /* Rendezvous structure used by the run-time dynamic linker to communicate
39*53ee8cc1Swenshuai.xi    details of shared object loading to the debugger.  If the executable's
40*53ee8cc1Swenshuai.xi    dynamic section has a DT_DEBUG element, the run-time linker sets that
41*53ee8cc1Swenshuai.xi    element's value to the address where this structure can be found.  */
42*53ee8cc1Swenshuai.xi 
43*53ee8cc1Swenshuai.xi struct r_debug
44*53ee8cc1Swenshuai.xi   {
45*53ee8cc1Swenshuai.xi     int r_version;		/* Version number for this protocol.  */
46*53ee8cc1Swenshuai.xi 
47*53ee8cc1Swenshuai.xi     struct link_map *r_map;	/* Head of the chain of loaded objects.  */
48*53ee8cc1Swenshuai.xi 
49*53ee8cc1Swenshuai.xi     /* This is the address of a function internal to the run-time linker,
50*53ee8cc1Swenshuai.xi        that will always be called when the linker begins to map in a
51*53ee8cc1Swenshuai.xi        library or unmap it, and again when the mapping change is complete.
52*53ee8cc1Swenshuai.xi        The debugger can set a breakpoint at this address if it wants to
53*53ee8cc1Swenshuai.xi        notice shared object mapping changes.  */
54*53ee8cc1Swenshuai.xi     ElfW(Addr) r_brk;
55*53ee8cc1Swenshuai.xi     enum
56*53ee8cc1Swenshuai.xi       {
57*53ee8cc1Swenshuai.xi 	/* This state value describes the mapping change taking place when
58*53ee8cc1Swenshuai.xi 	   the `r_brk' address is called.  */
59*53ee8cc1Swenshuai.xi 	RT_CONSISTENT,		/* Mapping change is complete.  */
60*53ee8cc1Swenshuai.xi 	RT_ADD,			/* Beginning to add a new object.  */
61*53ee8cc1Swenshuai.xi 	RT_DELETE		/* Beginning to remove an object mapping.  */
62*53ee8cc1Swenshuai.xi       } r_state;
63*53ee8cc1Swenshuai.xi 
64*53ee8cc1Swenshuai.xi     ElfW(Addr) r_ldbase;	/* Base address the linker is loaded at.  */
65*53ee8cc1Swenshuai.xi   };
66*53ee8cc1Swenshuai.xi 
67*53ee8cc1Swenshuai.xi /* This is the instance of that structure used by the dynamic linker.  */
68*53ee8cc1Swenshuai.xi extern struct r_debug _r_debug;
69*53ee8cc1Swenshuai.xi 
70*53ee8cc1Swenshuai.xi /* This symbol refers to the "dynamic structure" in the `.dynamic' section
71*53ee8cc1Swenshuai.xi    of whatever module refers to `_DYNAMIC'.  So, to find its own
72*53ee8cc1Swenshuai.xi    `struct r_debug', a program could do:
73*53ee8cc1Swenshuai.xi      for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn)
74*53ee8cc1Swenshuai.xi        if (dyn->d_tag == DT_DEBUG)
75*53ee8cc1Swenshuai.xi 	 r_debug = (struct r_debug *) dyn->d_un.d_ptr;
76*53ee8cc1Swenshuai.xi    */
77*53ee8cc1Swenshuai.xi extern ElfW(Dyn) _DYNAMIC[];
78*53ee8cc1Swenshuai.xi 
79*53ee8cc1Swenshuai.xi /* Structure describing a loaded shared object.  The `l_next' and `l_prev'
80*53ee8cc1Swenshuai.xi    members form a chain of all the shared objects loaded at startup.
81*53ee8cc1Swenshuai.xi 
82*53ee8cc1Swenshuai.xi    These data structures exist in space used by the run-time dynamic linker;
83*53ee8cc1Swenshuai.xi    modifying them may have disastrous results.  */
84*53ee8cc1Swenshuai.xi 
85*53ee8cc1Swenshuai.xi struct link_map
86*53ee8cc1Swenshuai.xi   {
87*53ee8cc1Swenshuai.xi     /* These first few members are part of the protocol with the debugger.
88*53ee8cc1Swenshuai.xi        This is the same format used in SVR4.  */
89*53ee8cc1Swenshuai.xi 
90*53ee8cc1Swenshuai.xi     ElfW(Addr) l_addr;		/* Base address shared object is loaded at.  */
91*53ee8cc1Swenshuai.xi     char *l_name;		/* Absolute file name object was found in.  */
92*53ee8cc1Swenshuai.xi     ElfW(Dyn) *l_ld;		/* Dynamic section of the shared object.  */
93*53ee8cc1Swenshuai.xi     struct link_map *l_next, *l_prev; /* Chain of loaded objects.  */
94*53ee8cc1Swenshuai.xi   };
95*53ee8cc1Swenshuai.xi 
96*53ee8cc1Swenshuai.xi #ifdef __USE_GNU
97*53ee8cc1Swenshuai.xi 
98*53ee8cc1Swenshuai.xi /* Version numbers for la_version handshake interface.  */
99*53ee8cc1Swenshuai.xi #define LAV_CURRENT	1
100*53ee8cc1Swenshuai.xi 
101*53ee8cc1Swenshuai.xi /* Activity types signaled through la_activity.  */
102*53ee8cc1Swenshuai.xi enum
103*53ee8cc1Swenshuai.xi   {
104*53ee8cc1Swenshuai.xi     LA_ACT_CONSISTENT,		/* Link map consistent again.  */
105*53ee8cc1Swenshuai.xi     LA_ACT_ADD,			/* New object will be added.  */
106*53ee8cc1Swenshuai.xi     LA_ACT_DELETE		/* Objects will be removed.  */
107*53ee8cc1Swenshuai.xi   };
108*53ee8cc1Swenshuai.xi 
109*53ee8cc1Swenshuai.xi /* Values representing origin of name for dynamic loading.  */
110*53ee8cc1Swenshuai.xi enum
111*53ee8cc1Swenshuai.xi   {
112*53ee8cc1Swenshuai.xi     LA_SER_ORIG = 0x01,		/* Original name.  */
113*53ee8cc1Swenshuai.xi     LA_SER_LIBPATH = 0x02,	/* Directory from LD_LIBRARY_PATH.  */
114*53ee8cc1Swenshuai.xi     LA_SER_RUNPATH = 0x04,	/* Directory from RPATH/RUNPATH.  */
115*53ee8cc1Swenshuai.xi     LA_SER_CONFIG = 0x08,	/* Found through ldconfig.  */
116*53ee8cc1Swenshuai.xi     LA_SER_DEFAULT = 0x40,	/* Default directory.  */
117*53ee8cc1Swenshuai.xi     LA_SER_SECURE = 0x80	/* Unused.  */
118*53ee8cc1Swenshuai.xi   };
119*53ee8cc1Swenshuai.xi 
120*53ee8cc1Swenshuai.xi /* Values for la_objopen return value.  */
121*53ee8cc1Swenshuai.xi enum
122*53ee8cc1Swenshuai.xi   {
123*53ee8cc1Swenshuai.xi     LA_FLG_BINDTO = 0x01,	/* Audit symbols bound to this object.  */
124*53ee8cc1Swenshuai.xi     LA_FLG_BINDFROM = 0x02	/* Audit symbols bound from this object.  */
125*53ee8cc1Swenshuai.xi   };
126*53ee8cc1Swenshuai.xi 
127*53ee8cc1Swenshuai.xi /* Values for la_symbind flags parameter.  */
128*53ee8cc1Swenshuai.xi enum
129*53ee8cc1Swenshuai.xi   {
130*53ee8cc1Swenshuai.xi     LA_SYMB_NOPLTENTER = 0x01,	/* la_pltenter will not be called.  */
131*53ee8cc1Swenshuai.xi     LA_SYMB_NOPLTEXIT = 0x02,	/* la_pltexit will not be called.  */
132*53ee8cc1Swenshuai.xi     LA_SYMB_STRUCTCALL = 0x04,	/* Return value is a structure.  */
133*53ee8cc1Swenshuai.xi     LA_SYMB_DLSYM = 0x08,	/* Binding due to dlsym call.  */
134*53ee8cc1Swenshuai.xi     LA_SYMB_ALTVALUE = 0x10	/* Value has been changed by a previous
135*53ee8cc1Swenshuai.xi 				   la_symbind call.  */
136*53ee8cc1Swenshuai.xi   };
137*53ee8cc1Swenshuai.xi 
138*53ee8cc1Swenshuai.xi struct dl_phdr_info
139*53ee8cc1Swenshuai.xi   {
140*53ee8cc1Swenshuai.xi     ElfW(Addr) dlpi_addr;
141*53ee8cc1Swenshuai.xi     const char *dlpi_name;
142*53ee8cc1Swenshuai.xi     const ElfW(Phdr) *dlpi_phdr;
143*53ee8cc1Swenshuai.xi     ElfW(Half) dlpi_phnum;
144*53ee8cc1Swenshuai.xi 
145*53ee8cc1Swenshuai.xi     /* Note: Following members were introduced after the first
146*53ee8cc1Swenshuai.xi        version of this structure was available.  Check the SIZE
147*53ee8cc1Swenshuai.xi        argument passed to the dl_iterate_phdr callback to determine
148*53ee8cc1Swenshuai.xi        whether or not each later member is available.  */
149*53ee8cc1Swenshuai.xi 
150*53ee8cc1Swenshuai.xi     /* Incremented when a new object may have been added.  */
151*53ee8cc1Swenshuai.xi     unsigned long long int dlpi_adds;
152*53ee8cc1Swenshuai.xi     /* Incremented when an object may have been removed.  */
153*53ee8cc1Swenshuai.xi     unsigned long long int dlpi_subs;
154*53ee8cc1Swenshuai.xi 
155*53ee8cc1Swenshuai.xi     /* If there is a PT_TLS segment, its module ID as used in
156*53ee8cc1Swenshuai.xi        TLS relocations, else zero.  */
157*53ee8cc1Swenshuai.xi     size_t dlpi_tls_modid;
158*53ee8cc1Swenshuai.xi 
159*53ee8cc1Swenshuai.xi     /* The address of the calling thread's instance of this module's
160*53ee8cc1Swenshuai.xi        PT_TLS segment, if it has one and it has been allocated
161*53ee8cc1Swenshuai.xi        in the calling thread, otherwise a null pointer.  */
162*53ee8cc1Swenshuai.xi     void *dlpi_tls_data;
163*53ee8cc1Swenshuai.xi   };
164*53ee8cc1Swenshuai.xi 
165*53ee8cc1Swenshuai.xi __BEGIN_DECLS
166*53ee8cc1Swenshuai.xi 
167*53ee8cc1Swenshuai.xi extern int dl_iterate_phdr (int (*__callback) (struct dl_phdr_info *,
168*53ee8cc1Swenshuai.xi 					       size_t, void *),
169*53ee8cc1Swenshuai.xi 			    void *__data);
170*53ee8cc1Swenshuai.xi 
171*53ee8cc1Swenshuai.xi 
172*53ee8cc1Swenshuai.xi /* Prototypes for the ld.so auditing interfaces.  These are not
173*53ee8cc1Swenshuai.xi    defined anywhere in ld.so but instead have to be provided by the
174*53ee8cc1Swenshuai.xi    auditing DSO.  */
175*53ee8cc1Swenshuai.xi extern unsigned int la_version (unsigned int __version);
176*53ee8cc1Swenshuai.xi extern void la_activity (uintptr_t *__cookie, unsigned int __flag);
177*53ee8cc1Swenshuai.xi extern char *la_objsearch (const char *__name, uintptr_t *__cookie,
178*53ee8cc1Swenshuai.xi 			   unsigned int __flag);
179*53ee8cc1Swenshuai.xi extern unsigned int la_objopen (struct link_map *__map, Lmid_t __lmid,
180*53ee8cc1Swenshuai.xi 				uintptr_t *__cookie);
181*53ee8cc1Swenshuai.xi extern void la_preinit (uintptr_t *__cookie);
182*53ee8cc1Swenshuai.xi extern uintptr_t la_symbind32 (Elf32_Sym *__sym, unsigned int __ndx,
183*53ee8cc1Swenshuai.xi 			       uintptr_t *__refcook, uintptr_t *__defcook,
184*53ee8cc1Swenshuai.xi 			       unsigned int *__flags, const char *__symname);
185*53ee8cc1Swenshuai.xi extern uintptr_t la_symbind64 (Elf64_Sym *__sym, unsigned int __ndx,
186*53ee8cc1Swenshuai.xi 			       uintptr_t *__refcook, uintptr_t *__defcook,
187*53ee8cc1Swenshuai.xi 			       unsigned int *__flags, const char *__symname);
188*53ee8cc1Swenshuai.xi extern unsigned int la_objclose (uintptr_t *__cookie);
189*53ee8cc1Swenshuai.xi 
190*53ee8cc1Swenshuai.xi __END_DECLS
191*53ee8cc1Swenshuai.xi 
192*53ee8cc1Swenshuai.xi #endif
193*53ee8cc1Swenshuai.xi 
194*53ee8cc1Swenshuai.xi #endif /* link.h */
195