mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@uni-koblenz.de>
To: Mark Swanson <swansma@yahoo.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [help] _syscall2 fails with -fPIC
Date: Tue, 20 Feb 2001 00:02:48 +0100	[thread overview]
Message-ID: <20010220000247.A1537@bacchus.dhis.org> (raw)
In-Reply-To: <20010217194709.283.qmail@web1304.mail.yahoo.com>
In-Reply-To: <20010217194709.283.qmail@web1304.mail.yahoo.com>; from swansma@yahoo.com on Sat, Feb 17, 2001 at 11:47:09AM -0800

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

      reply	other threads:[~2001-02-20 19:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-17 19:47 Mark Swanson
2001-02-19 23:02 ` Ralf Baechle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010220000247.A1537@bacchus.dhis.org \
    --to=ralf@uni-koblenz.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swansma@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®