3 syminit, getsym, symbase, pc2sp, pc2line, textseg, line2addr, lookup, findlocal,
4 getauto, findsym, localsym, globalsym, textsym, file2pc, fileelem, filesym,
5 fileline, fnbound \- symbol table access functions
17 int syminit(int fd, Fhdr *fp)
20 Sym *getsym(int index)
23 Sym *symbase(long *nsyms)
26 int fileelem(Sym **fp, uchar *encname, char *buf, int n)
29 int filesym(int index, char *buf, int n)
35 long pc2line(uvlong pc)
38 void textseg(uvlong base, Fhdr *fp)
41 uvlong line2addr(ulong line, uvlong basepc, uvlong endpc)
44 int lookup(char *fn, char *var, Symbol *s)
47 int findlocal(Symbol *s1, char *name, Symbol *s2)
50 int getauto(Symbol *s1, int off, int class, Symbol *s2)
53 int findsym(uvlong addr, int class, Symbol *s)
56 int localsym(Symbol *s, int index)
59 int globalsym(Symbol *s, int index)
62 int textsym(Symbol *s, int index)
65 uvlong file2pc(char *file, ulong line)
68 int fileline(char *str, int n, uvlong addr)
71 int fnbound(uvlong addr, uvlong *bounds)
73 These functions provide machine-independent access to the
74 symbol table of an executable file or executing process.
75 The latter is accessible by opening the device
76 .B /proc/\fIpid\fP/text
82 describe additional library functions
83 for processing executable and object files.
93 process the symbol table contained in an executable file
96 image of an executing program.
97 The symbol table is stored internally as an array of
99 data structures as defined in
109 to read the raw symbol tables from the open file descriptor
111 It returns the count of the number of symbols
112 or \-1 if an error occurs.
115 returns the address of the
123 returns the address of the first
125 structure in the symbol table. The number of
126 entries in the symbol table is returned in
130 converts a file name, encoded as described in
132 to a character string.
135 an array of pointers to file path components ordered by path index.
137 is the address of an array of encoded
138 file path components in the form of a
145 address of a receiving character buffer and its length.
147 returns the length of the null-terminated string
153 is a higher-level interface to
159 file and returns the length of the null-terminated string
163 File names are retrieved in no particular order, although
164 the order of retrieval does not vary from one pass to the next.
165 A zero is returned when
167 is too large or too small or an error occurs during file name
171 returns an offset associated with
172 a given value of the program counter. Adding this offset
173 to the current value of the stack pointer gives the address
174 of the current stack frame. This approach only applies
175 to the 68020 architecture; other architectures
176 use a fixed stack frame offset by a constant contained
177 in a dummy local variable (called
182 returns the line number of the statement associated
183 with the instruction address
186 line number is the absolute line number in the
187 source file as seen by the compiler after pre-processing; the
188 original line number in the source file may be derived from this
189 value using the history stacks contained in the symbol table.
194 must know the start and end addresses of the text segment
195 for proper operation. These values are calculated from the
196 file header by function
198 If the text segment address is changed, the application
201 to recalculate the boundaries of the segment.
203 is the new base address of the text segment and
207 data structure filled by
211 converts a line number to an instruction address. The
212 first argument is the absolute line number in
213 a file. Since a line number does not uniquely identify
214 an instruction location (e.g., every source file has line 1),
215 a second argument specifies a text address
216 from which the search begins. Usually this
217 is the address of the first function in the file of interest.
223 return \-1 in the case of an error.
235 operate on data structures riding above the raw symbol table.
236 These data structures occupy memory
237 and impose a startup penalty but speed retrievals
238 and provide higher-level access to the basic symbol
242 prior to using these functions.
249 void *handle; /* private */
259 describes a symbol table entry.
262 field contains the offset of the symbol within its
263 address space: global variables relative to the beginning
264 of the data segment, text beyond the start of the text
265 segment, and automatic variables and parameters relative
266 to the stack frame. The
268 field contains the type of the symbol as defined in
272 field assigns the symbol to a general class;
278 are the most popular.
283 structure with symbol table information. Global variables
284 and functions are represented by a single name; local variables
285 and parameters are uniquely specified by a function and
286 variable name pair. Arguments
291 name of a function and variable, respectively.
293 are non-zero, the symbol table is searched for a parameter
294 or automatic variable. If only
297 zero, the text symbol table is searched for function
301 is zero, the global variable table
308 with the symbol table data of the automatic variable
309 or parameter matching
314 data structure describing a function or a local variable;
315 the latter resolves to its owning function.
318 searches the local symbols associated with function
320 for an automatic variable or parameter located at stack
332 data structure to receive the symbol table information
333 of the desired symbol.
336 returns the symbol table entry of type
340 The selected symbol is a global variable or function
341 with address nearest to and less than or equal to
345 searches only the global variable symbol table; class
347 limits the search to the text symbol table.
350 searches the text table first, then the global table.
355 local variable in the function
359 may reference a function or a local variable; the latter
360 resolves to its owning function.
365 is filled with the data describing it.
370 with the symbol table information of the
377 with the symbol table information of the
379 text symbol. The text symbols are ordered
380 by increasing address.
383 returns a text address associated with
390 converts text address
393 line number in a source file. The result,
394 a null terminated character string of
404 returns the start and end addresses of the function containing
405 the text address supplied as the first argument. The second
406 argument is an array of two unsigned longs;
408 places the bounding addresses of the function in the first
409 and second elements of this array. The start address is the
410 address of the first instruction of the function; the end
411 address is the address of the start of the next function
412 in memory, so it is beyond the end of the target function.
414 returns 1 if the address is within a text function, or zero
415 if the address selects no function.
421 may produce inaccurate results when applied to
424 Unless otherwise specified, all functions return 1
425 on success, or 0 on error. When an error occurs,
426 a message describing it is stored in the system
427 error buffer where it is available via