Find the answer to your Linux question:
Results 1 to 5 of 5
Hi, I am trying to modify and execute the ELF loader program in the Linux kernel linux/fs/binfmt_elf.c . Though i tried compiling it using normal gcc -o binfmt_elf binfmt_elf.c , ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2004
    Posts
    26

    How to execute Linux kernel programs in User space


    Hi,
    I am trying to modify and execute the ELF loader program in the Linux kernel linux/fs/binfmt_elf.c . Though i tried compiling it using normal gcc -o binfmt_elf binfmt_elf.c , I could not successfully compile it.
    Please tell me what needs to be done to be able to execute the program in user space or how to move to kernel space.

    Regards,
    Shivanu

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    what is the error when you try to compile?

  3. #3
    Linux User
    Join Date
    Oct 2004
    Location
    /dev/random
    Posts
    404
    binfmt_elf(binfmt_*) is(are) a module(s) - it doesn't have main(), so you cannot compile it the way you're trying.

    If you want to create a user-space executable out of it, you'll have to redesign it significantly.
    The Unforgiven
    Registered Linux User #358564

  4. #4
    Just Joined!
    Join Date
    Sep 2004
    Posts
    26
    Yes I understand that it is a kernel module and probably all binfmt_* are also kernel modules. So when i compile them in normal user space using gcc it gives an array of errors, right from errors in the header files to some dereferencing errors in the code of binfmt_elf.c itself.
    So i guess that i will have to figure out a way to execute this in kernel mode. Anyway I can do that?

    Thanks
    Shivanu

  5. #5
    Linux User
    Join Date
    Oct 2004
    Location
    /dev/random
    Posts
    404
    Yes, of course you can execute that in the kernel.
    In fact, it does get executed everytime you execute an ELF binary - whatever you compile in the modern linux distros.

    You can find it out by putting printk() in the module somewhere which would output some message whenever an ELF binary is executed.
    The Unforgiven
    Registered Linux User #358564

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •