Chameleon

Chameleon Commit Details

Date:2011-01-24 06:55:52 (9 years 10 months ago)
Author:Evan Lojewski
Commit:710
Parents: 709
Message:Symbols.dylib embeded properly in boot. Modules now link to Symbols.dylib properly. Disabled Resolution init code untill, has issues with embeded symbols.dylib. TODO: fix gui / freezeup when embeded. Branch is *NOT* in a usable state
Changes:
M/branches/meklort/i386/modules/MakeInc.dir
M/branches/meklort/i386/boot2/modules.c
M/branches/meklort/i386/modules/Resolution/Resolution.c
M/branches/meklort/i386/boot2/Makefile

File differences

branches/meklort/i386/boot2/modules.c
5757
5858
5959
60
6061
6162
6263
......
371372
372373
373374
374
375
375376
376377
377378
{
void (*module_start)(void) = NULL;
char* module_data = symbols_module_start + BOOT2_ADDR;
// Intialize module system
if(symbols_module_start == (void*)0xFFFFFFFF)
{
}
else
{
printf("Invalid mach magic\n");
printf("Invalid mach magic 0x%X\n", ((struct mach_header*)binary)->magic);
getc();
return NULL;
}
branches/meklort/i386/boot2/Makefile
6666
6767
6868
69
70
71
69
70
71
7272
7373
7474
......
7878
7979
8080
81
81
8282
8383
84
85
86
8487
88
8589
86
90
8791
8892
8993
90
94
9195
96
97
9298
9399
94100
95101
96102
97
103
98104
99105
100106
101107
102108
103109
110
104111
105112
106113
......
117124
118125
119126
120
127
121128
122129
123
124
125
130
131
132
126133
127134
128135
......
153160
154161
155162
163
156164
157165
158166
#
SYMBOLS_MODULE = Symbols.dylib
SYMBOL_START= _symbols_module_start
SYMBOL_ADDR = $(shell printf "%d" 0x`nm -s __DATA __data $(SYMROOT)/boot_embeded.sys | grep " $(SYMBOL_START)$$" | cut -f 1 -d " "`)
DATA_OFFSET = $(shell otool -l $(SYMROOT)/boot_embeded.sys | grep __data -A 4 | grep __DATA -A 3 | tail -n 1 | cut -f 6 -d " ")
DATA_ADDR = $(shell printf "%d" `otool -l $(SYMROOT)/boot_embeded.sys | grep __data -A 4 | grep __DATA -A 3 | head -n 2 | tail -n 1 | cut -f 8 -d " "`)
SYMBOL_ADDR = $(shell printf "%d" 0x`nm -s __DATA __data $(SYMROOT)/boot.sys | grep " $(SYMBOL_START)$$" | cut -f 1 -d " "`)
DATA_OFFSET = $(shell otool -l $(SYMROOT)/boot.sys | grep __data -A 4 | grep __DATA -A 3 | tail -n 1 | cut -f 6 -d " ")
DATA_ADDR = $(shell printf "%d" `otool -l $(SYMROOT)/boot.sys | grep __data -A 4 | grep __DATA -A 3 | head -n 2 | tail -n 1 | cut -f 8 -d " "`)
PATCH_ADDR = $(shell echo ${SYMBOL_ADDR}-${DATA_ADDR}+${DATA_OFFSET} | bc)
boot: embedded.h machOconv $(OBJS) $(LIBDEP)
@echo "\t[LD] boot.sys"
@$(LD) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \
@$(LD) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \
-nostdlib -arch i386 -Wl,-segalign,20 \
-o $(SYMROOT)/boot.sys $(filter %.o,$^) $(LIBS) -lcc_kext
@cp $(SYMROOT)/boot.sys $(SYMROOT)/boot2.sys
@make Symbols.dylib
@${RM} $(SYMROOT)/boot.sys
@echo "\t[LD] boot_embeded.sys"
@echo "\t[LD] boot.sys"
@$(LD) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \
-nostdlib -arch i386 -Wl,-segalign,20 \
-Wl,-sectcreate,__DATA,__Symbols,$(SYMROOT)/Symbols.dylib \
-o $(SYMROOT)/boot_embeded.sys $(filter %.o,$^) $(LIBS) -lcc_kext
-o $(SYMROOT)/boot.sys $(filter %.o,$^) $(LIBS) -lcc_kext
@ld -arch i386 \
-undefined dynamic_lookup \
-dylib -read_only_relocs suppress \
-S -x -Z -dead_strip_dylibs \
-no_uuid \
-final_output Symbols.dylib \
-final_output Symbols \
$(filter %.o,$^) $(LIBS) \
-o $(OBJROOT)/Symbols_LINKER_ONLY.dylib
@make embed_symbols# this is done in a sub process after boot.sys exists so the strings are populated correctly
@${RM} $(SYMROOT)/boot2.sys
@${RM} $(SYMROOT)/${SYMBOLS_MODULE}
embed_symbols: machOconv
@echo ================= Embedding Symbols.dylib =================
@echo "\t[MACHOCONV] boot"
@$(SYMROOT)/machOconv $(SYMROOT)/boot.sys $(SYMROOT)/boot &> /dev/null
@$(SYMROOT)/machOconv $(SYMROOT)/boot2.sys $(SYMROOT)/boot &> /dev/null
@echo ******* Patching at $(PATCH_ADDR) ******
@stat -f%z $(SYMROOT)/boot | perl -ane "print pack('V',@F[0]);" | dd conv=notrunc of=${SYMROOT}/boot_embeded.sys bs=1 count=4 seek=$(PATCH_ADDR) &> /dev/null
@echo "\t[MACHOCONV] boot_embeded"
@$(SYMROOT)/machOconv $(SYMROOT)/boot_embeded.sys $(SYMROOT)/boot
@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
@echo "\t[MACHOCONV] boot"
@$(SYMROOT)/machOconv $(SYMROOT)/boot.sys $(SYMROOT)/boot
prompt.o: vers.h
-final_output Symbols \
-exported_symbols_list ${OBJROOT}/Symbols.save \
${OBJROOT}/Symbols.o \
-macosx_version_min 10.6 \
-o $(SYMROOT)/${SYMBOLS_MODULE}
@##size $(SYMROOT)/${SYMBOLS_MODULE}
branches/meklort/i386/modules/MakeInc.dir
3535
3636
3737
38
38
3939
40
40
4141
42
4243
4344
4445
......
6263
6364
6465
65
66
66
67
68
69
6770
6871
6972
-final_output $(MODULE_NAME) \
-L$(OBJROOT)/ \
-L$(OBJROOT)/../ \
-L$(SYMROOT)/ \
-L$(SYMROOT)/ \
$(OBJROOT)/*.o \
-weak_library $(OBJROOT)/../../boot2/Symbols_LINKER_ONLY.dylib \
-weak_library $(OBJROOT)/../../boot2/Symbols_LINKER_ONLY.dylib \
-weak_library $(SYMROOT)/*.dylib \
-macosx_version_min 10.6 \
-o $(SYMROOT)/$(MODULE_NAME).dylib
@cp -rf include/* ../module_includes/ &> /dev/null || true
-L$(OBJROOT)/../ \
-L$(SYMROOT)/ \
$(OBJROOT)/*.o \
-weak_library $(OBJROOT)/../../boot2/Symbols_LINKER_ONLY.dylib \
-o $(SYMROOT)/$(MODULE_NAME).dylib
-weak_library $(OBJROOT)/../../boot2/Symbols_LINKER_ONLY.dylib \
-macosx_version_min 10.6 \
-o $(SYMROOT)/$(MODULE_NAME).dylib
@cp -rf include/* ../module_includes/ &> /dev/null || true
endif
branches/meklort/i386/modules/Resolution/Resolution.c
99
1010
1111
12
12
1313
1414
void Resolution_start()
{
patchVideoBios();
//patchVideoBios();
}

Archive Download the corresponding diff file

Revision: 710