ARM: kernel: sort relocation sections before allocating PLTs
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 17 Aug 2016 11:45:21 +0000 (13:45 +0200)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 30 Aug 2016 16:45:34 +0000 (17:45 +0100)
commit1031a7e674d1de481d641c3723d5f53b776f621f
treef3b8a43b577bc7faed23d04221ef1e52403936e7
parent05123fef098220323e60834d5520b15d277e0415
ARM: kernel: sort relocation sections before allocating PLTs

The PLT allocation routines try to establish an upper bound on the
number of PLT entries that will be required at relocation time, and
optimize this by disregarding duplicates (i.e., PLT entries that will
end up pointing to the same function). This is currently a O(n^2)
algorithm, but we can greatly simplify this by
- sorting the relocation section so that relocations that can use the
  same PLT entry will be listed adjacently,
- disregard jump/call relocations with addends; these are highly unusual,
  for relocations against SHN_UNDEF symbols, and so we can simply allocate
  a PLT entry for each one we encounter, without trying to optimize away
  duplicates.

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