mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Nicolas Pitre <nico@fluxnic.net>
Cc: Sachin Verma <imschnvrm@gmail.com>, Rabin Vincent <rabin@rab.in>,
	Alexander Holler <holler@ahsoftware.de>,
	Dave Martin <dave.martin@linaro.org>,
	lkml <linux-kernel@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	catalin.marinas@arm.com
Subject: Re: ARM: relocation out of range (when loading a module)
Date: Thu, 10 Feb 2011 15:43:22 +0000	[thread overview]
Message-ID: <20110210154322.GE1742@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <alpine.LFD.2.00.1101270030220.8580@xanadu.home>

On Thu, Jan 27, 2011 at 12:43:54AM -0500, Nicolas Pitre wrote:
> The MMU-less kernel should still favor allocations close to the kernel 
> text for modules, and anything else away from the kernel going 
> downwards.
> 
> Otherwise a veneer should be created by the module symbol resolver such 
> that if the branch distance to reach, say, printk is too large, then the 
> following code would have to be dynamically generated right next to the 
> module:
> 
> 	ldr	pc, [pc, #-4]
> 	.word	<far_away_symbol>
> 
> Then, in your module, you patch the branch relocation for printk so that 
> it branches to the code above instead, and then store the address of 
> printk at the location represented by the .word directive.

What you're suggesting is what we used to do with the old user-space
module tools, which would've been nice to carry forwards to the new
module code.  I never found a way to do it.

The problems:
1. Where do you create those veneers?
2. How many veneers do you allocate space for?
3. How do you determine that you need a veneer?

While you can say "next to the module" for (1), you can only do that at
the point in time when the space for the module is allocated, and you
need to know at that point how much space you require.

For (2), you could always allocate space for one veneer per symbol present
in the module, but that's very wasteful.

(3) is almost impossible to know ahead of time as you don't have the
relocations, realistically you have to allocate one veneer per symbol,
and as you don't know whether it's a data or code symbol, you'll have
to allocate one veneer for every symbol in a module.

I really don't like it, and I don't see that this is sanely solvable
without giving architectures much more control over module loading,
which I don't think will ever happen.  It's probably simpler to build
modules with whatever that magic option is to tell GCC to always generate
'far call' veneers for everything rather than trying to 'fix' the kernel
module loader.

  reply	other threads:[~2011-02-10 15:44 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10 18:16 Alexander Holler
2011-01-10 22:26 ` Nicolas Pitre
2011-01-11  6:34   ` Alexander Holler
2011-01-11 15:17     ` Alexander Holler
2011-01-11 15:57       ` Russell King - ARM Linux
2011-01-11 16:02       ` Nicolas Pitre
2011-01-11 15:46     ` Rabin Vincent
2011-01-11 15:59       ` Russell King - ARM Linux
2011-01-12  3:00         ` Alexander Holler
2011-01-12 16:05           ` Dave Martin
2011-01-12 16:23             ` Russell King - ARM Linux
2011-01-12 18:28             ` Nicolas Pitre
2011-01-12 18:42               ` Russell King - ARM Linux
2011-01-12 18:55                 ` Nicolas Pitre
2011-01-25  8:44                   ` Sachin Verma
2011-01-25 13:23                     ` Catalin Marinas
2011-01-27  5:43                     ` Nicolas Pitre
2011-02-10 15:43                       ` Russell King - ARM Linux [this message]
2011-02-10 19:41                         ` Nicolas Pitre
2011-02-11  9:31                           ` Dave Martin
2011-02-11  9:38                             ` Russell King - ARM Linux
2011-02-11  9:45                               ` Dave Martin
2011-02-11 13:55                                 ` Nicolas Pitre
2011-02-11 13:51                             ` Nicolas Pitre
2011-02-11 14:25                               ` Dave Martin
2011-02-11 14:42                                 ` Russell King - ARM Linux
2011-02-12 19:52                                   ` Nicolas Pitre
2011-01-13  5:50                 ` Alexander Holler
2011-01-13 10:04                   ` Russell King - ARM Linux
2011-01-13 14:36                     ` Alexander Holler
2011-01-12 16:25         ` Matthieu CASTET
2011-01-12 16:38           ` Russell King - ARM Linux
2011-01-11 16:01     ` Nicolas Pitre

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=20110210154322.GE1742@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=catalin.marinas@arm.com \
    --cc=dave.martin@linaro.org \
    --cc=holler@ahsoftware.de \
    --cc=imschnvrm@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nico@fluxnic.net \
    --cc=rabin@rab.in \
    /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®