mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-16 11:24:39 +00:00
AArch64: use a different means to determine whether to byte swap relocations.
This code depended on a bug in the FindAssociatedSection function that would cause it to return the wrong result for certain absolute expressions. Instead, use EvaluateAsRelocatable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233119 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include "llvm/MC/MCObjectWriter.h"
|
#include "llvm/MC/MCObjectWriter.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
|
#include "llvm/MC/MCValue.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/MachO.h"
|
#include "llvm/Support/MachO.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@@ -493,14 +494,28 @@ void ELFAArch64AsmBackend::processFixupValue(
|
|||||||
IsResolved = false;
|
IsResolved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns whether this fixup is based on an address in the .eh_frame section,
|
||||||
|
// and therefore should be byte swapped.
|
||||||
|
// FIXME: Should be replaced with something more principled.
|
||||||
|
static bool isByteSwappedFixup(const MCExpr *E) {
|
||||||
|
MCValue Val;
|
||||||
|
if (!E->EvaluateAsRelocatable(Val, nullptr, nullptr))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!Val.getSymA() || Val.getSymA()->getSymbol().isUndefined())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const MCSectionELF *SecELF =
|
||||||
|
dyn_cast<MCSectionELF>(&Val.getSymA()->getSymbol().getSection());
|
||||||
|
return SecELF->getSectionName() == ".eh_frame";
|
||||||
|
}
|
||||||
|
|
||||||
void ELFAArch64AsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
|
void ELFAArch64AsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
|
||||||
unsigned DataSize, uint64_t Value,
|
unsigned DataSize, uint64_t Value,
|
||||||
bool IsPCRel) const {
|
bool IsPCRel) const {
|
||||||
// store fixups in .eh_frame section in big endian order
|
// store fixups in .eh_frame section in big endian order
|
||||||
if (!IsLittleEndian && Fixup.getKind() == FK_Data_4) {
|
if (!IsLittleEndian && Fixup.getKind() == FK_Data_4) {
|
||||||
const MCSection *Sec = Fixup.getValue()->FindAssociatedSection();
|
if (isByteSwappedFixup(Fixup.getValue()))
|
||||||
const MCSectionELF *SecELF = dyn_cast_or_null<const MCSectionELF>(Sec);
|
|
||||||
if (SecELF && SecELF->getSectionName() == ".eh_frame")
|
|
||||||
Value = ByteSwap_32(unsigned(Value));
|
Value = ByteSwap_32(unsigned(Value));
|
||||||
}
|
}
|
||||||
AArch64AsmBackend::applyFixup (Fixup, Data, DataSize, Value, IsPCRel);
|
AArch64AsmBackend::applyFixup (Fixup, Data, DataSize, Value, IsPCRel);
|
||||||
|
Reference in New Issue
Block a user