亚洲欧美第一页_禁久久精品乱码_粉嫩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| 亚洲成人在线网站| 日韩一区二区三区免费看| 黑人巨大精品欧美黑白配亚洲| 久久久久成人黄色影片| 97超碰欧美中文字幕| 亚洲风情在线资源站| 91精品国产综合久久久久久久久久| 久久精品国产99久久6| 国产精品国产精品国产专区不蜜 | 九九**精品视频免费播放| 欧美一区二区三区免费| 国产成人午夜片在线观看高清观看| 国产欧美精品一区| 欧美日本在线一区| 国产aⅴ精品一区二区三区色成熟| 亚洲日本在线视频观看| 欧美一区二区在线不卡| 成人毛片在线观看| 一区二区三区欧美日| 欧美电视剧免费观看| 成人v精品蜜桃久久一区| 亚洲国产成人av好男人在线观看| 精品1区2区在线观看| 在线影视一区二区三区| 精品一区二区在线观看| 亚洲视频免费在线| 久久综合久久久久88| 在线观看一区二区视频| 国产精品99久久久久久有的能看| 亚洲一区二区三区三| 中文一区在线播放 | 精品国产不卡一区二区三区| 91在线观看成人| 久久疯狂做爰流白浆xx| 一区二区激情小说| 国产亲近乱来精品视频| 日韩久久久久久| 在线中文字幕一区| 不卡视频在线看| 国产乱码精品一区二区三| 亚洲成av人片在线观看无码| 国产精品蜜臀av| 精品国产123| 欧美日韩1区2区| 在线欧美小视频| 91香蕉视频在线| 成人免费视频免费观看| 久久91精品久久久久久秒播| 亚洲成人动漫在线免费观看| 亚洲欧美激情小说另类| 久久久www成人免费毛片麻豆 | 欧美精选午夜久久久乱码6080| 国产成人一区二区精品非洲| 久久99精品久久久久| 日韩精品久久理论片| 亚洲午夜精品在线| 亚洲免费观看高清完整版在线观看| 欧美国产精品专区| 久久久一区二区| 精品嫩草影院久久| 精品福利一区二区三区免费视频| 日韩一级视频免费观看在线| 日韩一区二区三区免费看 | 国产欧美一区二区精品秋霞影院 | 精品国产髙清在线看国产毛片| 91精品国产欧美日韩| 欧美系列日韩一区| 欧美区一区二区三区| 在线电影院国产精品| 91精品国产美女浴室洗澡无遮挡| 9191久久久久久久久久久| 欧美一区二区视频在线观看2020 | 亚洲成人手机在线| 亚洲国产欧美一区二区三区丁香婷| 亚洲精品视频自拍| 亚洲高清视频在线| 日本美女视频一区二区| 日韩不卡在线观看日韩不卡视频| 免费在线成人网| 国产在线一区观看| 成人黄色小视频| 色婷婷综合久久久久中文一区二区| 色诱视频网站一区| 欧美日韩一区二区三区不卡| 5月丁香婷婷综合| 日韩欧美成人激情| 国产性天天综合网| √…a在线天堂一区| 亚洲国产精品久久一线不卡| 日韩电影免费在线观看网站| 韩国av一区二区三区四区| 丁香天五香天堂综合| 色综合久久66| 欧美一区在线视频| 中文字幕欧美国产| 亚洲成av人在线观看| 国产精选一区二区三区| 一本一道综合狠狠老| 欧美一二三在线| 中文字幕精品一区二区精品绿巨人 | 亚洲欧美另类小说视频| 午夜不卡av在线| 国产凹凸在线观看一区二区| 91麻豆文化传媒在线观看| 欧美精品一级二级| 亚洲国产精品成人综合 | 欧美日韩国产成人在线91| 日韩欧美第一区| 亚洲美女在线国产| 精品亚洲成a人在线观看 | 欧美性xxxxxxxx| 国产视频一区在线观看| 午夜欧美视频在线观看| av午夜一区麻豆| 欧美大片一区二区三区| 亚洲女同女同女同女同女同69| 久久精品国产成人一区二区三区| 91蝌蚪porny成人天涯| 欧美成人免费网站| 亚洲综合久久久| 成人a免费在线看| 日韩精品一区二区三区四区| 一区二区三区精品久久久| 国产精品自拍av| 欧美一区国产二区| 亚洲综合小说图片| 91色在线porny| 日韩欧美一二三区| 一区二区成人在线| 成人免费毛片a| 欧美变态tickle挠乳网站| 亚洲午夜精品在线| 91麻豆成人久久精品二区三区| 久久午夜羞羞影院免费观看| 污片在线观看一区二区| 色综合天天天天做夜夜夜夜做| 久久精品网站免费观看| 久久丁香综合五月国产三级网站| 欧美亚一区二区| 亚洲欧美激情小说另类| 国产成人精品一区二| 久久新电视剧免费观看| 久久精品国产秦先生| 在线综合+亚洲+欧美中文字幕| 亚洲永久精品大片| 色天使色偷偷av一区二区| 国产精品电影一区二区三区| 国产在线一区二区| 精品播放一区二区| 久久国产综合精品| 日韩欧美色综合| 蜜桃av噜噜一区二区三区小说| 制服丝袜亚洲播放| 日韩精品久久理论片| 日韩一区二区三区电影在线观看 | 欧美一区二区免费视频| 日韩国产欧美三级| 欧美美女网站色| 三级欧美在线一区| 日韩一区二区三区在线观看| 奇米精品一区二区三区在线观看 | 日韩一级大片在线| 青青草国产成人av片免费| 日韩精品一区国产麻豆| 美女尤物国产一区| 国产亚洲精品超碰| 成人精品一区二区三区四区| 国产精品初高中害羞小美女文| 99视频精品全部免费在线| 亚洲精品中文字幕乱码三区| 色94色欧美sute亚洲线路一ni| 亚洲国产毛片aaaaa无费看| 7777精品伊人久久久大香线蕉的| 爽好多水快深点欧美视频| 欧美一区二区免费视频| 国产精品一区二区在线观看不卡| 国产欧美一区二区三区在线看蜜臀 | 欧美人牲a欧美精品| 免费在线欧美视频| 久久久精品黄色| 9i看片成人免费高清| 亚洲一区二区在线播放相泽| 91精品国产综合久久久久久久 | 麻豆精品视频在线观看视频| 精品久久一区二区| 床上的激情91.| 亚洲午夜在线电影| 精品乱人伦一区二区三区| 成人一区二区三区视频在线观看| 亚洲美女电影在线| 日韩欧美一区二区三区在线| 成人午夜免费视频| 日本午夜一区二区| 国产精品国产三级国产三级人妇|