@@ -1051,12 +1051,13 @@ void instruction_from_string_build_base(const InstructionMap *im = nullptr,
1051
1051
}
1052
1052
if (!(im->flags & IMF_SUPPORTED))
1053
1053
continue ;
1054
- str_to_instruction_code_map.insert (im->name , code);
1055
- #if 0
1056
1054
if (im->code != code) {
1055
+ #if 0
1057
1056
printf("code mitchmatch %s computed 0x%08x found 0x%08x\n", im->name, code, im->code);
1057
+ #endif
1058
+ continue ;
1058
1059
}
1059
- # endif
1060
+ str_to_instruction_code_map. insert (im-> name , code);
1060
1061
}
1061
1062
#if 0
1062
1063
for (auto i = str_to_instruction_code_map.begin();
@@ -1074,11 +1075,17 @@ static int parse_reg_from_string(QString str, uint *chars_taken = nullptr)
1074
1075
return -1 ;
1075
1076
1076
1077
if (str.at (1 ).isLetter ()) {
1077
- str = str.mid (1 );
1078
+ int k = 1 ;
1079
+ while (k < str.count ()) {
1080
+ if (!str.at (k).isLetterOrNumber ())
1081
+ break ;
1082
+ k++;
1083
+ }
1084
+ str = str.mid (1 , k-1 );
1078
1085
for (i = 0 ; i < REGISTER_CODES; i++) {
1079
1086
if (str == regbycode[i].name ) {
1080
1087
if (chars_taken != nullptr )
1081
- *chars_taken = str. count () + 1 ;
1088
+ *chars_taken = k ;
1082
1089
return regbycode[i].number ;
1083
1090
}
1084
1091
}
@@ -1235,7 +1242,7 @@ ssize_t Instruction::code_from_string(std::uint32_t *code, size_t buffsize,
1235
1242
break ;
1236
1243
case ' a' :
1237
1244
shift_right += options & 0xff ;
1238
- val -= (inst_addr + 4 ) & 0xf0000000 ;
1245
+ val -= (inst_addr + 4 ) & ~(std:: int64_t ) 0x0fffffff ;
1239
1246
if (fl.at (0 ).isDigit () || (reloc == nullptr )) {
1240
1247
std::uint64_t num_val;
1241
1248
int i;
@@ -1256,7 +1263,7 @@ ssize_t Instruction::code_from_string(std::uint32_t *code, size_t buffsize,
1256
1263
need_reloc = true ;
1257
1264
}
1258
1265
if (need_reloc && (reloc != nullptr )) {
1259
- reloc_append (reloc, fl, val, inst_addr , adesc, &chars_taken, line, options);
1266
+ reloc_append (reloc, fl, inst_addr, val , adesc, &chars_taken, line, options);
1260
1267
val = 0 ;
1261
1268
}
1262
1269
break ;
@@ -1326,7 +1333,7 @@ ssize_t Instruction::code_from_string(std::uint32_t *code, size_t buffsize,
1326
1333
error = QString (" error in LUI element of " + inst_base);
1327
1334
return -1 ;
1328
1335
}
1329
- inst_fields.insert (1 , " $0 " );
1336
+ inst_fields.insert (1 , inst_fields. at ( 0 ) );
1330
1337
if (code_from_string (code + 1 , buffsize - 4 , " ORI" , inst_fields, error,
1331
1338
inst_addr + 4 , reloc, line, false ,
1332
1339
CFS_OPTION_SILENT_MASK + 0 ) < 0 ) {
@@ -1378,6 +1385,8 @@ ssize_t Instruction::code_from_string(std::uint32_t *code, size_t buffsize,
1378
1385
bool Instruction::update (std::int64_t val, RelocExpression *relocexp) {
1379
1386
std::int64_t mask = (((std::int64_t )1 << relocexp->bits ) - 1 ) << relocexp->lsb_bit ;
1380
1387
dt &= ~ mask;
1388
+ if (relocexp->shift )
1389
+ printf (" reloc shift\n " );
1381
1390
val += relocexp->offset ;
1382
1391
if ((val & ((1 << relocexp->shift ) - 1 )) &&
1383
1392
!(relocexp->options & CFS_OPTION_SILENT_MASK)) {
@@ -1392,7 +1401,9 @@ bool Instruction::update(std::int64_t val, RelocExpression *relocexp) {
1392
1401
if (relocexp->min < 0 ) {
1393
1402
if (((std::int64_t )val < relocexp->min ) ||
1394
1403
((std::int64_t )val > relocexp->max )) {
1395
- return false ;
1404
+ if (((std::int64_t )val - 0x100000000 < relocexp->min ) ||
1405
+ ((std::int64_t )val - 0x100000000 > relocexp->max ))
1406
+ return false ;
1396
1407
}
1397
1408
} else {
1398
1409
if (((std::uint64_t )val < (std::uint64_t )relocexp->min ) ||
0 commit comments