ldfcn.5

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 5 代码 · 共 285 行

5
285
字号
.TH ldfcn 5 RISC.SH Nameldfcn \- common object file access routines.SH Syntax.nf.ft B.B #include <stdio.h>.B #include <filehdr.h>.B #include <syms.h>.B #include <ldfcn.h>.fi.ft R.SH DescriptionThe common object file access routines are a collection of functions that read an object file that is in common object file form.The calling program must know the detailed structure of theparts of the object file that it processes,but the calling program does not have to know the overall structureof the object file as the routines handle this function..PPThe interface between the calling program and the object file accessroutines is based onthe defined type.PN LDFILE(defined as.PN "struct ldfile" ),which is declared in the header file.PN <ldfcn.h>.Primarily, this structure provides uniform access tosimple object files and object files that are members of anarchive file..PPThe function.MS ldopen 3xallocates and initializes the.PN LDFILEstructure, reads in the symbol table header, if present, and returns a pointer to the structureto the calling program.The fields of the.PN LDFILEstructure can be accessed individually throughmacros defined in.PN <ldfcn.h>.The fields contain the following information:.TP 15\s-1LDFILE\s+1	\(**ldptr;.TP 15\s-1TYPE\s+1(ldptr)The file magic number, used to distinguish between archive members and simpleobject files..TP 15\s-1IOPTR\s+1(ldptr)The file pointer returned by .MS fopen 3s and used by the standard input/output functions..TP 15\s-1OFFSET\s+1(ldptr)The file address of the beginning of the object file;if the object file is a member of an archive file, the offset is nonzero..TP 15\s-1HEADER\s+1(ldptr)The file header structure of the object file..TP 15\s-1SYMHEADER\s+1(ldptr)The symbolic header structure for the symbol table associated with the objectfile..TP 15\s-1PFD\s+1(ldptr)The file table associated with the symbol table..TP 15\s-1SYMTAB\s+1(ldptr)A pointer to a copy of the symbol table in memory. It is accessed through thepCHDR structure (see .PN cmplrs/stsupport.h ). If no symbol table is present, this field is NULL.  This macro causes thewhole symbol table to be read..TP 15\s-1LDSWAP\s+1(ldptr)If the header and symbol table structures are swapped within the objectfile and all access requires using .PN libsex, this field is set to true.  Note that if you use .PN libmldroutines, all structures, except the optional header and auxiliaries, are swapped..PPThe object file access functions can be divided into fourcategories:.RS.PP(1)  Functions that open or close an object file.PP.RS.MS ldopen 3xand.PN ldaopen.RSopen a common object file.RE.MS ldclose 3xand.PN ldaclose.RSclose a common object file.RE.RE.PP(2)  Functions that return header or symbol table information.PP.RS.MS ldahread 3x.RSread the archive header of a member of an archive file.RE.MS ldfhread 3x.RSread the file header of a common object file.RE.MS ldshread 3xand.PN ldnshread.RSread a section header of a common object file.RE.MS ldtbread 3x.RSread a symbol table entry of a common object file.RE.MS ldgetname 3x.RSretrieve a symbol name from a symbol table entry or from the string table.RE.MS ldgetaux 3x.RSretrieve a pointer into the aux table for the specified ldptr.RE.MS ldgetsymstr 3x.RScreate a type string (for example, C declarations) for the specified symbol.RE.MS ldgetpd 3x.RSretrieve a procedure descriptor.RE.MS ldgetrfd 3x.RSretrieve a relative file table entry.RE.RE.PP(3)  Functions that position (seek to) an object file at the start of the section, relocation,or line number information for a particular section.PP.RS.MS ldohseek 3x.RSseek to the optional file header of a common object file.RE.MS ldsseek 3xand.PN ldnsseek.RSseek to a section of a common object file.RE.MS ldrseek 3xand.PN ldnrseek.RSseek to the relocation information for a section of a commonobject file.RE.MS ldlseek 3xand.PN ldnlseek.RSseek to the line number information for a section of a common object file.RE.MS ldtbseek 3x.RSseek to the symbol table of a common object file.RE.RE.PP(4) Miscellaneous functions.RS.MS ldtbindex 3x.RSreturn the index of a particular common object file symbol table entry.RE.MS ranhashinit 3x.RSinitialize the tables and constantsso that the archive hash and lookup routines can work.RE.MS ranhash 3x.RSgive a string return the hash index for it.RE.MS ranlookup 3x.RSreturn an archive hash bucket that is empty or matches the string argument.RE.MS disassembler 3x.RSprint MIPS assembly instructions.RE.MS ldreadst 3x.RScause a section of the symbol table to be read.RE.RE.PPThese functions are described in detail in the manual pages identified for each function..PPThe.PN ldopenand .PN ldaopenfunctions both return pointers to a.PN LDFILEstructure..SH MacrosAdditional access to an object file is provided through a set of macrosdefined in.PN <ldfcn.h>.These macros parallel the standardinput\/output file reading and manipulating functions.  Theytranslate a reference of the.PN LDFILEstructure into a reference to its file descriptor field..PP.ne 4The following macros are provided:.PP.RS.nfGETC(ldptr)FGETC(ldptr)GETW(ldptr)UNGETC(c, ldptr)FGETS(s, n, ldptr)FREADM((char \(**) ptr, sizeof (\(**ptr), nitems, ldptr)FSEEK(ldptr, offset, ptrname)FTELL(ldptr)REWIND(ldptr)FEOF(ldptr)FERROR(ldptr)FILENO(ldptr)SETBUF(ldptr, buf)STROFFSET(ldptr).RE.fi.PPThe STROFFSET macro calculates the address of the localsymbol's string table in an object file.See the manual entries for the corresponding standard input/output libraryfunctions for details on the use of these macros.  (The functionsare identified as 3s in Section 3 of the reference pages.).SH RestrictionsThe macro.PN FSEEKdefined in the header file.PN <ldfcn.h>translates into a call to the standard input/output function.MS fseek 3s ..PN FSEEKshould not be used to seek from the end of an archive file sincethe end of an archive file cannot be the same as the end of one ofits object file members..SH See Alsoar(1),fopen(3s), fseek(3s), ldahread(3x), ldclose(3x), ldfhread(3x),ldgetname(3x), ldlread(3x), ldlseek(3x),ldohseek(3x), ldopen(3x), ldrseek(3x), ldlseek(3x),ldshread(3x), ldtbindex(3x), ldtbread(3x), ldtbseek(3x)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?