Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > The Linux Kernel > How to execute Linux kernel programs in User space

Forgot Password?
 The Linux Kernel   Compiling, theory, programming or other discussion about the linux kernel

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 01-12-2005   #1 (permalink)
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
shivanu is offline  



Reply With Quote
Old 01-12-2005   #2 (permalink)
Linux Guru
 
lakerdonald's Avatar
 
Join Date: Jun 2004
Location: St. Petersburg, FL
Posts: 5,039
what is the error when you try to compile?
__________________
the lost art of found sound
lakerdonald is offline   Reply With Quote
Old 01-13-2005   #3 (permalink)
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
the_unforgiven is offline   Reply With Quote
Old 01-13-2005   #4 (permalink)
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
shivanu is offline   Reply With Quote
Old 01-13-2005   #5 (permalink)
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
the_unforgiven is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
A Newbie's Getting Started Guide to Linux
Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you're a complete Linux newbie and looking for a quick and easy guide to get you started this is it.
subscribe
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 02:15 AM.






© 2000 - - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.1