Skip to content

Commit

Permalink
Ignore R_ARM_V4BX relocation for ARM
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingcom committed Jan 7, 2018
1 parent a1b9d43 commit c082e18
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Archs/ARM/ArmRelocator.cpp
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Archs/ARM/ArmRelocator.h
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions Core/ELF/ElfRelocator.cpp
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions Core/ELF/ElfRelocator.h
Expand Up @@ -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; }
Expand Down

0 comments on commit c082e18

Please sign in to comment.