]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ARM: kernel: allocate PLT entries only for external symbols
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 16 Aug 2016 14:49:56 +0000 (16:49 +0200)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 30 Aug 2016 16:45:34 +0000 (17:45 +0100)
commit05123fef098220323e60834d5520b15d277e0415
tree371a6395b8251e57e837cd9a5be0b5fc9aaabd2c
parent35fa91eed817d2c65c59ef5a9737011313be6ac0
ARM: kernel: allocate PLT entries only for external symbols

When CONFIG_ARM_MODULE_PLTS is enabled, jump and call instructions in
modules no longer need to be within 16 MB (8 MB for Thumb2) of their
targets. If they are further away, a PLT entry will be generated on the
fly for each of them, which extends the range to the entire 32-bit
address space.

However, since these PLT entries will become the branch targets of the
original jump and call instructions, the PLT itself needs to be in
range, or we end up in the same situation we started in. Since the PLT
is in a separate section, this essentially means that all jumps and calls
inside the same module must be resolvable without PLT entries.

The PLT allocation code executes before the module itself is loaded in
its final location, and so it has to use a worst-case estimate for
which jumps and calls will require an entry in the PLT at relocation
time. As an optimization, this code deduplicates entries pointing to
the same symbol, using a O(n^2) algorithm. However, it does not take
the above into account, i.e., that PLT entries will only be needed for
jump and call relocations against symbols that are not defined in the
module.

So disregard relocations against symbols that are defined in the module
itself.

As an additional minor optimization, ignore input sections that lack
the SHF_EXECINSTR flag. Since jump and call relocations operate on
executable instructions only, there is no need to look in sections that
do not contain executable code.

Tested-by: Jongsung Kim <neidhard.kim@lge.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
arch/arm/kernel/module-plts.c