Skip to content

Commit eda844b

Browse files
authored
Fix RIP-relative detection and mmap parameters (#109)
* bug-fix:order args of `mmap` * bug-fix:condition of RIP-relative LEA
1 parent 5e098f7 commit eda844b

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/e9patch/e9CFR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void targetAnalysis(Binary *B)
241241
uint8_t modRM = data[j+2];
242242
uint8_t mod = (modRM & 0xc0) >> 6;
243243
uint8_t rm = modRM & 0x7;
244-
if (mod != 0x00 && rm != 0x05)
244+
if (mod != 0x00 || rm != 0x05)
245245
continue;
246246
target = j + 7 + *(int32_t *)(data + j + 3);
247247
if (target >= 0 && target % sizeof(int32_t) == 0)

src/e9tool/e9frontend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ ELF *e9tool::parseELF(const char *filename, intptr_t base)
895895
strerror(errno));
896896

897897
size_t size = (size_t)stat.st_size;
898-
void *ptr = mmap(NULL, size, MAP_SHARED, PROT_READ, fd, 0);
898+
void *ptr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
899899
if (ptr == MAP_FAILED)
900900
error("failed to map file \"%s\" into memory: %s", filename,
901901
strerror(errno));
@@ -1355,7 +1355,7 @@ ELF *e9tool::parsePE(const char *filename)
13551355
strerror(errno));
13561356

13571357
size_t size = (size_t)stat.st_size;
1358-
void *ptr = mmap(NULL, size, MAP_SHARED, PROT_READ, fd, 0);
1358+
void *ptr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
13591359
if (ptr == MAP_FAILED)
13601360
error("failed to map file \"%s\" into memory: %s", filename,
13611361
strerror(errno));

0 commit comments

Comments
 (0)