diff options
author | Martin Storsjö <martin@martin.st> | 2021-05-11 10:04:02 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2021-05-12 09:53:43 +0300 |
commit | 382c505d9cfca8adaec47aea2da7bbcbc00fc05c (patch) | |
tree | ca7e85fc2de902a94abe26c8b8a028f20ae90b03 /llvm/lib/MC/WinCOFFObjectWriter.cpp | |
parent | 2721e27c3aa34841db3fc0b4da25890288652d50 (diff) | |
download | llvm-382c505d9cfca8adaec47aea2da7bbcbc00fc05c.zip llvm-382c505d9cfca8adaec47aea2da7bbcbc00fc05c.tar.gz llvm-382c505d9cfca8adaec47aea2da7bbcbc00fc05c.tar.bz2 |
[COFF] Fix ARM and ARM64 REL32 relocations to be relative to the end of the relocation
This matches how they are defined on X86.
This should fix the relative lookup tables pass for COFF, allowing
it to be reenabled.
Differential Revision: https://reviews.llvm.org/D102217
Diffstat (limited to 'llvm/lib/MC/WinCOFFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/WinCOFFObjectWriter.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp index 2a69a30..646f416 100644 --- a/llvm/lib/MC/WinCOFFObjectWriter.cpp +++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp @@ -789,12 +789,16 @@ void WinCOFFObjectWriter::recordRelocation(MCAssembler &Asm, Reloc.Data.Type = TargetObjectWriter->getRelocType( Asm.getContext(), Target, Fixup, SymB, Asm.getBackend()); - // FIXME: Can anyone explain what this does other than adjust for the size - // of the offset? + // The *_REL32 relocations are relative to the end of the relocation, + // not to the start. if ((Header.Machine == COFF::IMAGE_FILE_MACHINE_AMD64 && Reloc.Data.Type == COFF::IMAGE_REL_AMD64_REL32) || (Header.Machine == COFF::IMAGE_FILE_MACHINE_I386 && - Reloc.Data.Type == COFF::IMAGE_REL_I386_REL32)) + Reloc.Data.Type == COFF::IMAGE_REL_I386_REL32) || + (Header.Machine == COFF::IMAGE_FILE_MACHINE_ARMNT && + Reloc.Data.Type == COFF::IMAGE_REL_ARM_REL32) || + (Header.Machine == COFF::IMAGE_FILE_MACHINE_ARM64 && + Reloc.Data.Type == COFF::IMAGE_REL_ARM64_REL32)) FixedValue += 4; if (Header.Machine == COFF::IMAGE_FILE_MACHINE_ARMNT) { |