Skip to content

Commit

Permalink
Add support for R_HEX_B32_PCREL_X, R_HEX_B22_PCREL_X relocations
Browse files Browse the repository at this point in the history
A couple more basic relocations plus testcase.

Differential Revision: https://reviews.llvm.org/D47791

llvm-svn: 337484
  • Loading branch information
Sid Manning committed Jul 19, 2018
1 parent d4d6e21 commit bdd71f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lld/ELF/Arch/Hexagon.cpp
Expand Up @@ -54,6 +54,8 @@ RelExpr Hexagon::getRelExpr(RelType Type, const Symbol &S,
const uint8_t *Loc) const {
switch (Type) {
case R_HEX_B22_PCREL:
case R_HEX_B22_PCREL_X:
case R_HEX_B32_PCREL_X:
return R_PC;
default:
return R_ABS;
Expand All @@ -69,6 +71,12 @@ void Hexagon::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
case R_HEX_B22_PCREL:
or32le(Loc, applyMask(0x1ff3ffe, Val >> 2));
break;
case R_HEX_B22_PCREL_X:
or32le(Loc, applyMask(0x1ff3ffe, Val & 0x3f));
break;
case R_HEX_B32_PCREL_X:
or32le(Loc, applyMask(0x0fff3fff, Val >> 6));
break;
default:
error(getErrorLocation(Loc) + "unrecognized reloc " + toString(Type));
break;
Expand Down
6 changes: 6 additions & 0 deletions lld/test/ELF/hexagon.s
Expand Up @@ -7,3 +7,9 @@
# R_HEX_B22_PCREL
call #_start
# CHECK: call 0x11000

# R_HEX_B32_PCREL_X
# R_HEX_B22_PCREL_X
call ##_start
# CHECK: immext(#4294967232)
# CHECK: call 0x11000

0 comments on commit bdd71f3

Please sign in to comment.