Browse code

rename x86 macroes due to collisions on HPUX

git-svn: trunk@3141

aCaB authored on 2007/07/12 09:38:51
Showing 8 changed files
... ...
@@ -1,3 +1,8 @@
1
+Thu Jul 12 01:41:56 CEST 2007 (acab)
2
+------------------------------------
3
+  * libclamav: rename x86 macroes due to collisions on HPUX
4
+  		reported by njh
5
+
1 6
 Wed Jul 11 10:20:53 BST 2007 (njh)
2 7
 ----------------------------------
3 8
   * libclamav:	Fix warnings on HP-UX
... ...
@@ -375,7 +375,7 @@ int unaspack212(uint8_t *image, unsigned int size, struct cli_exe_section *secti
375 375
 	  wrkbuf = &image[block_rva+i+1];
376 376
 	  if (*wrkbuf == image[ep+0x148]) {
377 377
 	    uint32_t target = cli_readint32(wrkbuf) & 0xffffff00;
378
-	    ROL(target, 0x18);
378
+	    CLI_ROL(target, 0x18);
379 379
 	    cli_writeint32(wrkbuf, target - i);
380 380
 	    i+=4;
381 381
 	  }
... ...
@@ -129,16 +129,16 @@ typedef struct {
129 129
 #endif
130 130
 
131 131
 /* used by: spin, yc (C) aCaB */
132
-#define ROL(a,b) a = ( a << (b % (sizeof(a)<<3) ))  |  (a >> (  (sizeof(a)<<3)  -  (b % (sizeof(a)<<3 )) ) )
133
-#define ROR(a,b) a = ( a >> (b % (sizeof(a)<<3) ))  |  (a << (  (sizeof(a)<<3)  -  (b % (sizeof(a)<<3 )) ) )
132
+#define CLI_ROL(a,b) a = ( a << (b % (sizeof(a)<<3) ))  |  (a >> (  (sizeof(a)<<3)  -  (b % (sizeof(a)<<3 )) ) )
133
+#define CLI_ROR(a,b) a = ( a >> (b % (sizeof(a)<<3) ))  |  (a << (  (sizeof(a)<<3)  -  (b % (sizeof(a)<<3 )) ) )
134 134
 
135 135
 /* Implementation independent sign-extended signed right shift */
136 136
 #ifdef HAVE_SAR
137
-#define SRS(n,s) ((n)>>(s))
137
+#define CLI_SRS(n,s) ((n)>>(s))
138 138
 #else
139
-#define SRS(n,s) (((n)>>(s)) ^ (1<<(sizeof(n)*8-1-s)) - (1<<(sizeof(n)*8-1-s)))
139
+#define CLI_SRS(n,s) (((n)>>(s)) ^ (1<<(sizeof(n)*8-1-s)) - (1<<(sizeof(n)*8-1-s)))
140 140
 #endif
141
-#define SAR(n,s) n = SRS(n,s)
141
+#define CLI_SAR(n,s) n = CLI_SRS(n,s)
142 142
 
143 143
 #ifndef	FALSE
144 144
 #define FALSE (0)
... ...
@@ -112,8 +112,8 @@ static char exec86(uint8_t aelle, uint8_t cielle, char *curremu, int *retval) {
112 112
       case 0xc0: /* ror/rol al, ?? */
113 113
 	support = curremu[len];
114 114
         len++;
115
-        if ( support == 0xc0 ) ROL(aelle, curremu[len]);
116
-        else ROR(aelle, curremu[len]);
115
+        if ( support == 0xc0 ) CLI_ROL(aelle, curremu[len]);
116
+        else CLI_ROR(aelle, curremu[len]);
117 117
         len++;
118 118
         break;
119 119
 
... ...
@@ -144,7 +144,7 @@ static uint32_t summit (char *src, int size)
144 144
       eax ^= ebx>>8 & 0xff;
145 145
       eax += 0x7801a108;
146 146
       eax ^= ebx;
147
-      ROR(eax, ebx&0xff);
147
+      CLI_ROR(eax, ebx&0xff);
148 148
       swap = eax;
149 149
       eax = ebx;
150 150
       ebx = swap;
... ...
@@ -400,7 +400,7 @@ int getbit_from_table(uint16_t *intable, struct UNSP *read_struct) {
400 400
     read_struct->bitmap = nval;
401 401
     nval = *intable;
402 402
     sval = 0x800 - nval;
403
-    sval = SRS((int32_t)sval,5); /* signed */
403
+    sval = CLI_SRS((int32_t)sval,5); /* signed */
404 404
     sval += nval;
405 405
     *intable=sval;
406 406
     if (read_struct->bitmap<0x1000000) { /* unsigned */
... ...
@@ -543,7 +543,7 @@ int unupack399(char *bs, uint32_t bl, uint32_t init_eax, char *init_ebx, uint32_
543 543
 						return -1;
544 544
 					/* cdq, loc_edx = (loc_eax&0x80000000)?0xffffffff:0; */
545 545
 					loc_ecx = temp_ebp;
546
-					temp_ebp = SRS((int32_t)loc_eax, 31); /* thx, desp */
546
+					temp_ebp = CLI_SRS((int32_t)loc_eax, 31); /* thx, desp */
547 547
 					/* loc_483a00 */
548 548
 					do {
549 549
 						temp_ebp += temp_ebp;
... ...
@@ -394,7 +394,7 @@ int upx_inflate2d(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_
394 394
       if (!backbytes)
395 395
 	break;
396 396
       backsize = backbytes & 1;
397
-      SAR(backbytes,1);
397
+      CLI_SAR(backbytes,1);
398 398
       unp_offset = backbytes;
399 399
     } else {
400 400
       if ( (backsize = (uint32_t)doubleebx(src, &myebx, &scur, ssize)) == 0xffffffff )
... ...
@@ -474,7 +474,7 @@ int upx_inflate2e(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_
474 474
       if (!backbytes)
475 475
 	break;
476 476
       backsize = backbytes & 1; /* Using backsize to carry on the shifted out bit (UPX uses CF) */
477
-      SAR(backbytes,1);
477
+      CLI_SAR(backbytes,1);
478 478
       unp_offset = backbytes;
479 479
     } else {
480 480
       if ( (backsize = (uint32_t)doubleebx(src, &myebx, &scur, ssize)) == 0xffffffff )
... ...
@@ -120,12 +120,12 @@ static int yc_poly_emulator(char* decryptor_offset, char* code, unsigned int ecx
120 120
 	      if(decryptor_offset[j]=='\xC0') /* ROL AL,num */
121 121
 		{
122 122
 		  j++;
123
-		  ROL(al,decryptor_offset[j]);
123
+		  CLI_ROL(al,decryptor_offset[j]);
124 124
 		}
125 125
 	      else			/* ROR AL,num */
126 126
 		{
127 127
 		  j++;
128
-		  ROR(al,decryptor_offset[j]);
128
+		  CLI_ROR(al,decryptor_offset[j]);
129 129
 		}
130 130
 	      break;
131 131
 
... ...
@@ -134,12 +134,12 @@ static int yc_poly_emulator(char* decryptor_offset, char* code, unsigned int ecx
134 134
 	      if(decryptor_offset[j]=='\xC8') /* ROR AL,CL */
135 135
 		{
136 136
 		  j++;
137
-		  ROR(al,cl);
137
+		  CLI_ROR(al,cl);
138 138
 		}
139 139
 	      else			/* ROL AL,CL */
140 140
 		{
141 141
 		  j++;
142
-		  ROL(al,cl);
142
+		  CLI_ROL(al,cl);
143 143
 		}
144 144
 	      break;
145 145