亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? binfmt_coff.c

?? LINUX1.0源代碼,代碼條理清晰
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
 * These are the functions used to load COFF IBSC style executables.
 * Information on COFF format may be obtained in either the Intel Binary
 * Compatibility Specification 2 or O'Rilley's book on COFF. The shared
 * libraries are defined only the in the Intel book.
 *
 * This file is based upon code written by Eric Youndale for the ELF object
 * file format.
 *
 * Author: Al Longyear (longyear@sii.com)
 *
 * Latest Revision:
 *    3 Feburary 1994
 *      Al Longyear (longyear@sii.com)
 *      Cleared first page of bss section using put_fs_byte.
 */

#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/a.out.h>
#include <linux/errno.h>
#include <linux/signal.h>
#include <linux/binfmts.h>
#include <asm/segment.h>
#include <linux/string.h>
#include <linux/fcntl.h>
#include <linux/ptrace.h>
#include <linux/coff.h>
#include <linux/malloc.h>

asmlinkage int sys_exit (int exit_code);
asmlinkage int sys_close (unsigned fd);
asmlinkage int sys_open (const char *, int, int);
asmlinkage int sys_uselib(const char * library);

static int preload_library (struct linux_binprm *exe_bprm,
			    COFF_SCNHDR * sect,
			    struct file *fp);

static int load_object (struct linux_binprm *bprm,
			struct pt_regs *regs,
			int lib_ok);

/*
 *  Small procedure to test for the proper file alignment.
 */

static inline int
is_properly_aligned (COFF_SCNHDR *sect)
{
    long scnptr = COFF_LONG (sect->s_scnptr);
    long vaddr  = COFF_LONG (sect->s_vaddr);
/*
 *  Print the section information if needed
 */

#ifdef COFF_DEBUG
    printk ("%s, scnptr = %d, vaddr = %d\n",
	    sect->s_name,
	    scnptr, vaddr);
#endif

/*
 *  Return the error code if the section is not properly aligned.
 */

#ifdef COFF_DEBUG
    if (((vaddr - scnptr) & ~PAGE_MASK) != 0)
	printk ("bad alignment in %s\n", sect->s_name);
#endif
    return ((((vaddr - scnptr) & ~PAGE_MASK) != 0) ? -ENOEXEC : 0);
}

/*
 *    Clear the bytes in the last page of data.
 */

static
int clear_memory (unsigned long addr, unsigned long size)
{
    int status;

    size = (PAGE_SIZE - (addr & ~PAGE_MASK)) & ~PAGE_MASK;
    if (size == 0)
        status = 0;
    else {
      
#ifdef COFF_DEBUG
        printk ("un-initialized storage in last page %d\n", size);
#endif

	status = verify_area (VERIFY_WRITE,
			      (void *) addr, size);
#ifdef COFF_DEBUG
	printk ("result from verify_area = %d\n", status);
#endif

	if (status >= 0)
	    while (size-- != 0)
	        put_fs_byte (0, addr++);
    }
    return status;
}

/*
 *  Helper function to process the load operation.
 */

static int
load_object (struct linux_binprm * bprm, struct pt_regs *regs, int lib_ok)
{
    COFF_FILHDR  *coff_hdr = (COFF_FILHDR *) bprm->buf;	/* COFF Header */
    COFF_SCNHDR  *sect_bufr;	/* Pointer to section table            */
    COFF_SCNHDR  *text_sect;	/* Pointer to the text section         */
    COFF_SCNHDR  *data_sect;	/* Pointer to the data section         */
    COFF_SCNHDR  *bss_sect;	/* Pointer to the bss section          */
    int text_count;		/* Number of text sections             */
    int data_count;		/* Number of data sections             */
    int bss_count;		/* Number of bss sections              */
    int lib_count;		/* Number of lib sections              */
    unsigned int start_addr = 0;/* Starting location for program       */
    int status = 0;		/* Result status register              */
    int fd = -1;		/* Open file descriptor                */
    struct file *fp     = NULL;	/* Pointer to the file at "fd"         */
    short int sections  = 0;	/* Number of sections in the file      */
    short int aout_size = 0;	/* Size of the a.out header area       */
    short int flags;		/* Flag bits from the COFF header      */

#ifdef COFF_DEBUG
    printk ("binfmt_coff entry: %s\n", bprm->filename);
#endif

/*
 *  Validate the magic value for the object file.
 */
    do {
	if (COFF_I386BADMAG (*coff_hdr)) {
#ifdef COFF_DEBUG
	    printk ("bad filehdr magic\n");
#endif
	    status = -ENOEXEC;
	    break;
	}
/*
 *  The object file should have 32 BIT little endian format. Do not allow
 *  it to have the 16 bit object file flag set as Linux is not able to run
 *  on the 80286/80186/8086.
 */
	flags = COFF_SHORT (coff_hdr->f_flags);
	if ((flags & (COFF_F_AR32WR | COFF_F_AR16WR)) != COFF_F_AR32WR) {
#ifdef COFF_DEBUG
	    printk ("invalid f_flags bits\n");
#endif
	    status = -ENOEXEC;
	    break;
	}
/*
 *  Extract the header information which we need.
 */
	sections  = COFF_SHORT (coff_hdr->f_nscns);   /* Number of sections */
	aout_size = COFF_SHORT (coff_hdr->f_opthdr);  /* Size of opt. headr */
/*
 *  If the file is not executable then reject the exectution. This means
 *  that there must not be external references.
 */
	if ((flags & COFF_F_EXEC) == 0) {
#ifdef COFF_DEBUG
	    printk ("not executable bit\n");
#endif
	    status = -ENOEXEC;
	    break;
	}
/*
 *  There must be atleast one section.
 */
	if (sections == 0) {
#ifdef COFF_DEBUG
	    printk ("no sections\n");
#endif
	    status = -ENOEXEC;
	    break;
	}
/*
 *  Do some additional consistency checks.
 *  The system requires mapping for this loader. If you try
 *  to use a file system with no mapping, the format is not valid.
 */
	if (!bprm->inode->i_op ||
	    !bprm->inode->i_op->default_file_ops->mmap) {
#ifdef COFF_DEBUG
	    printk ("no mmap in fs\n");
#endif
	    status = -ENOEXEC;
	}
    }
    while (0);
/*
 *  Allocate a buffer to hold the entire coff section list.
 */
    if (status >= 0) {
	int nbytes = sections * COFF_SCNHSZ;

	sect_bufr = (COFF_SCNHDR *) kmalloc (nbytes, GFP_KERNEL);
	if (0 == sect_bufr) {
#ifdef COFF_DEBUG
	    printk ("kmalloc failed\n");
#endif
	    status = -ENOEXEC;
	}
/*
 *  Read the section list from the disk file.
 */
	else {
	     int old_fs = get_fs ();
	     set_fs (get_ds ());  /* Make it point to the proper location    */
	     status = read_exec (bprm->inode,	     /* INODE for file       */
			    aout_size + COFF_FILHSZ, /* Offset in the file   */
			    (char *) sect_bufr,      /* Buffer for read      */
			    nbytes);                 /* Byte count reqd.     */
	     set_fs (old_fs);	                     /* Restore the selector */
#ifdef COFF_DEBUG
	     if (status < 0)
	        printk ("read aout hdr, status = %d\n", status);
#endif
	 }
    }
    else
	sect_bufr = NULL;	/* Errors do not have a section buffer */
/*
 *  Count the number of sections for the required types and store the location
 *  of the last section for the three primary types.
 */
    text_count = 0;
    data_count = 0;
    bss_count  = 0;
    lib_count  = 0;

    text_sect = NULL;
    data_sect = NULL;
    bss_sect  = NULL;
/*
 *  Loop through the sections and find the various types
 */
    if (status >= 0) {
	int nIndex;
	COFF_SCNHDR *sect_ptr = sect_bufr;

	for (nIndex = 0; nIndex < sections; ++nIndex) {
	    long int sect_flags = COFF_LONG (sect_ptr->s_flags);

	    switch (sect_flags) {
	    case COFF_STYP_TEXT:
		text_sect = sect_ptr;
		++text_count;
		status = is_properly_aligned (sect_ptr);
		break;

	    case COFF_STYP_DATA:
		data_sect = sect_ptr;
		++data_count;
		status = is_properly_aligned (sect_ptr);
		break;

	    case COFF_STYP_BSS:
		bss_sect = sect_ptr;
		++bss_count;
		break;

	    case COFF_STYP_LIB:
#ifdef COFF_DEBUG
		printk (".lib section found\n");
#endif
		++lib_count;
		break;

	    default:
		break;
	    }
	    sect_ptr = (COFF_SCNHDR *) & ((char *) sect_ptr)[COFF_SCNHSZ];
	}
/*
 *  Ensure that there are the required sections. There must be one text
 *  sections and one each of the data and bss sections for an executable.
 *  A library may or may not have a data / bss section.
 */
	if (text_count != 1) {
	    status = -ENOEXEC;
#ifdef COFF_DEBUG
	    printk ("no text sections\n");
#endif
	}
	else {
	    if (lib_ok) {
		if (data_count != 1 || bss_count != 1) {
		    status = -ENOEXEC;
#ifdef COFF_DEBUG
		    printk ("no .data nor .bss sections\n");
#endif
		}
	    }
	}
    }
/*
 *  If there is no additional header then assume the file starts at
 *  the first byte of the text section. This may not be the proper place,
 *  so the best solution is to include the optional header. A shared library
 *  __MUST__ have an optional header to indicate that it is a shared library.
 */
    if (status >= 0) {
	if (aout_size == 0) {
	    if (!lib_ok) {
		status = -ENOEXEC;
#ifdef COFF_DEBUG
		printk ("no header in library\n");
#endif
	    }
	    start_addr = COFF_LONG (text_sect->s_vaddr);
	}
/*
 *  There is some header. Ensure that it is sufficient.
 */
	else {
	    if (aout_size < COFF_AOUTSZ) {
		status = -ENOEXEC;
#ifdef COFF_DEBUG
		printk ("header too small\n");
#endif
	    }
	    else {
		COFF_AOUTHDR *aout_hdr =	/* Pointer to a.out header */
		(COFF_AOUTHDR *) & ((char *) coff_hdr)[COFF_FILHSZ];
		short int aout_magic = COFF_SHORT (aout_hdr->magic); /* id */
/*
 *  Validate the magic number in the a.out header. If it is valid then
 *  update the starting symbol location. Do not accept these file formats
 *  when loading a shared library.
 */
		switch (aout_magic) {
		case COFF_OMAGIC:
		case COFF_ZMAGIC:
		case COFF_STMAGIC:
		    if (!lib_ok) {
			status = -ENOEXEC;
#ifdef COFF_DEBUG
			printk ("wrong a.out header magic\n");
#endif
		    }
		    start_addr = (unsigned int) COFF_LONG (aout_hdr->entry);
		    break;
/*
 *  Magic value for a shared library. This is valid only when loading a
 *  shared library. (There is no need for a start_addr. It won't be used.)
 */
		case COFF_SHMAGIC:
		    if (lib_ok) {
#ifdef COFF_DEBUG
			printk ("wrong a.out header magic\n");
#endif
			status = -ENOEXEC;
		    }
		    break;

		default:
#ifdef COFF_DEBUG
		    printk ("wrong a.out header magic\n");
#endif
		    status = -ENOEXEC;
		    break;
		}
	    }
	}
    }
/*
 *  Fetch a file pointer to the executable.
 */
    if (status >= 0) {
	fd = open_inode (bprm->inode, O_RDONLY);
	if (fd < 0) {
#ifdef COFF_DEBUG
	    printk ("can not open inode, result = %d\n", fd);
#endif
	    status = fd;
	}
	else
	    fp = current->filp[fd];
    }
    else
	fd = -1;		/* Invalidate the open file descriptor */
/*
 *  Generate the proper values for the text fields
 *

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
这里是久久伊人| 中文av一区特黄| 国产精品妹子av| 三级精品在线观看| 色婷婷av一区二区三区软件| 日韩欧美国产成人一区二区| 亚洲国产精品麻豆| 99免费精品在线| 欧美国产欧美亚州国产日韩mv天天看完整| 亚洲国产乱码最新视频| 99久久精品国产麻豆演员表| 久久亚洲精品小早川怜子| 日韩有码一区二区三区| 欧美日韩视频在线观看一区二区三区| 亚洲国产精品成人综合色在线婷婷| 日本中文在线一区| 7777女厕盗摄久久久| 亚洲高清久久久| 欧美日韩在线播放| 亚洲一区自拍偷拍| 91在线观看一区二区| 欧美精品一区视频| 亚洲成人动漫精品| 色婷婷亚洲一区二区三区| 欧美精品丝袜中出| 中文字幕一区av| 另类小说图片综合网| 色爱区综合激月婷婷| 国产色综合久久| 蜜臂av日日欢夜夜爽一区| 欧美日韩视频在线第一区| 亚洲特黄一级片| 国产99久久久国产精品| 欧美www视频| 丝袜国产日韩另类美女| 色哟哟一区二区在线观看| 国产日产欧美一区| 美女视频第一区二区三区免费观看网站| 在线亚洲一区二区| 成人免费一区二区三区在线观看| 国产综合久久久久影院| 精品电影一区二区| 久久电影网电视剧免费观看| 7777精品久久久大香线蕉| 亚洲va国产天堂va久久en| 精品视频在线免费观看| 亚洲精选免费视频| 91麻豆精品在线观看| 国产精品成人一区二区艾草 | 欧美一区三区四区| 亚洲第一二三四区| 91精品国产综合久久久蜜臀图片| 性久久久久久久| 在线观看91av| 免费观看在线综合| 精品日韩在线观看| 国产在线播放一区二区三区| 欧美成人精品福利| 风间由美性色一区二区三区| 欧美高清视频不卡网| 男女激情视频一区| 久久综合色婷婷| 成人av在线资源网| 日韩久久一区二区| 欧美精品色综合| 精品一区二区三区视频| 国产精品你懂的在线| 日本韩国欧美三级| 日本一区中文字幕 | 亚洲超丰满肉感bbw| 欧美日韩国产首页| 麻豆传媒一区二区三区| 日韩色在线观看| 成人福利视频在线| 中文字幕不卡在线观看| 精品视频色一区| 日韩高清中文字幕一区| 专区另类欧美日韩| 欧美丰满一区二区免费视频| 久久av资源站| 日韩美女视频一区二区| 一本大道久久a久久综合| 日韩**一区毛片| 中文字幕乱码一区二区免费| 91浏览器在线视频| 三级欧美韩日大片在线看| 欧美国产日本韩| 欧美日韩国产综合一区二区| 国产经典欧美精品| 亚洲国产成人av网| 国产精品久久久久久户外露出| 欧美视频完全免费看| 国产成人一区二区精品非洲| 亚洲一区视频在线| 国产亚洲综合在线| 91麻豆精品国产| 粉嫩av一区二区三区| 国产精品伦理在线| 日韩女优毛片在线| 欧美中文字幕不卡| 成+人+亚洲+综合天堂| 免费在线观看不卡| 亚洲午夜精品久久久久久久久| 久久久精品免费免费| 欧美夫妻性生活| 91黄色免费看| 成人在线综合网| 麻豆91精品91久久久的内涵| 一区二区三区高清不卡| 欧美国产在线观看| 久久久久久久性| 在线不卡的av| 91精品视频网| 欧美日韩精品一区二区三区蜜桃| 国产乱码精品一区二区三区忘忧草 | 精品成a人在线观看| 欧美福利一区二区| 欧美日韩一级二级三级| 色婷婷久久久亚洲一区二区三区 | 92国产精品观看| 国产福利一区二区三区视频 | 日本精品免费观看高清观看| 成人性视频网站| 国产乱妇无码大片在线观看| 久久精品国产**网站演员| 免费成人性网站| 秋霞国产午夜精品免费视频| 日韩精品一级中文字幕精品视频免费观看| 亚洲欧美欧美一区二区三区| 国产精品国产自产拍高清av| 中文字幕va一区二区三区| 国产欧美日韩麻豆91| 国产精品私人影院| 亚洲国产成人在线| 国产精品伦理一区二区| 国产精品每日更新在线播放网址| 久久一夜天堂av一区二区三区 | 国产一区二区精品久久99 | 欧美日韩另类国产亚洲欧美一级| 色老汉一区二区三区| 在线免费不卡电影| 99re在线视频这里只有精品| 成人免费观看av| 久久99精品一区二区三区三区| 国产精品一区二区在线看| 日韩一区欧美二区| 久久成人免费网| 国产成人av自拍| 91天堂素人约啪| 91精品国产综合久久久蜜臀粉嫩 | 亚洲午夜免费福利视频| 午夜精品久久久久久不卡8050| 午夜伦欧美伦电影理论片| 青青草视频一区| 国产做a爰片久久毛片| av资源网一区| 欧美猛男超大videosgay| 精品日韩在线一区| 国产精品家庭影院| 亚洲第一成人在线| 国产一区二区三区四区在线观看| 成人av电影在线播放| 色综合久久中文综合久久97 | 蜜臀99久久精品久久久久久软件| 国产在线国偷精品产拍免费yy| 国产成人av影院| 欧美在线影院一区二区| 欧美精品一区二区三区蜜臀| 中文字幕乱码日本亚洲一区二区| 亚洲青青青在线视频| 日韩电影免费在线观看网站| 国产成a人亚洲| 欧美日韩一级大片网址| 国产日韩精品视频一区| 亚洲电影你懂得| 国产v日产∨综合v精品视频| 欧美性videosxxxxx| 欧美—级在线免费片| 亚洲成人激情社区| 成人av片在线观看| 日韩免费在线观看| 亚洲在线观看免费视频| 国产成人自拍在线| 欧美一级艳片视频免费观看| 自拍偷拍国产精品| 国产精品一区免费在线观看| 欧美日韩精品系列| 中文字幕在线观看一区二区| 美国毛片一区二区| 欧美日精品一区视频| 日韩精品一区二区三区三区免费 | 中文字幕一区二区不卡| 精品一区二区影视| 欧美日韩在线三级| 一区二区三区欧美日| 狠狠色综合日日| 欧美顶级少妇做爰| 亚洲码国产岛国毛片在线| 成人免费视频视频| 欧美精品一区二区不卡 |