public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Werner Almesberger <wa@almesberger.net>
To: Jeff Dike <jdike@karaya.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	Oleg Drokin <green@namesys.com>,
	Linus Torvalds <torvalds@transmeta.com>,
	Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Linux 2.5.60
Date: Thu, 13 Feb 2003 20:25:58 -0300	[thread overview]
Message-ID: <20030213202558.A2791@almesberger.net> (raw)
In-Reply-To: <200302121149.GAA01822@ccure.karaya.com>; from jdike@karaya.com on Wed, Feb 12, 2003 at 06:49:49AM -0500

Jeff Dike wrote:
>> Or it can use the linker to play games with symbol names to move the
>> kernel off into it's own separate name space.
> 
> Maybe, I'm not expert enough with the linker to do that.

The basic trick is that  -Wl,--wrap,foo  renames the symbol "foo"
to "__real_foo", and resolves any reference to "foo" to "__wrap_foo".
So you can write wrappers that look like this:

whatever __wrap_foo(...)
{
    /* do stuff */
    blah = __real_foo(...);
    /* do more stuff */
}

While this sounds pretty cool, it comes with a few gotchas:

 - doesn't work for symbols that get resolved at compile time
   (static, maybe also anything in the same compilation unit)
 - when doing incremental linking, you need the -Wl,--wrap there,
   too
 - changing the set of -Wl,--wrap options means that you have to
   rebuild from a make clean afterwards (okay, not such a nightmare
   anymore, thanks to ccache)

I've used this pretty extensively in umlsim. It's okay if you
really want to avoid touching the source underneath. But you
spend a lot of time tracking down the occasional symbol that is
affected by one of the gotchas above ...

- Werner

-- 
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/

  reply	other threads:[~2003-02-13 23:16 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-10 19:08 Linux 2.5.60 Linus Torvalds
2003-02-10 20:41 ` Maciej Soltysiak
2003-02-10 21:06   ` Linux 2.5.60 Compile error James Lamanna
2003-02-10 21:38     ` Kevin Corry
2003-02-10 22:50       ` Muli Ben-Yehuda
2003-02-10 21:52     ` Dave Jones
2003-02-11  0:12     ` Another " Vlad@geekizoid.com
2003-02-11  5:21       ` Anthony J. Breeds-Taurima
2003-02-10 21:11   ` Linux 2.5.60 Stephen Hemminger
2003-02-10 21:25     ` James Lamanna
2003-02-10 22:54       ` Linus Torvalds
2003-02-10 20:46 ` 2.5.60: JFS no longer compiles with gcc 2.95 Adrian Bunk
2003-02-10 21:43   ` James Lamanna
2003-02-11  7:27     ` Adrian Bunk
2003-02-12 14:52       ` [PATCH - 2.5.60] " Dave Kleikamp
2003-02-12 15:04         ` Adrian Bunk
2003-02-12 15:42           ` Dave Kleikamp
2003-02-12 16:22             ` Andreas Schwab
2003-02-10 22:21 ` Linux 2.5.60 John Cherry
2003-02-11  7:08 ` Oleg Drokin
2003-02-11  7:38   ` Linus Torvalds
2003-02-12  8:11     ` Eric W. Biederman
2003-02-12 11:49       ` Jeff Dike
2003-02-13 23:25         ` Werner Almesberger [this message]
2003-02-11 15:16 ` Zephaniah E. Hull
2003-02-11 22:47   ` Andrew Morton
2003-02-11 22:54     ` Andrew Morton
2003-02-14 16:56       ` Zephaniah E. Hull
2003-02-11 16:23 ` Russell King
2003-02-11 17:06   ` Linus Torvalds
2003-02-12  2:47     ` David S. Miller
2003-02-11 16:44 ` 2.5.60: arlan.c no longer compiles Adrian Bunk
2003-02-11 23:08   ` Andrew Morton
2003-02-11 18:16 ` 2.5.60: sim710.c doesn't compile Adrian Bunk
2003-02-11 18:21   ` James Bottomley
2003-02-11 22:00 ` Linux 2.5.60 Rudmer van Dijk
2003-02-12 10:05 ` Ingo Oeser
  -- strict thread matches above, loose matches on Subject: below --
2003-02-13  4:12 Jeff Dike
2003-02-13  8:19 ` Oleg Drokin

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=20030213202558.A2791@almesberger.net \
    --to=wa@almesberger.net \
    --cc=ebiederm@xmission.com \
    --cc=green@namesys.com \
    --cc=jdike@karaya.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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