Chameleon

Chameleon Commit Details

Date:2010-12-19 06:59:26 (8 years 7 months ago)
Author:Evan Lojewski
Commit:680
Parents: 679
Message:Module loader update: Read in special librayr ordinal values correctly. Now uses the values to ignore certain bind information when unneded
Changes:
M/branches/meklort/i386/boot2/modules.c

File differences

branches/meklort/i386/boot2/modules.c
66
77
88
9
109
1110
1211
......
820819
821820
822821
823
822
824823
825824
826825
......
833832
834833
835834
836
835
837836
838837
839838
840839
841840
842
843
841
842
844843
845844
846845
......
926925
927926
928927
929
928
930929
931
932
933
930
931
934932
935933
936934
937
938
935
936
937
938
939
940
941
942
943
944
945
946
947
939948
940949
941950
......
956965
957966
958967
959
960
968
961969
962
963
964
970
965971
966972
967973
968
969
974
975
976
977
978
979
980
981
982
983
984
970985
971986
972987
......
975990
976991
977992
978
979
993
980994
981
982
983
995
984996
985997
986998
987
988
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
9891010
9901011
9911012
......
10231044
10241045
10251046
1026
1027
1028
1047
1048
1049
1050
1051
1052
1053
1054
1055
10291056
10301057
10311058
10321059
10331060
1034
1035
1061
1062
1063
1064
1065
1066
1067
1068
1069
10361070
10371071
10381072
......
11711205
11721206
11731207
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
11851208
11861209
11871210
......
11961219
11971220
11981221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
11991233
12001234
12011235
#include "boot.h"
#include "bootstruct.h"
#include "multiboot.h"
#include "modules.h"
#ifndef DEBUG_MODULES
case BIND_OPCODE_SET_DYLIB_ORDINAL_IMM:
libraryOrdinal = immediate;
//DBG("BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: %d\n", libraryOrdinal);
//printf("BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: %d\n", libraryOrdinal);
break;
case BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB:
}
while(bind_stream[i] & 0x80);
//DBG("BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: %d\n", libraryOrdinal);
//printf("BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: %d\n", libraryOrdinal);
break;
case BIND_OPCODE_SET_DYLIB_SPECIAL_IMM:
// NOTE: this is wrong, fortunately we don't use it
libraryOrdinal = -immediate;
//DBG("BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: %d\n", libraryOrdinal);
libraryOrdinal = immediate ? (SInt8)(BIND_OPCODE_MASK | immediate) : immediate;
//printf("BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: %d\n", libraryOrdinal);
break;
case BIND_OPCODE_DO_BIND:
//DBG("BIND_OPCODE_DO_BIND\n");
if(symbolAddr != 0xFFFFFFFF)
if(libraryOrdinal == BIND_SPECIAL_DYLIB_FLAT_LOOKUP && type == BIND_TYPE_POINTER)
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
// HACK(ish)
// Internal symbol, don't bind
}
else
{
printf("Unable to bind symbol %s\n", symbolName);
getc();
//printf("Binding symbol %s, libraryOrdinal = %d, symboFlags = %d, type = %d\n", symbolName, libraryOrdinal, symboFlags, type);
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
}
else
{
printf("Unable to bind symbol %s, libraryOrdinal = %d, symboFlags = %d, type = %d\n", symbolName, libraryOrdinal, symboFlags, type);
getc();
}
}
segmentAddress += sizeof(void*);
while(bind_stream[i] & 0x80);
if(symbolAddr != 0xFFFFFFFF)
if(libraryOrdinal == BIND_SPECIAL_DYLIB_FLAT_LOOKUP && type == BIND_TYPE_POINTER)
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
// Internal symbol, don't bind
}
else
{
printf("Unable to bind symbol %s\n", symbolName);
getc();
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
}
else
{
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(symbolAddr != 0xFFFFFFFF)
if(libraryOrdinal == BIND_SPECIAL_DYLIB_FLAT_LOOKUP && type == BIND_TYPE_POINTER)
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
// Internal symbol, don't bind
}
else
{
printf("Unable to bind symbol %s\n", symbolName);
getc();
if(symbolAddr != 0xFFFFFFFF)
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
}
else
{
printf("Unable to bind symbol %s\n", symbolName);
getc();
}
}
segmentAddress += (immediate * sizeof(void*)) + sizeof(void*);
{
address = segmentAddress + (UInt32)base;
bind_location((UInt32*)address, (char*)symbolAddr, addend, BIND_TYPE_POINTER);
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
{
printf("Unable to bind symbol %s\n", symbolName);
getc();
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();
}
}
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
verbose("Unable to locate symbol %s\n", name);

Archive Download the corresponding diff file

Revision: 680