3 symopen, symclose, indexsym, lookupsym, findsym,
4 lookuplsym, indexlsym, findlsym,
5 symoff, pc2file, file2pc, line2pc, fnbound, fileline,
6 pc2line \- symbol table access functions
14 .ta \w'\fBxxxxxx'u +\w'\fBxxxxxx'u
16 int symopen(Fhdr *hdr)
18 void symclose(Fhdr *hdr)
21 int indexsym(uint n, Symbol *s)
23 int lookupsym(char *fn, char *var, Symbol *s)
25 int findsym(Loc loc, uint class, Symbol *s)
28 int indexlsym(Symbol *s1, uint n, Symbol *s2)
30 int lookuplsym(Symbol *s1, char *name, Symbol *s2)
32 int findlsym(Symbol *s1, Loc loc, Symbol *s2)
35 int symoff(char *a, uint n, ulong addr, uint class)
38 int pc2file(ulong pc, char *file, uint n, ulong *line)
40 int pc2line(ulong pc, ulong *line)
42 int fileline(ulong pc, char *buf, uint n)
44 int file2pc(char *file, ulong line, ulong *pc)
46 int line2pc(ulong basepc, ulong line, ulong *pc)
48 int fnbound(ulong pc, ulong bounds[2])
50 These functions provide machine-independent access to the
51 symbol table of an executable file or executing process.
56 describe additional library functions for
57 accessing executable files and executing processes.
66 to initialize in-memory structures used to access the symbol
67 tables contained in the file.
70 The rest of the functions described here access a composite
71 symbol table made up of all currently open tables.
80 typedef struct Symbol Symbol;
93 describes a symbol table entry.
96 field contains the offset of the symbol within its
97 address space: global variables relative to the beginning
98 of the data segment, text beyond the start of the text
99 segment, and automatic variables and parameters relative
100 to the stack frame. The
102 field contains the type of the symbol:
109 static text segment symbol
115 static data segment symbol
121 static bss segment symbol
124 automatic (local) variable symbol
127 function parameter symbol
133 field assigns the symbol to a general class;
139 are the most popular.
142 stores information for the
146 The symbols are ordered by increasing address.
151 structure with symbol table information. Global variables
152 and functions are represented by a single name; local variables
153 and parameters are uniquely specified by a function and
154 variable name pair. Arguments
159 name of a function and variable, respectively.
161 are non-zero, the symbol table is searched for a parameter
162 or automatic variable. If only
165 zero, the text symbol table is searched for function
169 is zero, the global variable table
174 returns the symbol table entry of type
178 The selected symbol is a global variable or function with
179 address nearest to and less than or equal to
183 searches only the global variable symbol table; class
185 limits the search to the text symbol table.
188 searches the text table first, then the global table.
199 but operate on the smaller symbol table of parameters and
200 variables local to the function represented by symbol
204 writes symbol information for the
206 local symbol of function
210 Function parameters appear first in the ordering, followed by local symbols.
213 writes symbol information for the symbol named
221 searches for a symbol local to the function
223 whose location is exactly
225 writing its symbol information to
228 is almost always an indirection through a frame pointer register;
229 the details vary from architecture to architecture.
232 converts a location to a symbol reference.
233 The string containing that reference is of the form
234 `name+offset', where `name' is the name of the
235 nearest symbol with an address less than or equal to the
236 target address, and `offset' is the hexadecimal offset beyond
237 that symbol. If `offset' is zero, only the name of the
239 If no symbol is found within 4096 bytes of the address, the address
240 is formatted as a hexadecimal address.
242 is the address of a buffer of
244 bytes to receive the formatted string.
246 is the address to be converted.
248 is the type code of the search space:
254 returns the length of the formatted string contained in
258 searches the symbol table to find the file and line number
259 corresponding to the instruction at program counter
262 is the address of a buffer of
264 bytes to receive the file name.
266 receives the line number.
271 but neglects to return information about the source file.
276 but returns the file and line number in the
284 performs the opposite mapping:
287 a text address associated with
294 is similar: it converts a line number to an
295 instruction address, storing it in
297 Since a line number does not uniquely identify an
298 instruction (e.g., every source file has line 1),
300 specifies a text address from which
302 Usually this is the address of the first function in the
306 returns the start and end addresses of the function containing
307 the text address supplied as the first argument.
308 The second argument is an array of two unsigned longs;
310 places the bounding addresses of the function in the
311 first and second elements of this array.
312 The start address is the address of the first instruction of the function;
313 the end address is the first address beyond the end of the target function.
315 All functions return 0 on success and \-1 on error.
316 When an error occurs, a message describing it is stored
317 in the system error buffer where it is available via