mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [help] _syscall2 fails with -fPIC
@ 2001-02-17 19:47 Mark Swanson
  2001-02-19 23:02 ` Ralf Baechle
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Swanson @ 2001-02-17 19:47 UTC (permalink / raw)
  To: linux-kernel

Hello,

I am building a -fPIC shared object that will define and access a Linux
kernel system call, but _syscall2 fails with -fPIC .so compilation.
What can I do?
 
        F.E. the statement:
 
_syscall2 (int, tux, unsigned int, action, user_req_t *, req)
 
Gives the following gcc error when compiled with -fPIC:
 
tst.c: In function `tux':
tst.c:62: Invalid `asm' statement:
tst.c:62: fixed or forbidden register 3 (bx) was spilled for class
BREG.

If the -fPIC isn't there it compiles fine. Unfortunately I need to find
another way as I have to use -fPIC.

Thanks in advance for any suggestions.


=====
A camel is ugly but useful; it may stink, and it may spit, but it'll get you where you're going. - Larry Wall -

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [help] _syscall2 fails with -fPIC
  2001-02-17 19:47 [help] _syscall2 fails with -fPIC Mark Swanson
@ 2001-02-19 23:02 ` Ralf Baechle
  0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2001-02-19 23:02 UTC (permalink / raw)
  To: Mark Swanson; +Cc: linux-kernel

On Sat, Feb 17, 2001 at 11:47:09AM -0800, Mark Swanson wrote:

> I am building a -fPIC shared object that will define and access a Linux
> kernel system call, but _syscall2 fails with -fPIC .so compilation.
> What can I do?
>  
>         F.E. the statement:
>  
> _syscall2 (int, tux, unsigned int, action, user_req_t *, req)
>  
> Gives the following gcc error when compiled with -fPIC:
>  
> tst.c: In function `tux':
> tst.c:62: Invalid `asm' statement:
> tst.c:62: fixed or forbidden register 3 (bx) was spilled for class
> BREG.
> 
> If the -fPIC isn't there it compiles fine. Unfortunately I need to find
> another way as I have to use -fPIC.

Don't use the syscallX macros whenever possible; there are all sorts of
portability problems hidden there.  Their primary use is for within the
kernel; any other use should be considered problematic.  The prefered
solution is putting the necessary stubs into libc; if that doesn't seem
to be an option in your case try using the syscall() function defined in
<unistd.h> like:

#include <sys/syscall.h>
#include <unistd.h>

int main(char *argc, char *argv[])
{
	syscall(SYS_write, 1, "Hello, world\n", 13);
}

  Ralf

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-02-20 19:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-17 19:47 [help] _syscall2 fails with -fPIC Mark Swanson
2001-02-19 23:02 ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®