mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-22 09:29:31 +00:00
MCELF: Write relocation fragments in the right endian.
- This code is gross, but does the job for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113509 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5baf79edc0
commit
5e492e8d42
@ -745,12 +745,33 @@ void ELFObjectWriterImpl::WriteRelocationsFragment(const MCAssembler &Asm,
|
||||
for (unsigned i = 0, e = Relocs.size(); i != e; ++i) {
|
||||
ELFRelocationEntry entry = Relocs[e - i - 1];
|
||||
|
||||
unsigned WordSize = Is64Bit ? 8 : 4;
|
||||
F->getContents() += StringRef((const char *)&entry.r_offset, WordSize);
|
||||
F->getContents() += StringRef((const char *)&entry.r_info, WordSize);
|
||||
if (Is64Bit) {
|
||||
char buf[8];
|
||||
|
||||
if (HasRelocationAddend)
|
||||
F->getContents() += StringRef((const char *)&entry.r_addend, WordSize);
|
||||
String64(buf, entry.r_offset);
|
||||
F->getContents() += StringRef(buf, 8);
|
||||
|
||||
String64(buf, entry.r_info);
|
||||
F->getContents() += StringRef(buf, 8);
|
||||
|
||||
if (HasRelocationAddend) {
|
||||
String64(buf, entry.r_addend);
|
||||
F->getContents() += StringRef(buf, 8);
|
||||
}
|
||||
} else {
|
||||
char buf[4];
|
||||
|
||||
String32(buf, entry.r_offset);
|
||||
F->getContents() += StringRef(buf, 4);
|
||||
|
||||
String32(buf, entry.r_info);
|
||||
F->getContents() += StringRef(buf, 4);
|
||||
|
||||
if (HasRelocationAddend) {
|
||||
String32(buf, entry.r_addend);
|
||||
F->getContents() += StringRef(buf, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user