Chameleon

Chameleon Commit Details

Date:2012-10-27 20:31:25 (6 years 8 months ago)
Author:Evan Lojewski
Commit:2093
Parents: 2092
Message:Fix Symbols.dylib search address.
Changes:
M/trunk/i386/boot2/modules.c
M/trunk/i386/boot2/Makefile

File differences

trunk/i386/boot2/Makefile
9595
9696
9797
98
98
9999
100100
101101
......
104104
105105
106106
107
108
109107
110108
111109
......
116114
117115
118116
119
117
120118
121119
122120
......
136134
137135
138136
139
137
140138
141139
142140
143141
144142
145
143
146144
147145
148146
......
156154
157155
158156
159
160
161157
162
158
159
163160
164161
165162
......
172169
173170
174171
175
176
177
178
179
180
181
182
183
184
185
186
187172
188173
189174
-nostdlib -arch i386 -Wl,-pie \
-Wl,-segaddr,__INIT,`echo obase=16\; $$((0x${BOOT2ADDR})) | bc` \
-Wl,-segaddr,__TEXT,`echo obase=16\; $$((0x${BOOT2ADDR})) + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __INIT\` | bc` \
-Wl,-segaddr,__DATA,`echo obase=16\; $$((0x${BOOT2ADDR})) + 3582 + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __INIT\` + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __TEXT\` | bc` \
-Wl,-segaddr,__DATA,`echo obase=16\; $$((0x${BOOT2ADDR})) + ${DATA_PAD} + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __INIT\` + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __TEXT\` | bc` \
-Wl,-read_only_relocs,suppress \
-lcc_kext \
$(filter %.o,$^) `find $(OBJROOT)/../boot2_modules/ -name \*.o` $(LIBS) \
ifeq (${CONFIG_MODULES}, y)
@cp $(SYMROOT)/boot.sys $(SYMROOT)/boot2.sys
@# Generate the Symbols.dylib file
@echo "\t[dyldsymboltool] Symbols.dylib"
@$(SYMROOT)/dyldsymboltool $(SYMROOT)/boot.sys $(SYMROOT)/${SYMBOLS_MODULE}
-Wl,-sectcreate,__DATA,__Symbols,$(SYMROOT)/Symbols.dylib \
-Wl,-segaddr,__INIT,`echo obase=16\; $$((0x${BOOT2ADDR})) | bc` \
-Wl,-segaddr,__TEXT,`echo obase=16\; $$((0x${BOOT2ADDR})) + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __INIT\` | bc` \
-Wl,-segaddr,__DATA,`echo obase=16\; $$((0x${BOOT2ADDR})) + 3582 + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __INIT\` + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __TEXT\` | bc` \
-Wl,-segaddr,__DATA,`echo obase=16\; $$((0x${BOOT2ADDR})) + ${DATA_PAD} + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __INIT\` + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __TEXT\` | bc` \
-Wl,-read_only_relocs,suppress \
-lcc_kext \
$(filter %.o,$^) `find $(OBJROOT)/../boot2_modules/ -name \*.o` $(LIBS) \
-Wl,-sectcreate,__DATA,__Symbols,$(SYMROOT)/Symbols.dylib \
-Wl,-segaddr,__INIT,`echo obase=16\; $$((0x${BOOT2ADDR})) | bc` \
-Wl,-segaddr,__TEXT,`echo obase=16\; $$((0x${BOOT2ADDR})) + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __INIT\` | bc` \
-Wl,-segaddr,__DATA,`echo obase=16\; $$((0x${BOOT2ADDR})) + 3582 + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __INIT\` + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __TEXT\` | bc` \
-Wl,-segaddr,__DATA,`echo obase=16\; $$((0x${BOOT2ADDR})) + ${DATA_PAD} + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __INIT\` + \`${SYMROOT}/segsize ${SYMROOT}/$@.sys __TEXT\` | bc` \
-Wl,-read_only_relocs,suppress \
-lcc_kext \
$(filter %.o,$^) `find $(OBJROOT)/../boot2_modules/ -name \*.o` $(LIBS) \
-o ${SYMROOT}/$@.sys
@${RM} $(SYMROOT)/${SYMBOLS_MODULE}
@#${RM} $(SYMROOT)/${SYMBOLS_MODULE}
@$(LD) -arch i386 \
-undefined dynamic_lookup \
endif
@# this is done in a sub process after boot.sys exists so the strings are populated correctly
@make embed_symbols
@${RM} $(SYMROOT)/boot2.sys
@echo "\t[MACHOCONV] boot"
@$(SYMROOT)/machOconv ${SYMROOT}/$@.sys $(SYMROOT)/$@ &> /dev/null
@( size=`ls -l $(SYMROOT)/boot | awk '{ print $$5}'` ; \
if expr "$$size" ">" "$(MAXBOOTSIZE)" > /dev/null ;\
echo "\t******* boot is $$size bytes *******"; \
fi)
embed_symbols:
ifeq (${CONFIG_MODULES}, y)
@echo ================= Embedding Symbols.dylib =================
@echo "\t[MACHOCONV] boot"
@$(SYMROOT)/machOconv $(SYMROOT)/boot2.sys $(SYMROOT)/boot &> /dev/null
@echo "\t******* Patching at $(PATCH_ADDR) ******"
@stat -f%z $(SYMROOT)/boot | perl -ane "print pack('V',@F[0]);" | dd conv=notrunc of=${SYMROOT}/boot.sys bs=1 count=4 seek=$(PATCH_ADDR) &> /dev/null
endif
@echo "\t[MACHOCONV] boot"
@$(SYMROOT)/machOconv $(SYMROOT)/boot.sys $(SYMROOT)/boot
$(SYMROOT)/art.h:
@if [ "$(PNGCRUSH)" ]; then\
echo "optimizing art files ...\n$(PNGCRUSH) $(PNGOPTIONS) artwork/$(THEME)"; \
trunk/i386/boot2/modules.c
2626
2727
2828
29
30
3129
3230
3331
......
4846
4947
5048
51
49
50
51
5252
5353
54
54
5555
5656
5757
......
6060
6161
6262
63
6463
6564
6665
......
6968
7069
7170
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
71
72
9173
9274
9375
UInt64 textAddress = 0;
UInt64 textSection = 0;
void* symbols_module_start = (void*)0xFFFFFFFF;// Global, value is populated by the makefile with actual address
/** Internal symbols, however there are accessor methods **/
moduleHook_t* moduleCallbacks = NULL;
moduleList_t* loadedModules = NULL;
int retVal = 0;
void (*module_start)(void) = NULL;
char* module_data = symbols_module_start + BOOT2_ADDR;
extern char symbols_start __asm("section$start$__DATA$__Symbols");
char* module_data = &symbols_start;
// Intialize module system
if(symbols_module_start != (void*)0xFFFFFFFF)
if(module_data)
{
// Module system was compiled in (Symbols.dylib addr known)
module_start = parse_mach(module_data, &load_module, &add_symbol, NULL);
{
// Notify the system that it was laoded
module_loaded(SYMBOLS_MODULE, SYMBOLS_AUTHOR, SYMBOLS_DESCRIPTION, SYMBOLS_VERSION, SYMBOLS_COMPAT);
(*module_start)();// Start the module. This will point to load_all_modules due to the way the dylib was constructed.
execute_hook("ModulesLoaded", NULL, NULL, NULL, NULL);
DBG("Module %s Loaded.\n", SYMBOLS_MODULE);
}
else
{
module_data -= 0x10; // XCODE 4 HACK
module_start = parse_mach(module_data, &load_module, &add_symbol, NULL);
if(module_start && module_start != (void*)0xFFFFFFFF)
{
// Notify the system that it was laoded
module_loaded(SYMBOLS_MODULE, SYMBOLS_AUTHOR, SYMBOLS_DESCRIPTION, SYMBOLS_VERSION, SYMBOLS_COMPAT);
(*module_start)();// Start the module. This will point to load_all_modules due to the way the dylib was constructed.
execute_hook("ModulesLoaded", NULL, NULL, NULL, NULL);
DBG("Module %s Loaded.\n", SYMBOLS_MODULE);
retVal = 1;
}
else
{
// The module does not have a valid start function
printf("Unable to start %s\n", SYMBOLS_MODULE); getchar();
}
// The module does not have a valid start function
printf("Unable to start %s at 0x%x\n", SYMBOLS_MODULE, module_data); pause();
}
}
return retVal;

Archive Download the corresponding diff file

Revision: 2093