File to Memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm trying to implement a binary format loader for a format that is similar (but not the same) as the a.out format. Here's how the executable file is laid out (example):

0x0000 - 0x0020: Header
0x0020 - 0x4b02: TEXT
0x4b02 - 0x6944: DATA
0x6944 - 0x8d69: BSS

and here's how the file must be laid out in the virtual process address space so that it can be executed:

0x1000 - 0x4b22: Header + TEXT
0x5000 - 0x9267: DATA + BSS (Heap grows upwards)
(Stack grows downwards)

As you can see, the data in memory must be page-aligned (DATA starts at the next page after TEXT ends). I've registered by binary format handler using register_binfmt() in a kernel module and my custom load_binary() function is invoked with the linux bprm strcuture.

bprm->file gives me a pointer to the corresponding file structure. However, bprm->file->f_op->read is NULL, so I can't use it. The only thing I can do is use do_mmap, but that doesn't work in this case, as the offsets in the file are not page aligned - basically, I can't copy the DATA portion into memory since it starts at offset 0x4b02 in the file which is not page-aligned.

How do I copy data from the file into memory such that it fits in all the right places?

Thanks in advance (and please CC me on any replies as I'm not subscribed).

Cheers,
Anant


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux