Commit 3e5e8466 authored by dill Upstream's avatar dill Upstream Committed by Eisenhauer, Greg
Browse files

dill 2018-05-22 (e0c9c495)

Code extracted from:

    https://github.com/GTkorvo/dill.git

at commit e0c9c495ac7f15f3f41aa378fbcd0d066951ceeb (master).

Upstream Shortlog
-----------------
parent 411a442c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ else()
  project(DILL C CXX)
  set(DILL_MAJOR_VERSION 2)
  set(DILL_MINOR_VERSION 3)
  set(DILL_PATCH_VERSION 2)
  set(DILL_PATCH_VERSION 3)
  set(DILL_VERSION
    ${DILL_MAJOR_VERSION}.${DILL_MINOR_VERSION}.${DILL_PATCH_VERSION})
endif()
+18 −9
Original line number Diff line number Diff line
@@ -172,14 +172,16 @@ BYTE_OUT2IR(dill_stream s, int rex, int insn1, int insn2, int imm32)
    }
    tmp_ip = (unsigned char *) s->p->cur_ip;
    if (rex != 0) {
	int tmp = imm32;
	*tmp_ip = (unsigned char)rex|0x40;
	*(tmp_ip + 1) = (unsigned char)insn1;
	*(tmp_ip + 2) = (unsigned char)insn2;
	*((int *)(tmp_ip + 3)) = imm32;
	memcpy(tmp_ip + 3, &tmp, 4);
    } else {
	int tmp = imm32;
	*(tmp_ip) = (unsigned char)insn1;
	*(tmp_ip + 1) = (unsigned char)insn2;
	*((int *)(tmp_ip + 2)) = imm32;
	memcpy(tmp_ip + 2, &tmp, 4);
    }
    if (s->dill_debug) dump_cur_dill_insn(s);
    s->p->cur_ip = ((char*)s->p->cur_ip)+6;
@@ -195,16 +197,18 @@ BYTE_OUT3IR(dill_stream s, int rex, int insn1, int insn2, int insn3, int imm32)
    }
    tmp_ip = (unsigned char *) s->p->cur_ip;
    if (rex != 0) {
	int tmp = imm32;
	*tmp_ip = (unsigned char)rex|0x40;
	*(tmp_ip + 1) = (unsigned char)insn1;
	*(tmp_ip + 2) = (unsigned char)insn2;
	*(tmp_ip + 3) = (unsigned char)insn3;
	*((int *)(tmp_ip + 4)) = imm32;
	memcpy(tmp_ip + 4, &tmp, 4);
    } else {
	int tmp = imm32;
	*(tmp_ip) = (unsigned char)insn1;
	*(tmp_ip + 1) = (unsigned char)insn2;
	*(tmp_ip + 2) = (unsigned char)insn3;
	*((int *)(tmp_ip + 3)) = imm32;
	memcpy(tmp_ip + 3, &tmp, 4);
    }
    if (s->dill_debug) dump_cur_dill_insn(s);
    s->p->cur_ip = ((char*)s->p->cur_ip)+7;
@@ -220,12 +224,14 @@ BYTE_OUT1IR(dill_stream s, int rex, int insn1, int imm32)
    }
    tmp_ip = (unsigned char *) s->p->cur_ip;
    if (rex != 0) {
	int tmp = imm32;
	*tmp_ip = (unsigned char)rex|0x40;
	*(tmp_ip + 1) = (unsigned char)insn1;
	*((int *)(tmp_ip + 2)) = imm32;
	memcpy(tmp_ip + 2, &tmp, 4);
    } else {
	int tmp = imm32;
	*(tmp_ip) = (unsigned char)insn1;
	*((int *)(tmp_ip + 1)) = imm32;
	memcpy(tmp_ip + 1, &tmp, 4);
    }
    if (s->dill_debug) dump_cur_dill_insn(s);
    s->p->cur_ip = ((char*)s->p->cur_ip)+5;
@@ -241,12 +247,14 @@ BYTE_OUT1LR(dill_stream s, int rex, int insn1, long imm64)
    }
    tmp_ip = (unsigned char *) s->p->cur_ip;
    if (rex != 0) {
	long tmp = imm64;
	*tmp_ip = (unsigned char)rex|0x40;
	*(tmp_ip + 1) = (unsigned char)insn1;
	*((long *)(tmp_ip + 2)) = imm64;
	memcpy(tmp_ip + 2, &tmp, 8);
    } else {
	long tmp = imm64;
	*(tmp_ip) = (unsigned char)insn1;
	*((long *)(tmp_ip + 1)) = imm64;
	memcpy(tmp_ip + 1, &tmp, 8);
    }
    if (s->dill_debug) dump_cur_dill_insn(s);
    s->p->cur_ip = ((char*)s->p->cur_ip)+9;
@@ -2535,7 +2543,8 @@ x86_64_branch_link(dill_stream s)
	    branch_addr++; /* unconditional */
	    offset = 5;
	}
	*(int*)branch_addr = label_offset - offset;
	int tmp = label_offset - offset;
	memcpy(branch_addr, &tmp, 4);
    }
}

+6 −3
Original line number Diff line number Diff line
@@ -115,25 +115,28 @@ if (c->dill_debug) dump_cur_dill_insn(c);\

#define BYTE_OUT2I(c, insn1, insn2,imm32) \
do { \
unsigned int tmp = (unsigned int) imm32; \
if (c->p->cur_ip >= c->p->code_limit) {\
   extend_dill_stream(c);\
}\
*(unsigned char*)c->p->cur_ip = (unsigned char)insn1;\
*(((unsigned char*)c->p->cur_ip) + 1)= (unsigned char)insn2;\
*(unsigned int *)(((unsigned char*)c->p->cur_ip) + 2)= (unsigned int)imm32;\
memcpy((((unsigned char*)c->p->cur_ip) + 2), &tmp, 4);\
if (c->dill_debug) dump_cur_dill_insn(c);\
 c->p->cur_ip = ((char*)c->p->cur_ip)+6; \
} while (0)

#define BYTE_OUT2II(c, insn1, insn2,imm32, imm32_2) \
do { \
unsigned int tmp = (unsigned int) imm32;\
unsigned int tmp2 = (unsigned int) imm32_2;\
if (c->p->cur_ip >= c->p->code_limit) {\
   extend_dill_stream(c);\
}\
*(unsigned char*)c->p->cur_ip = (unsigned char)insn1;\
*(((unsigned char*)c->p->cur_ip) + 1)= (unsigned char)insn2;\
*(unsigned int *)(((unsigned char*)c->p->cur_ip) + 2)= (unsigned int)imm32;\
*(unsigned int *)(((unsigned char*)c->p->cur_ip) + 6)= (unsigned int)imm32_2;\
memcpy((((unsigned char*)c->p->cur_ip) + 2), &tmp, 4);\
memcpy((((unsigned char*)c->p->cur_ip) + 6), &tmp2, 4);\
if (c->dill_debug) dump_cur_dill_insn(c);\
 c->p->cur_ip = ((char*)c->p->cur_ip)+10;	\
} while (0)
+2 −1
Original line number Diff line number Diff line
@@ -23,8 +23,9 @@ x86_64_rt_call_link(char *code, call_t *t)
    int i;

    for(i=0; i< t->call_count; i++) {
	unsigned long tmp = (unsigned long) t->call_locs[i].xfer_addr;
	long *call_addr = (long *) (code + t->call_locs[i].loc + 2);
	*call_addr = (unsigned long)t->call_locs[i].xfer_addr;
	memcpy(call_addr, &tmp, 8);
    }
}