Chameleon

Chameleon Commit Details

Date:2010-12-20 05:19:39 (8 years 8 months ago)
Author:Sergey Slice
Commit:682
Parents: 681
Message:module revert
Changes:
M/branches/slice/revision
M/branches/slice/i386/boot2/modules.c

File differences

branches/slice/i386/boot2/modules.c
840840
841841
842842
843
844
843
844
845845
846846
847847
......
927927
928928
929929
930
931
932
933
934
935
936
937
938
939930
940931
941932
......
944935
945936
946937
947
938
948939
949940
950
951941
952942
953943
......
967957
968958
969959
970
971
972
973
974
975
960
976961
977962
978963
......
984969
985970
986971
987
988972
989973
990974
......
992976
993977
994978
995
996
997
998
999
1000
979
1001980
1002981
1003982
......
1009988
1010989
1011990
1012
1013991
1014992
1015993
......
10461024
10471025
10481026
1049
1050
1051
1052
1053
1054
10551027
10561028
1057
1029
10581030
10591031
10601032
1061
1033
10621034
1063
1064
1065
1066
1067
1068
10691035
10701036
10711037
1072
10731038
10741039
10751040
......
12071172
12081173
12091174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
12101186
12111187
12121188
......
12211197
12221198
12231199
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
12361200
1201
1202
12371203
12381204
1205
12391206
12401207
12411208
......
13381305
13391306
13401307
1341
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
case BIND_OPCODE_SET_DYLIB_SPECIAL_IMM:
// NOTE: this is wrong, fortunately we don't use it
libraryOrdinal = immediate ? (SInt8)(BIND_OPCODE_MASK | immediate) : immediate;
//printf("BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: %d\n", libraryOrdinal);
libraryOrdinal = -immediate;
//DBG("BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: %d\n", libraryOrdinal);
break;
case BIND_OPCODE_DO_BIND:
//DBG("BIND_OPCODE_DO_BIND\n");
if(libraryOrdinal == BIND_SPECIAL_DYLIB_FLAT_LOOKUP && type == BIND_TYPE_POINTER)
{
// HACK(ish)
// Internal symbol, don't bind
}
else
{
//printf("Binding symbol %s, libraryOrdinal = %d, symboFlags = %d, type = %d\n", symbolName, libraryOrdinal, symboFlags, type);
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
}
else //if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0)
{
printf("Unable to bind symbol %s, libraryOrdinal = %d, symboFlags = %d, type = %d\n", symbolName, libraryOrdinal, symboFlags, type);
printf("Unable to bind symbol %s\n", symbolName);
getc();
}
}
segmentAddress += sizeof(void*);
break;
while(bind_stream[i] & 0x80);
if(libraryOrdinal == BIND_SPECIAL_DYLIB_FLAT_LOOKUP && type == BIND_TYPE_POINTER)
{
// Internal symbol, don't bind
}
else
{
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
printf("Unable to bind symbol %s\n", symbolName);
getc();
}
}
segmentAddress += tmp + sizeof(void*);
case BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED:
//DBG("BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED\n");
if(libraryOrdinal == BIND_SPECIAL_DYLIB_FLAT_LOOKUP && type == BIND_TYPE_POINTER)
{
// Internal symbol, don't bind
}
else
{
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
printf("Unable to bind symbol %s\n", symbolName);
getc();
}
}
segmentAddress += (immediate * sizeof(void*)) + sizeof(void*);
{
address = segmentAddress + (UInt32)base;
if(libraryOrdinal == BIND_SPECIAL_DYLIB_FLAT_LOOKUP && type == BIND_TYPE_POINTER)
{
// Internal symbol, don't bind
}
else
{
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
}
segmentAddress += tmp2 + sizeof(void*);
}
}
else
else //if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0)
{
if(libraryOrdinal == BIND_SPECIAL_DYLIB_FLAT_LOOKUP && type == BIND_TYPE_POINTER)
{
// Internal symbol, don't bind
}
else
{
printf("Unable to bind symbol %s\n", symbolName);
getc();
}
}
break;
unsigned int lookup_all_symbols(const char* name)
{
unsigned int addr = 0xFFFFFFFF;
if(lookup_symbol && (UInt32)lookup_symbol != 0xFFFFFFFF)
{
addr = lookup_symbol(name);
if(addr != 0xFFFFFFFF)
{
//DBG("Internal symbol %s located at 0x%X\n", name, addr);
return addr;
}
}
symbolList_t* entry = moduleSymbols;
while(entry)
{
}
}
if(lookup_symbol && (UInt32)lookup_symbol != 0xFFFFFFFF)
{
addr = lookup_symbol(name);
if(addr != 0xFFFFFFFF)
{
//DBG("Internal symbol %s located at 0x%X\n", name, addr);
return addr;
}
}
#if DEBUG_MODULES
//if(strcmp(name, SYMBOL_DYLD_STUB_BINDER) != 0)
//{
verbose("Unable to locate symbol %s\n", name);
getc();
//}
#endif
return 0xFFFFFFFF;
}
{
// TODO: actualy impliment this function (asm)
stop("ERROR: dyld_stub_binder was called, should have been take care of by the linker.\n");
}
}
/* Nedded to divide 64bit numbers correctly. TODO: look into why modules need this
* And why it isn't needed when compiled into boot2
*/
uint64_t __udivdi3(uint64_t numerator, uint64_t denominator)
{
uint64_t quotient = 0, qbit = 1;
if (denominator)
{
while ((int64_t) denominator >= 0)
{
denominator <<= 1;
qbit <<= 1;
}
while (denominator)
{
if (denominator <= numerator)
{
numerator -= denominator;
quotient += qbit;
}
denominator >>= 1;
qbit >>= 1;
}
return quotient;
}
else {
stop("Divide by 0");
return 0;
}
}
branches/slice/revision
1
1
676:678
676:681

Archive Download the corresponding diff file

Revision: 682