Permalink
Browse files

Ignore R_ARM_V4BX relocation for ARM

  • Loading branch information...
Kingcom committed Jan 7, 2018
1 parent a1b9d43 commit c082e187a715c273b808dd75d89b357ae6aab7c1
Showing with 13 additions and 0 deletions.
  1. +7 −0 Archs/ARM/ArmRelocator.cpp
  2. +2 −0 Archs/ARM/ArmRelocator.h
  3. +3 −0 Core/ELF/ElfRelocator.cpp
  4. +1 −0 Core/ELF/ElfRelocator.h
@@ -10,6 +10,13 @@ inline int signExtend(int value, int bitsLength)
return (value << (32-bitsLength)) >> (32-bitsLength);
}

bool ArmElfRelocator::isDummyRelocationType(int type) const
{
// R_ARM_V4BX marks the position of a bx opcode, and does not
// cause any actual relocations
return type == R_ARM_V4BX;
}

/*
S = symbol address
T = 1 if symbol is a thumb mode function, 0 otherwise
@@ -8,13 +8,15 @@ enum {
R_ARM_CALL = 28,
R_ARM_JUMP24 = 29,
R_ARM_TARGET1 = 38,
R_ARM_V4BX = 40,
};


class ArmElfRelocator: public IElfRelocator
{
public:
ArmElfRelocator(bool arm9): arm9(arm9) { };
virtual bool isDummyRelocationType(int type) const;
virtual bool relocateOpcode(int type, RelocationData& data);
virtual void setSymbolAddress(RelocationData& data, int64_t symbolAddress, int symbolType);
virtual CAssemblerCommand* generateCtorStub(std::vector<ElfRelocatorCtor>& ctors);
@@ -317,6 +317,9 @@ bool ElfRelocator::relocateFile(ElfRelocatorFile& file, int64_t& relocationAddre
loadRelocation(rel, relSection->getData(), relOffset, elf->isBigEndian());
int pos = rel.r_offset;

if (relocator->isDummyRelocationType(rel.getType()))
continue;

int symNum = rel.getSymbolNum();
if (symNum <= 0)
{
@@ -15,6 +15,7 @@ class IElfRelocator
{
public:
virtual ~IElfRelocator() { };
virtual bool isDummyRelocationType(int type) const { return false; }
virtual bool relocateOpcode(int type, RelocationData& data) = 0;
virtual void setSymbolAddress(RelocationData& data, int64_t symbolAddress, int symbolType) = 0;
virtual CAssemblerCommand* generateCtorStub(std::vector<ElfRelocatorCtor>& ctors) { return nullptr; }

0 comments on commit c082e18

Please sign in to comment.