mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-10-24 06:01:09 +00:00
Merge remote-tracking branch 'origin/GP-3216_emteere_CParserLower_ul'
into patch (Closes #5069)
This commit is contained in:
commit
a9530fa137
|
@ -76,6 +76,15 @@ public class AddressEvaluatorTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
|
||||
assertEquals(addr("0x1"), AddressEvaluator.evaluate(p, "(((0x1 | 0x2) & 0x2) >= 0x1)"));
|
||||
assertEquals(addr("0x0"), AddressEvaluator.evaluate(p, "(((0x1 | 0x2) & 0x2) <= 0x1)"));
|
||||
|
||||
assertEquals(addr("0x4"), AddressEvaluator.evaluate(p, "(4ul)"));
|
||||
assertEquals(addr("0x4"), AddressEvaluator.evaluate(p, "(4UL)"));
|
||||
assertEquals(addr("0x4"), AddressEvaluator.evaluate(p, "( 4l )"));
|
||||
assertEquals(addr("0x4"), AddressEvaluator.evaluate(p, "(4L)"));
|
||||
assertEquals(addr("0x4"), AddressEvaluator.evaluate(p, "(4u )"));
|
||||
assertEquals(addr("0x4"), AddressEvaluator.evaluate(p, "( 4U)"));
|
||||
|
||||
assertEquals(null, AddressEvaluator.evaluate(p, "( 4P)"));
|
||||
|
||||
Symbol s = p.getSymbolTable().createLabel(addr("0x100"), "entry", SourceType.IMPORTED);
|
||||
Address a = s.getAddress();
|
||||
|
|
|
@ -117,7 +117,7 @@ public class PreProcessorTest extends AbstractGenericTest {
|
|||
public void testDefines() throws Exception {
|
||||
long value;
|
||||
String defname;
|
||||
|
||||
|
||||
value = 32516;
|
||||
defname = "DefVal1";
|
||||
checkDefine(dtMgr, path, value, defname);
|
||||
|
@ -157,7 +157,31 @@ public class PreProcessorTest extends AbstractGenericTest {
|
|||
value = ((0x7fff) * 900L / 1000);
|
||||
defname = "DefVal10";
|
||||
checkDefine(dtMgr, path, value, defname);
|
||||
|
||||
value = 1;
|
||||
defname = "DefVal_1L";
|
||||
checkDefine(dtMgr, path, value, defname);
|
||||
|
||||
value = 2;
|
||||
defname = "DefVal_2l";
|
||||
checkDefine(dtMgr, path, value, defname);
|
||||
|
||||
value = 3;
|
||||
defname = "DefVal_3U";
|
||||
checkDefine(dtMgr, path, value, defname);
|
||||
|
||||
value = 4;
|
||||
defname = "DefVal_4u";
|
||||
checkDefine(dtMgr, path, value, defname);
|
||||
|
||||
value = 5;
|
||||
defname = "DefVal_5UL";
|
||||
checkDefine(dtMgr, path, value, defname);
|
||||
|
||||
value = 6;
|
||||
defname = "DefVal_6ul";
|
||||
checkDefine(dtMgr, path, value, defname);
|
||||
|
||||
value = 0;
|
||||
defname = "TOO_MANY_FISH";
|
||||
checkDefine(dtMgr, path, value, defname);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#undef a
|
||||
#endif
|
||||
|
||||
|
||||
/* definition coming from -D, should evaluate to true */
|
||||
#if FROM_ARG_VALUE
|
||||
#define DID_ARG_VALUE 1
|
||||
|
@ -218,6 +219,13 @@ int TEST_FAILED;
|
|||
|
||||
#define DefVal10 ((0x7fff) * 900L / 1000)
|
||||
|
||||
#define DefVal_1L (1L)
|
||||
#define DefVal_2l (2l)
|
||||
#define DefVal_3U (3U )
|
||||
#define DefVal_4u ( 4u)
|
||||
#define DefVal_5UL ( 5UL )
|
||||
#define DefVal_6ul (6ul)
|
||||
|
||||
#define BIGNUM 64 * 16 + 16
|
||||
|
||||
#define ImOctal 01234567
|
||||
|
|
|
@ -257,7 +257,7 @@ public class AddressEvaluator {
|
|||
if (globalSymbols.size() == 1) {
|
||||
return globalSymbols.get(0).getAddress();
|
||||
}
|
||||
return null;
|
||||
return getValueObject(tok);
|
||||
}
|
||||
|
||||
private static Object getValueObject(String strValue) {
|
||||
|
@ -268,10 +268,11 @@ public class AddressEvaluator {
|
|||
start = 2;
|
||||
radix = 16;
|
||||
}
|
||||
if (strValue.endsWith("UL")) {
|
||||
strValue = strValue.toLowerCase();
|
||||
if (strValue.endsWith("ul")) {
|
||||
strValue = strValue.substring(start, strValue.length() - 2);
|
||||
}
|
||||
else if (strValue.endsWith("L") || strValue.endsWith("l") || strValue.endsWith("U")) {
|
||||
else if (strValue.endsWith("l") || strValue.endsWith("u")) {
|
||||
strValue = strValue.substring(start, strValue.length() - 1);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user