[ELF][ARM] Refine check for when undefined weak needs a Thunk
authorPeter Smith <peter.smith@linaro.org>
Mon, 27 Nov 2017 11:49:18 +0000 (11:49 +0000)
committerPeter Smith <peter.smith@linaro.org>
Mon, 27 Nov 2017 11:49:18 +0000 (11:49 +0000)
commit2809926c4d123e4ecd2339d7b10323d0d53106c9
tree33134a22f4d28e26b21e6f05c1f208b7a801f430
parent4b476488baeb5216a46e51bcdff0c8de366260a5
[ELF][ARM] Refine check for when undefined weak needs a Thunk

When an undefined weak reference has a PLT entry we must generate a range
extension thunk for any B or BL that can't reach the PLT entry.

This change explicitly looks for whether a PLT entry exists rather than
assuming that weak references never need PLT entries unless Config->Shared
is in operation. This covers the case where we are linking an executable
with dynamic linking, hence a PLT entry will be needed for undefined weak
references. This case comes up in real programs over 32 Mb in size as there
is a B to a weak reference __gmon__start__ in the Arm crti.o for glibc.

Differential Revision: https://reviews.llvm.org/D40248

llvm-svn: 319020
lld/ELF/Arch/ARM.cpp
lld/test/ELF/arm-branch-undef-weak-plt-thunk.s [new file with mode: 0644]