ldgetpd.c

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 64 行

C
64
字号
/* --------------------------------------------------------- *//* | Copyright (c) 1986, 1989 MIPS Computer Systems, Inc.  | *//* | All Rights Reserved.                                  | *//* --------------------------------------------------------- *//* $Header: ldgetpd.c,v 2010.2.1.3 89/11/29 14:28:28 bettina Exp $ */#include <stdio.h>#include "filehdr.h"#include "syms.h"#include "ldfcn.h"longldgetpd(ldptr, ipd, ppd)	register LDFILE *ldptr;	register int	ipd;	pPDR ppd;{	extern int vldldptr();	extern char *malloc();	extern void free();	static pPDR pdtab = NULL;	static int last_fnum_ = 0;	static long last_offset = -1L;	static long length;	int ifd;	if (vldldptr(ldptr) != SUCCESS || PSYMTAB(ldptr) == NULL)		return (FAILURE);	if (ldreadst(ldptr,ST_PPDS|ST_PSYMS) == FAILURE)	    return(NULL);	/*	* Different archive members are noted by the OFFSET change.	* Otherwise, normal other ldptr's are distinguished by	* the different _fnum_'s.	*/	if (last_offset != OFFSET(ldptr) ||		last_fnum_ != ldptr->_fnum_)	{		st_setchdr(PSYMTAB(ldptr));		last_fnum_ = ldptr->_fnum_;		last_offset = OFFSET(ldptr);	}	if (ipd < 0 && SYMHEADER(ldptr).ipdMax >= ipd)		return (FAILURE);	*ppd = PSYMTAB(ldptr)->ppd[ipd];	for (ifd = 0; ifd < SYMHEADER(ldptr).ifdMax; ifd++)	    if (PSYMTAB(ldptr)->pfd[ifd].cpd > 0 &&	       ipd >= PSYMTAB(ldptr)->pfd[ifd].ipdFirst &&	       ipd < PSYMTAB(ldptr)->pfd[ifd].ipdFirst +	       PSYMTAB(ldptr)->pfd[ifd].cpd)	       break;	if (ifd >= SYMHEADER(ldptr).ifdMax)	    return (FAILURE);	if (ppd->isym != isymNil)	    ppd->isym += PSYMTAB(ldptr)->pfd[ifd].isymBase; 	if (ppd->iline != ilineNil)	    ppd->iline += PSYMTAB(ldptr)->pfd[ifd].ilineBase; 	if (ppd->iopt != ioptNil)	    ppd->iopt += PSYMTAB(ldptr)->pfd[ifd].ioptBase; 	ppd->adr = PSYMTAB(ldptr)->psym[ppd->isym].value;	return (SUCCESS);}static char ID[] = "@(#) ldgetname.c: 1.2 2/16/83";

⌨️ 快捷键说明

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