Skip to content

Commit 4ae6b53

Browse files
radaretrufae
authored andcommitted
Fix unsupported reloc type 1027 on ELF-x64 binaries ##bin
1 parent cd7f38d commit 4ae6b53

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

libr/bin/format/elf/elf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3321,13 +3321,14 @@ typedef struct {
33213321

33223322
static bool read_relr_entry(ELFOBJ *eo, RBinElfReloc *r, ut64 vaddr, ut64 entry, RelrInfo *info) {
33233323
R_RETURN_VAL_IF_FAIL (eo && r && info, false);
3324+
bool arm64 = eo->ehdr.e_machine == EM_AARCH64;
33243325

33253326
// If entry is even (LSB == 0), it's an address to relocate
33263327
if ((entry & 1) == 0) {
33273328
r->mode = DT_RELR;
33283329
r->offset = entry;
33293330
r->rva = entry;
3330-
r->type = R_AARCH64_RELATIVE;
3331+
r->type = arm64? R_AARCH64_RELATIVE: R_X86_64_RELATIVE;
33313332
r->sym = 0; // RELR relocations don't refer to symbols
33323333
r->addend = 0;
33333334
// Set next_addr to the word after the one pointed to by entry
@@ -3347,7 +3348,7 @@ static bool read_relr_entry(ELFOBJ *eo, RBinElfReloc *r, ut64 vaddr, ut64 entry,
33473348
r->mode = DT_RELR;
33483349
r->offset = info->next_addr + (bit_pos * sizeof (Elf_(Addr)));
33493350
r->rva = r->offset;
3350-
r->type = R_AARCH64_RELATIVE;
3351+
r->type = arm64? R_AARCH64_RELATIVE: R_X86_64_RELATIVE;
33513352
r->sym = 0; // RELR relocations don't refer to symbols
33523353
r->addend = 0;
33533354
return true;

libr/bin/p/bin_elf.inc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ static RBinReloc *reloc_convert(ELFOBJ* eo, RBinElfReloc *rel, ut64 got_addr) {
590590
case R_X86_64_TPOFF64: ADD(64, 0); break;
591591
case R_X86_64_DTPMOD64: break; // id of module containing symbol (keep it as zero)
592592
case R_X86_64_DTPOFF64: ADD(64, 0); break; // offset inside module's tls
593+
// case 1027: // this is aarc64_relative, if this appears here we are mixing x64 and arm64 reloc types
593594
default:
594595
R_LOG_WARN ("Unsupported reloc type %d for x64", rel->type);
595596
break;

0 commit comments

Comments
 (0)