Chameleon

Chameleon Commit Details

Date:2011-05-28 23:56:55 (8 years 10 months ago)
Author:Evan Lojewski
Commit:904
Parents: 903
Message:Utils makefile fix. Modified dyldsymboltool to allow for an arbitrary number of objects
Changes:
M/trunk/i386/modules/Makefile
M/trunk/i386/util/Makefile
M/trunk/i386/modules/MakeInc.dir
M/trunk/i386/Makefile
M/trunk/i386/util/dyldsymboltool.c
M/trunk/i386/boot2/Makefile

File differences

trunk/i386/boot2/Makefile
2323
2424
2525
26
26
2727
2828
2929
......
119119
120120
121121
122
122123
124
125
126
123127
124128
125129
126130
127131
132
128133
129134
130135
......
136141
137142
138143
139
144
140145
141146
142147
......
149154
150155
151156
152
157
153158
154159
155160
-fno-builtin -DSAIO_INTERNAL_USER -static $(OMIT_FRAME_POINTER_CFLAG) \
-mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \
-march=pentium4 -msse2 -mfpmath=sse -msoft-float -nostdinc -include $(SRCROOT)/autoconf.h
CPPFLAGS := $(CPPFLAGS) -nostdinc++ -include $(SRCROOT)/autoconf.h
DEFINES=
-final_output Symbols \
-macosx_version_min 10.6 \
-o $(OBJROOT)/Symbols_LINKER_ONLY.dylib
endif
@make embed_symbols# this is done in a sub process after boot.sys exists so the strings are populated correctly
@${RM} $(SYMROOT)/boot2.sys
@##size $(SYMROOT)/boot.sys
@ls -l $(SYMROOT)/boot
exit 1;\
fi)
embed_symbols:
ifeq (${CONFIG_MODULES}, y)
@echo ================= Embedding Symbols.dylib =================
@echo "\t[MACHOCONV] boot"
@$(SYMROOT)/machOconv $(SYMROOT)/boot.sys $(SYMROOT)/boot
$(SYMROOT)/vers.h:
@echo "#define I386BOOT_VERSION \"5.0.132\"" > $(SYMROOT)/vers.h
@echo "#define I386BOOT_BUILDDATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $(SYMROOT)/vers.h
trunk/i386/modules/MakeInc.dir
1010
1111
1212
13
13
1414
1515
1616
......
5454
5555
5656
57
57
58
5859
60
5961
6062
6163
62
63
6464
6565
6666
......
8282
8383
8484
85
85
8686
8787
8888
......
9797
9898
9999
100
101100
102
101
102
103
104
105
106
107
108
103109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
104125
105126
106127
......
109130
110131
111132
112
113
114
115
116
117
133
134
135
118136
119
137
120138
121139
122140
141
123142
124143
125144
ifeq ($(BUILT_IN),yes)
override OBJROOT = $(SRCROOT)/obj/i386/boot2_modules/$(DIR)
override SYMROOT = $(SRCROOT)/sym/i386/
override SYMROOT = $(SRCROOT)/obj/i386/
endif
include ${SRCROOT}/Make.rules
INC = -I$(SRCROOT)/i386/modules/include/ -Iinclude/ -I$(SRCROOT)/i386/modules/module_includes/ -I$(SRCROOT)/i386/libsaio/ -I$(SRCROOT)/i386/libsa/ -I$(SRCROOT)/i386/include/ -I$(SRCROOT)/i386/boot2/
DEFINES := -D__KLIBC__ $(DEFINES)
MODULE_DEPENDENCIES := $(foreach x,$(MODULE_DEPENDENCIES),-weak_library $(SYMROOT)/modules/$(x).dylib)
MODULE_DEPENDENCIES := $(wildcard $(foreach x,$(MODULE_DEPENDENCIES),$(SYMROOT)/modules/$(x).dylib)) \
$(wildcard $(foreach x,$(MODULE_DEPENDENCIES),$(OBJROOT)/../$(x).dylib))
MODULE_DEPENDENCIES_CMD := $(foreach x,$(MODULE_DEPENDENCIES), -weak_library $(x))
INSTALLDIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/standalone
##$(error DEFINED AS $(MODULE_DEFINITION))
MODULE_DEFINITION := $(CONFIG_$(shell echo $(MODULE_NAME) | tr '[:lower:]' '[:upper:]')_MODULE)
ifeq ($(BUILT_IN),yes)
# Make this *BUILT IN*
all: ${OBJROOT} ${SYMROOT}/modules/ ${OBJROOT} $(addprefix $(OBJROOT)/, ${MODULE_OBJS}) $(SYMROOT)/boot_modules.h $(SYMROOT)/boot_modules.c
all: dylib_LINKER
else
# Module not selected to be built in
endif
endif
dylib: ${SYMROOT}/modules/ ${OBJROOT} $(addprefix $(OBJROOT)/, ${MODULE_OBJS}) $(SYMROOT)/modules/$(MODULE_NAME).dylib
$(SYMROOT)/modules/$(MODULE_NAME).dylib:
dylib_LINKER: $(SYMROOT)/boot_modules.h $(SYMROOT)/boot_modules.c dylib
dylib: ${SYMROOT}/modules/ ${OBJROOT} $(SYMROOT)/modules/$(MODULE_NAME).dylib
ifeq ($(BUILT_IN),yes)
$(SYMROOT)/modules/$(MODULE_NAME).dylib: $(addprefix $(OBJROOT)/, ${MODULE_OBJS}) $(MODULE_DEPENDENCIES)
@echo "\t[LD] $(MODULE_NAME).dylib"
@ld -arch i386 -undefined dynamic_lookup \
-dylib -read_only_relocs suppress \
-S -x -Z -dead_strip_dylibs \
-no_uuid \
-current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \
-final_output $(MODULE_NAME) \
$(filter %.o,$^) \
-macosx_version_min 10.6 \
-o $(SYMROOT)/modules/$(MODULE_NAME).dylib
else
$(SYMROOT)/modules/$(MODULE_NAME).dylib: $(addprefix $(OBJROOT)/, ${MODULE_OBJS}) $(MODULE_DEPENDENCIES) $(SRCROOT)/obj/i386/boot2/Symbols_LINKER_ONLY.dylib
@echo "\t[LD] $(MODULE_NAME).dylib"
@ld -arch i386 \
-alias _$(MODULE_START) start \
-no_uuid \
-current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \
-final_output $(MODULE_NAME) \
-L$(OBJROOT)/ \
-L$(OBJROOT)/../ \
-L$(SYMROOT)/ \
$(OBJROOT)/*.o \
-weak_library $(OBJROOT)/../../boot2/Symbols_LINKER_ONLY.dylib \
$(MODULE_DEPENDENCIES) \
$(filter %.o,$^) \
-weak_library $(SRCROOT)/obj/i386/boot2/Symbols_LINKER_ONLY.dylib \
$(MODULE_DEPENDENCIES_CMD) \
-macosx_version_min 10.6 \
-o $(SYMROOT)/modules/$(MODULE_NAME).dylib
-o $@
@cp -rf include/* ../module_includes/ &> /dev/null || true
endif
clean:
@echo "\t[RM] $(SYMROOT)/modules/$(MODULE_NAME).dylib"
trunk/i386/modules/Makefile
5656
5757
5858
59
60
59
6160
6261
6362
objroot_dirs:
@rm -rf module_includes
@mkdir module_includes
@rm -rf "$(SYMROOT)/modules/"
@mkdir "$(SYMROOT)/modules/"
@${MKDIRS} "$(SYMROOT)/modules/"
$(SYMROOT)/boot_modules.c: ${OBJROOT} ${SYMROOT}/modules/ ${OBJROOT} $(addprefix $(OBJROOT)/, ${MODULE_OBJS})
trunk/i386/Makefile
1515
1616
1717
18
18
19
1920
2021
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
2240
2341
2442
include ${SRCROOT}/Make.rules
# The order of building is important.
SUBDIRS = util libsa libsaio boot0 boot1 boot2 cdboot modules
SUBDIRS_PRE = util
SUBDIRS = libsa libsaio boot0 boot1 boot2 cdboot modules
all:
@cd modules; ${MAKE} BUILT_IN=yes all
@for i in ${SUBDIRS_PRE}; \
do \
echo ================= make $@ for $$i =================; \
( cd $$i; ${MAKE} \
"OBJROOT=$(OBJROOT)/$$i" \
"SYMROOT=$(SYMROOT)" \
"DSTROOT=$(DSTROOT)" \
"SRCROOT=$(SRCROOT)" \
"RC_ARCHS=$(RC_ARCHS)" \
"RC_KANJI=$(RC_KANJI)" \
"JAPANESE=$(JAPANESE)" \
"RC_CFLAGS=$(RC_CFLAGS)" $@ \
) || exit $$?; \
done
@cd modules; ${MAKE} BUILT_IN=yes $@
@for i in ${SUBDIRS}; \
do \
echo ================= make $@ for $$i =================; \
trunk/i386/util/dyldsymboltool.c
4545
4646
4747
48
48
4949
50
50
5151
5252
5353
5454
5555
56
57
58
5956
6057
6158
......
6562
6663
6764
65
66
67
68
69
70
6871
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
69105
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94106
95107
96108
97
109
110
98111
112
113
114
115
99116
100
101
102
103117
104118
105119
......
135149
136150
137151
138
152
139153
140154
141155
int main(int argc, char *argv[])
{
if(argc != 3)
if(argc < 3)
{
fprintf(stderr, "usage: dyldsymboltool bootFile loadAddr outfile\n");
fprintf(stderr, "usage: dyldsymboltool obj1 [obj2 ...] outfile\n");
exit(-1);
}
char line[256];
char* command = malloc(strlen(argv[1]) + sizeof("nm -g "));
FILE *fpipe;
symbols_dylib_t dylib;
symbolList_t*symbols = NULL;
int i;
for(i = 1; i < argc-1; i++)
{
char line[256];
char* command = malloc(strlen(argv[1]) + sizeof("nm -g "));
FILE *fpipe;
// Parse boot.sys (arg1) to get symtab
sprintf(command, "nm -g %s", argv[i]);// TODO: read boot.sym directly, no need for nm
if ( !(fpipe = (FILE*)popen(command,"r")) )
{ // If fpipe is NULL
perror("Problems with pipe");
exit(1);
}
while ( fgets( line, sizeof line, fpipe))
{
if((strlen(line) < strlen(argv[i]) ||
strncmp(line, argv[i], strlen(argv[i])) != 0)
&& line[0] != ' ')
{
uint32_t address = 0;
char* addr = strtok(line, " ");
strtok(NULL, " ");
char* name = strtok(NULL, " ");
name[strlen(name)-1] = 0;// remove newline
sscanf(addr, "%x", &address);
if(strcmp(name, VOID_SYMBOL) == 0) start_addr = address;
add_symbol(&symbols, name, address);
}
}
pclose(fpipe);
free(command);
}
// Parse boot.sys (arg1) to get symtab
sprintf(command, "nm -g %s", argv[1]);// TODO: read boot.sym directly, no need for nm
if ( !(fpipe = (FILE*)popen(command,"r")) )
{ // If fpipe is NULL
perror("Problems with pipe");
exit(1);
}
while ( fgets( line, sizeof line, fpipe))
{
uint32_t address = 0;
char* addr = strtok(line, " ");
strtok(NULL, " ");
char* name = strtok(NULL, " ");
name[strlen(name)-1] = 0;// remove newline
sscanf(addr, "%x", &address);
if(strcmp(name, VOID_SYMBOL) == 0) start_addr = address;
add_symbol(&symbols, name, address);
}
pclose(fpipe);
if(start_addr == 0)
{
fprintf(stderr, "Unable to locate Symbol.dylib start function\n");
exit(1);
//exit(1);
}
else
{
add_symbol(&symbols, START_SYMBOL, start_addr);
}
add_symbol(&symbols, START_SYMBOL, start_addr);
/* Header command info */
dylib.header.ncmds = 2;
dylib.header.sizeofcmds = sizeof(dylib) - sizeof(struct mach_header);// + dylib.symtab.nsyms * sizeof(struct nlist) + dylib.symtab.strsize;
FILE* outfile = fopen(argv[2], "w");
FILE* outfile = fopen(argv[argc-1], "w");
fwrite(&dylib,sizeof(dylib)/* Sizeof header + module name */
, 1, outfile);
trunk/i386/util/Makefile
44
55
66
7
7
88
99
1010
# and install them directly, rather than generating them again.
#
SRCROOT = $(shell pwd)/../../
OBJROOT = $(SRCROOT)/obj/i386
OBJROOT = $(SRCROOT)/obj/i386/util
SYMROOT = $(SRCROOT)/sym/i386
DSTROOT = $(SRCROOT)/dst/i386
DOCROOT = $(SRCROOT)/doc

Archive Download the corresponding diff file

Revision: 904