Index: ELF/Config.h =================================================================== --- ELF/Config.h +++ ELF/Config.h @@ -154,6 +154,7 @@ bool Verbose; bool WarnCommon; bool WarnMissingEntry; + bool WriteAddends; bool ZCombreloc; bool ZExecstack; bool ZNocopyreloc; Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -821,6 +821,7 @@ (Config->Is64 || IsX32 || Machine == EM_PPC) && Machine != EM_MIPS; Config->Pic = Config->Pie || Config->Shared; Config->Wordsize = Config->Is64 ? 8 : 4; + Config->WriteAddends = Config->ApplyDynamicRelocs || !Config->IsRela; } // Returns a value of "-format" option. Index: ELF/SyntheticSections.cpp =================================================================== --- ELF/SyntheticSections.cpp +++ ELF/SyntheticSections.cpp @@ -1211,7 +1211,7 @@ // relocations for compatibility with GNU Linkers. There is some system // software such as the Bionic dynamic linker that uses the addend prior // to dynamic relocation resolution. - if ((!Config->IsRela || Config->ApplyDynamicRelocs) && UseSymVA) + if (Config->WriteAddends && UseSymVA) InputSec->Relocations.push_back({Expr, Type, OffsetInSec, Addend, Sym}); addReloc({DynType, InputSec, OffsetInSec, UseSymVA, Sym, Addend}); }