Gilad,
My fault is that I forgot to write I am developing embedded software.
However the problem is much more general. If you know how compilers
work, you can usually guess how to solve some problems.
Well, function is called by some jump instruction. Basically, jump
instruction can be either direct or indirect. Direct instruction in many
cases is limited by address you can specify there (usually inside one or
a few number of pages), but indirect one (which is using a register) is
much more flexible. Compiler uses the first way if you just put a
function name in your code. The second way is used when you call a
function by its pointer;
e.g.:
typedef void (*func)(char *, ...);
func p_printk = &printk;
..
(*p_printk)("Hello World\n");
Another note: Sometimes, code portions can be located at the same
physical space, but accessible via different addresses: cache, virtual,
etc... This, actually, is my case. So, direct jump does not work for me.
Best regards,
George
-----Original Message-----
From: Gilad Ben-Yossef [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 18, 2002 13:26
To: George Agasandian
Cc: [EMAIL PROTECTED]
Subject: RE: Using printk in module
On Thu, 2002-07-18 at 11:14, George Agasandian wrote:
> Actually this staff, I guess, is architecture dependent. To call a
> kernel function, module must be located close enough to kernel in the
> address space in order to use regular call/branch/whatever assembly
> instructions. Many architectures have limitations in their jump
> instructions.
OK.
> I thought about it and so tried to find a workaround. The solution is
in
> calling functions by their pointer. So if you call printk by its
> pointer, all will work fine.
Either you or me don't understand what we're talking about. What you
wrote here sounds wrong to me. A funciton is called by one way only.
Whether you write it's name and the compiler + linker (in the case of a
Linux kernel module it's the insmod code) translates this to an address
or you give the specific address yourself is irrelevant.
Gilad.
--
Gilad Ben-Yossef <[EMAIL PROTECTED]>
Code mangler, senior coffee drinker and VP SIGSEGV
Qlusters ltd.
"You got an EMP device in the server room? That is so cool."
-- from a hackers-il thread on paranoia
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]