Function report |
Source Code:fs\binfmt_flat.c |
Create Date:2022-07-28 20:29:24 |
| Last Modify:2020-03-12 14:18:49 | Copyright©Brick |
| home page | Tree |
| Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:load_flat_file
Proto:static int load_flat_file(struct linux_binprm *bprm, struct lib_info *libinfo, int id, unsigned long *extra_stack)
Type:int
Parameter:
| Type | Parameter | Name |
|---|---|---|
| struct linux_binprm * | bprm | |
| struct lib_info * | libinfo | |
| int | id | |
| unsigned long * | extra_stack |
| 443 | data_len = ntohl(Offset of end of data segment from beginningof file ) - ntohl(Offset of data segment from beginning offile ) |
| 444 | bss_len = ntohl(Offset of end of bss segment from beginningof file ) - ntohl(Offset of end of data segment from beginningof file ) |
| 445 | stack_len = ntohl(Size of stack, in bytes ) |
| 446 | If extra_stack Then |
| 447 | stack_len += extra_stack |
| 448 | extra_stack = stack_len |
| 450 | relocs = ntohl(Number of relocation records ) |
| 452 | rev = ntohl(version (as above) ) |
| 467 | If flags & utput useful kernel trace for debugging Then pr_info("Loading file: %s\n", filename) |
| 495 | If rev != FLAT_VERSION Then |
| 496 | pr_err("bad flat file version 0x%x (supported 0x%lx)\n", rev, FLAT_VERSION) |
| 499 | Go to err |
| 515 | If flags & (all but the header is compressed | ly data/relocs are compressed (for XIP) ) Then |
| 527 | rlim = rlimit(RLIMIT_DATA) |
| 528 | If rlim >= RLIM_INFINITY Then rlim = ~0 |
| 536 | If id == 0 Then |
| 543 | setup_new_exec(bprm) |
| 549 | extra = max_t - return maximum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(unsignedlong, bss_len + stack_len, relocs * sizeof(unsignedlong)) |
| 562 | pr_debug("ROM mapping of file (we hope)\n") |
| 564 | textpos = vm_mmap(file, 0, text_len, page can be read | page can be executed , Changes are private | mark it as an executable , 0) |
| 566 | If Not textpos || IS_ERR_VALUE(textpos) Then |
| 571 | Go to err |
| 576 | realdatastart = vm_mmap(NULL, 0, len, page can be read | page can be written | page can be executed , Changes are private , 0) |
| 579 | If realdatastart == 0 || IS_ERR_VALUE(realdatastart) Then |
| 604 | If IS_ERR_VALUE(result) Then |
| 608 | vm_munmap(realdatastart, len) |
| 609 | Go to err |
| 612 | reloc * __user = datapos + ntohl(Offset of relocation records from beginning offile ) - text_len |
| 614 | memp = realdatastart |
| 616 | Else |
| 620 | textpos = vm_mmap(NULL, 0, len, page can be read | page can be executed | page can be written , Changes are private , 0) |
| 623 | If Not textpos || IS_ERR_VALUE(textpos) Then |
| 629 | Go to err |
| 635 | reloc * __user = datapos + ntohl(Offset of relocation records from beginning offile ) - text_len |
| 700 | If Not IS_ERR_VALUE(result) Then result = read_code(file, datapos, ntohl(Offset of data segment from beginning offile ), full_data) |
| 705 | If IS_ERR_VALUE(result) Then |
| 713 | start_code = textpos + sizeof(structflat_hdr) |
| 718 | If id == 0 Then |
| 719 | start_code = start_code |
| 721 | start_data = datapos |
| 737 | If flags & utput useful kernel trace for debugging Then |
| 738 | pr_info("Mapping is %lx, Entry point is %x, data_start is %x\n", textpos, 0x00ffffff & ntohl(Offset of first executable instructionwith text segment from beginning of file ), ntohl(Offset of data segment from beginning offile )) |
| 748 | Start of data segment = datapos |
| 749 | End of data segment = datapos + data_len + bss_len |
| 751 | Has this library been loaded? = 1 |
| 752 | Start address for this module = (0x00ffffff & ntohl(Offset of first executable instructionwith text segment from beginning of file )) + textpos |
| 767 | If flags & program is PIC with GOT Then |
| 768 | cycle |
| 770 | If Get a simple variable from user space(rp_val, rp) Then Return -EFAULT |
| 772 | If rp_val == 0xffffffff Then Break |
| 774 | If rp_val Then |
| 775 | addr = calc_reloc(rp_val, libinfo, id, 0) |
| 776 | If addr == Relocation incorrect somewhere Then |
| 780 | If Write a simple value into user space(addr, rp) Then Return -EFAULT |
| 807 | If Get a simple variable from user space(tmp, reloc + i) Then Return -EFAULT |
| 810 | addr = flat_get_relocate_addr(relval) |
| 811 | rp = calc_reloc(addr, libinfo, id, 1) |
| 812 | If rp == Relocation incorrect somewhere Then |
| 819 | If Value for the false possibility is greater at compile time(ret) Then Go to err |
| 822 | If addr != 0 Then |
| 827 | If (flags & program is PIC with GOT ) == 0 Then |
| 834 | addr = calc_reloc(addr, libinfo, id, 0) |
| 835 | If addr == Relocation incorrect somewhere Then |
| 841 | ret = flat_put_addr_at_rp(rp, addr, relval) |
| 842 | If Value for the false possibility is greater at compile time(ret) Then Go to err |
| 866 | Return 0 |
| 867 | err : |
| 868 | Return ret |
| Name | Describe |
|---|---|
| load_flat_binary | These are the functions used to load flat style executables and shared* libraries. There is no binary dependent code anywhere else. |
| Source code conversion tool public plug-in interface | X |
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |