LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-22-2011, 01:07 AM   #1
kamalsivadas
LQ Newbie
 
Registered: Apr 2009
Distribution: slackware
Posts: 10

Rep: Reputation: 0
Question Not able to push arguments to a function from entry_32.S


Hi All,
I am trying to customize linux 2.6.37 on x86. I have a function written in C which need to be called from entry_32.S. This function takes 2 arguments and return an integer. Prototype for function is -
unsigned int some_fn(int *addr,int length);
I am invoking this function before sys_call_table is invoked. But kernel panic is coming. Error message says "Kernel panic BAD EIP". If I am invoking a function that has no parameters it works fine. Please help me out of this issue.
See the relevant modification I done.
arch/x86/kernel/entry_32.S:

sysenter_do_call:
cmpl $(nr_syscalls), %eax
jae syscall_badsys
/* start of my modification */
pushl %eax /* Save system call no: in stack*/
pushl $(length) /* pushing second argument*/
pushl addr /* pushing first argument.*/
call some_fn /* calling my own c function*/
popl %eax /* restoring system call no to eax*/
/* end of my modification */
call *sys_call_table(,%eax,4)
 
Old 03-28-2011, 10:56 AM   #2
accessory2008
LQ Newbie
 
Registered: Mar 2011
Posts: 9

Rep: Reputation: 4
I guess one possible reason is the stack is not ready yet, so the original code is written in assembly which, unlike C, does not need a stack.

One workaround is try to use some registers to pass the arguments.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass all arguments to a function stormcloud Linux - General 4 07-08-2010 03:15 AM
too few arguments to function 'register_sysctl_table' Richard.Yang Linux - Kernel 2 07-31-2009 08:31 AM
Passing Arguments into the Thread Function George_gk Programming 2 01-31-2005 05:03 AM
C Function Arguments jpbarto Programming 6 04-23-2004 01:59 PM
Function accept() and its arguments. krajzega Programming 1 01-20-2004 01:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration