Skip to content

Commit

Permalink
[ELF][HEXAGON] Add R_HEX_8_X relocation
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D50577

llvm-svn: 339477
  • Loading branch information
Sid Manning committed Aug 10, 2018
1 parent b5dd3cc commit 07e541a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lld/ELF/Arch/Hexagon.cpp
Expand Up @@ -104,6 +104,14 @@ static uint32_t findMaskR6(uint32_t Insn) {
return 0;
}

static uint32_t findMaskR8(uint32_t Insn) {
if ((0xff000000 & Insn) == 0xde000000)
return 0x00e020e8;
if ((0xff000000 & Insn) == 0x3c000000)
return 0x0000207f;
return 0x00001fe0;
}

static void or32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) | V); }

void Hexagon::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
Expand All @@ -114,6 +122,9 @@ void Hexagon::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
case R_HEX_6_X:
or32le(Loc, applyMask(findMaskR6(read32le(Loc)), Val));
break;
case R_HEX_8_X:
or32le(Loc, applyMask(findMaskR8(read32le(Loc)), Val));
break;
case R_HEX_12_X:
or32le(Loc, applyMask(0x000007e0, Val));
break;
Expand Down
13 changes: 13 additions & 0 deletions lld/test/ELF/hexagon.s
Expand Up @@ -159,3 +159,16 @@ r0.h = #HI(_start)
# R_HEX_LO16
r0.l = #LO(_start)
# CHECK: r0.l = #4096

# R_HEX_8_X has 3 relocation mask variations
#0xde000000
r0=sub(##_start,asl(r1,#4))
# CHECK: de00c406 r0 = sub(##69632,asl(r0,#4)) }

#0x3c000000
memw(r0+#0) = ##_start
# CHECK: 3c40c000 memw(r0+#0) = ##69632 }

# The rest:
r1:0=combine(r2,##_start);
# CHECK: 7302e000 r1:0 = combine(r2,##69632) }

0 comments on commit 07e541a

Please sign in to comment.