mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 04:39:44 +00:00
MC: check machine magic when applying offset adjustments
The values for the relocation type can (and do) overlap across various architectures. When performing an adjustment of the emitted relocation in the final object file, check that the file magic matches the target for which the relocation type is valid (e.g. a I386 relocation is only applied to an X86 object file, and an AMD64 relocation is only applied to an X86_64 object file). This was noticed while adding support for ARM WinCOFF object file emission. A test case for this is not really possible as the values for REL32 do not overlap on I386 and AMD64, which is why this was never noticed in practice. The ARM WinCOFF emission is not yet ready to merge into the tree. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206138 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ea0ea63773
commit
42ad510d31
@ -739,8 +739,10 @@ void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
||||
|
||||
// FIXME: Can anyone explain what this does other than adjust for the size
|
||||
// of the offset?
|
||||
if (Reloc.Data.Type == COFF::IMAGE_REL_AMD64_REL32 ||
|
||||
Reloc.Data.Type == COFF::IMAGE_REL_I386_REL32)
|
||||
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))
|
||||
FixedValue += 4;
|
||||
|
||||
coff_section->Relocations.push_back(Reloc);
|
||||
|
Loading…
Reference in New Issue
Block a user