[ELF] Use more specific method to calculate DT_PLTRELSZ
authorPeter Smith <peter.smith@linaro.org>
Wed, 28 Nov 2018 10:04:55 +0000 (10:04 +0000)
committerPeter Smith <peter.smith@linaro.org>
Wed, 28 Nov 2018 10:04:55 +0000 (10:04 +0000)
commit7dc5af75ae5b8bcfce269fbd21c893cc2e4a61f0
treef063f2f2f37c56119db95f23e475eaf31536608a
parent06acb3a236594c93b9deefa2229d805b310c1e60
[ELF] Use more specific method to calculate DT_PLTRELSZ

The DT_PLTRELSZ dynamic tag is calculated using the size of the
OutputSection containing the In.RelaPlt InputSection. This will work for the
default no linker script case and the majority of linker scripts.
Unfortunately it doesn't work for some 'almost' sensible linker scripts. It
is permitted by ELF to have a single OutputSection containing both
In.RelaDyn, In.RelaPlt and In.RelaIPlt. It is also permissible for the range
of memory [DT_RELA, DT_RELA + DT_RELASZ) and the range
[DT_JMPREL, DT_JMPREL + DT_JMPRELSZ) to overlap as long as the the latter
range is at the end.

To support this type of linker script use the specific InputSection sizes.

Fixes pr39678

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

llvm-svn: 347736
lld/ELF/SyntheticSections.cpp
lld/test/ELF/aarch64-combined-dynrel-ifunc.s [new file with mode: 0644]
lld/test/ELF/aarch64-combined-dynrel.s [new file with mode: 0644]
lld/test/ELF/arm-combined-dynrel-ifunc.s [new file with mode: 0644]
lld/test/ELF/x86-64-combined-dynrel.s [new file with mode: 0644]