[ELF] Implement --[no-]apply-dynamic-relocs option.
authorPeter Smith <peter.smith@linaro.org>
Mon, 5 Feb 2018 10:15:08 +0000 (10:15 +0000)
committerPeter Smith <peter.smith@linaro.org>
Mon, 5 Feb 2018 10:15:08 +0000 (10:15 +0000)
commit64f65b02d287b760959e727d897cbeb3f8c50434
treef0a65fbdeb15f10579c06640c3f2218d2e375e1d
parentd86ad2e359c59e20eb3bf855fd73e61a711bbda0
[ELF] Implement --[no-]apply-dynamic-relocs option.

When resolving dynamic RELA relocations the addend is taken from the
relocation and not the place being relocated. Accordingly lld does not
write the addend field to the place like it would for a REL relocation.
Unfortunately there is some system software, in particlar dynamic loaders
such as Bionic's linker64 that use the value of the place prior to
relocation to find the offset that they have been loaded at. Both gold
and bfd control this behavior with the --[no-]apply-dynamic-relocs option.
This change implements the option and defaults it to true for compatibility
with gold and bfd.

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

llvm-svn: 324221
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/Options.td
lld/ELF/SyntheticSections.cpp
lld/test/ELF/dynamic-got-rela.s
lld/test/ELF/relocation-non-alloc.s