Chameleon

Chameleon Commit Details

Date:2010-11-18 04:55:38 (8 years 10 months ago)
Author:Evan Lojewski
Commit:639
Parents: 638
Message:Updated embedding code, bss segment nolonger overlaps Symbols module. Symbols module can now be loaded correctly
Changes:
M/branches/meklort/i386/boot2/modules.c
M/branches/meklort/i386/boot2/Makefile

File differences

branches/meklort/i386/boot2/modules.c
11
22
33
4
45
56
67
......
910
1011
1112
12
13
1314
1415
1516
......
5556
5657
5758
59
60
5861
5962
6063
6164
65
6266
67
68
6369
64
65
70
71
72
73
74
75
6676
67
68
6977
7078
7179
7280
7381
7482
75
7683
77
84
85
86
87
88
7889
79
80
81
8290
8391
8492
/*
* Copyright 2010 Evan Lojewski. All rights reserved.
*
* TODO: Zero out bss if needed
*/
#include "boot.h"
#include "modules.h"
#ifndef DEBUG_MODULES
#define DEBUG_MODULES 0
#define DEBUG_MODULES 1
#endif
#if DEBUG_MODULES
*/
int init_module_system()
{
void (*module_start)(void) = NULL;
char* module_data = symbols_module_start + BOOT2_ADDR;
// Intialize module system
if(symbols_module_start == (void*)0xFFFFFFFF)
{
printf("Module system not compiled in\n");
return 0;
}
module_start = parse_mach(module_data, &load_module, &add_symbol);
// TODO: Load embeded module
/*
if(module_start && module_start != (void*)0xFFFFFFFF)
{
// Notify the system that it was laoded
module_loaded(SYMBOLS_MODULE /*moduleName, moduleVersion, moduleCompat*/);
(*module_start)();// Start the module
DBG("Module %s Loaded.\n", SYMBOLS_MODULE);
if(load_module(SYMBOLS_MODULE))
{
lookup_symbol = (void*)lookup_all_symbols(SYMBOL_LOOKUP_SYMBOL);
if((UInt32)lookup_symbol != 0xFFFFFFFF)
{
return 1;
}
}
else {
// The module does not have a valid start function
printf("Unable to start %s\n", SYMBOLS_MODULE);
getc();
}
return 0;
*/
return -1;
}
branches/meklort/i386/boot2/Makefile
6060
6161
6262
63
64
65
63
64
65
6666
6767
6868
......
7070
7171
7272
73
73
7474
7575
7676
77
77
78
79
80
81
82
83
7884
7985
86
87
8088
8189
8290
......
8795
8896
8997
90
98
9199
92100
93
94101
95
96
97
98
102
103
99104
105
100106
107
101108
102109
103110
#
SYMBOLS_MODULE = Symbols.dylib
SYMBOL_START= _symbols_module_start
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 " "`)
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 " "`)
PATCH_ADDR = $(shell echo ${SYMBOL_ADDR}-${DATA_ADDR}+${DATA_OFFSET} | bc)
all embedtheme optionrom: $(DIRS_NEEDED) boot
boot: embedded.h $(OBJS) $(LIBDEP)
boot: embedded.h machOconv $(OBJS) $(LIBDEP)
$(LD) -static -Wl,-preload -Wl,-segaddr,__INIT,$(BOOT2ADDR) \
-nostdlib -arch i386 -Wl,-segalign,20 \
-o $(SYMROOT)/boot.sys $(filter %.o,$^) $(LIBS) -lcc_kext
@make Symbols.dylib
$(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
@make embed_symbols# this is done in a sub process after boot.sys exists so the strings are populated correctly
${RM} $(SYMROOT)/${SYMBOLS_MODULE}
size $(SYMROOT)/boot.sys
ls -l $(SYMROOT)/boot
@( size=`ls -l $(SYMROOT)/boot | awk '{ print $$5}'` ; \
exit 1;\
fi)
embed_symbols: machOconv Symbols.dylib
embed_symbols: machOconv
@echo ================= Embedding Symbols.dylib =================
machOconv $(SYMROOT)/boot.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)
machOconv $(SYMROOT)/boot.sys $(SYMROOT)/boot
dd if=${SYMROOT}/${SYMBOLS_MODULE} of=${SYMROOT}/boot bs=1 seek=`stat -f%z $(SYMROOT)/boot`
${RM} $(SYMROOT)/${SYMBOLS_MODULE}
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)
machOconv $(SYMROOT)/boot_embeded.sys $(SYMROOT)/boot
prompt.o: vers.h
vers.h:
@echo "#define I386BOOT_VERSION \"5.0.132\"" > $(SYMROOT)/vers.h

Archive Download the corresponding diff file

Revision: 639