@@ -78,7 +78,7 @@ static void elf_custom_links() {
78
78
ct_fndef_size = collect_fndef_list (ctx );
79
79
ct_fndef_data = fndefs_serialize ();
80
80
elf_put_data (ctx -> data_fndef_section , ct_fndef_data , ct_fndef_size );
81
- sym = (Elf64_Sym ){
81
+ sym = (Elf64_Sym ) {
82
82
.st_shndx = ctx -> data_fndef_section -> sh_index ,
83
83
.st_value = 0 ,
84
84
.st_other = 0 ,
@@ -91,7 +91,7 @@ static void elf_custom_links() {
91
91
// caller - --------------------------------------------------------------------------
92
92
ct_caller_data = callers_serialize ();
93
93
elf_put_data (ctx -> data_caller_section , ct_caller_data , ct_caller_list -> length * sizeof (caller_t ));
94
- sym = (Elf64_Sym ){
94
+ sym = (Elf64_Sym ) {
95
95
.st_shndx = ctx -> data_caller_section -> sh_index ,
96
96
.st_value = 0 ,
97
97
.st_other = 0 ,
@@ -106,7 +106,7 @@ static void elf_custom_links() {
106
106
ct_symdef_size = collect_symdef_list (ctx );
107
107
ct_symdef_data = symdefs_serialize ();
108
108
elf_put_data (ctx -> data_symdef_section , ct_symdef_data , ct_symdef_size );
109
- sym = (Elf64_Sym ){
109
+ sym = (Elf64_Sym ) {
110
110
.st_shndx = ctx -> data_symdef_section -> sh_index ,
111
111
.st_value = 0 ,
112
112
.st_other = 0 ,
@@ -143,11 +143,11 @@ static void mach_custom_links() {
143
143
ct_rtype_data = rtypes_serialize ();
144
144
mach_put_data (ctx -> data_rtype_section , ct_rtype_data , ct_rtype_size );
145
145
// 创建符号指向自定义数据段 __data.rtype
146
- mach_put_sym (ctx -> symtab_command , & (struct nlist_64 ){
147
- .n_type = N_SECT | N_EXT ,
148
- .n_sect = ctx -> data_rtype_section -> sh_index ,
149
- .n_value = 0 , // in section data offset
150
- },
146
+ mach_put_sym (ctx -> symtab_command , & (struct nlist_64 ) {
147
+ .n_type = N_SECT | N_EXT ,
148
+ .n_sect = ctx -> data_rtype_section -> sh_index ,
149
+ .n_value = 0 , // in section data offset
150
+ },
151
151
SYMBOL_RTYPE_DATA );
152
152
153
153
macho_put_global_symbol (ctx , SYMBOL_RTYPE_COUNT , & ct_rtype_count , QWORD );
@@ -157,11 +157,11 @@ static void mach_custom_links() {
157
157
ct_fndef_data = fndefs_serialize ();
158
158
mach_put_data (ctx -> data_fndef_section , ct_fndef_data , ct_fndef_size );
159
159
160
- mach_put_sym (ctx -> symtab_command , & (struct nlist_64 ){
161
- .n_type = N_SECT | N_EXT ,
162
- .n_sect = ctx -> data_fndef_section -> sh_index ,
163
- .n_value = 0 , // in section data offset
164
- },
160
+ mach_put_sym (ctx -> symtab_command , & (struct nlist_64 ) {
161
+ .n_type = N_SECT | N_EXT ,
162
+ .n_sect = ctx -> data_fndef_section -> sh_index ,
163
+ .n_value = 0 , // in section data offset
164
+ },
165
165
SYMBOL_FNDEF_DATA );
166
166
macho_put_global_symbol (ctx , SYMBOL_FNDEF_COUNT , & ct_fndef_count , QWORD );
167
167
@@ -170,11 +170,11 @@ static void mach_custom_links() {
170
170
ct_caller_data = callers_serialize ();
171
171
mach_put_data (ctx -> data_caller_section , ct_caller_data , ct_caller_list -> length * sizeof (caller_t ));
172
172
// 注册段名称与 runtime 中的符号进行绑定
173
- mach_put_sym (ctx -> symtab_command , & (struct nlist_64 ){
174
- .n_type = N_SECT | N_EXT ,
175
- .n_sect = ctx -> data_caller_section -> sh_index ,
176
- .n_value = 0 , // in section data offset
177
- },
173
+ mach_put_sym (ctx -> symtab_command , & (struct nlist_64 ) {
174
+ .n_type = N_SECT | N_EXT ,
175
+ .n_sect = ctx -> data_caller_section -> sh_index ,
176
+ .n_value = 0 , // in section data offset
177
+ },
178
178
SYMBOL_CALLER_DATA );
179
179
macho_put_global_symbol (ctx , SYMBOL_CALLER_COUNT , & ct_caller_list -> length , QWORD );
180
180
@@ -184,11 +184,11 @@ static void mach_custom_links() {
184
184
ct_symdef_data = symdefs_serialize ();
185
185
mach_put_data (ctx -> data_symdef_section , ct_symdef_data , ct_symdef_size );
186
186
187
- mach_put_sym (ctx -> symtab_command , & (struct nlist_64 ){
188
- .n_type = N_SECT | N_EXT ,
189
- .n_sect = ctx -> data_symdef_section -> sh_index ,
190
- .n_value = 0 , // in section data offset
191
- },
187
+ mach_put_sym (ctx -> symtab_command , & (struct nlist_64 ) {
188
+ .n_type = N_SECT | N_EXT ,
189
+ .n_sect = ctx -> data_symdef_section -> sh_index ,
190
+ .n_value = 0 , // in section data offset
191
+ },
192
192
SYMBOL_SYMDEF_DATA );
193
193
macho_put_global_symbol (ctx , SYMBOL_SYMDEF_COUNT , & ct_symdef_count , QWORD );
194
194
@@ -278,11 +278,11 @@ static void mach_assembler_module(module_t *m) {
278
278
uint64_t offset = mach_put_data (ctx -> data_section , symbol -> value , symbol -> size );
279
279
280
280
// 写入符号表
281
- mach_put_sym (ctx -> symtab_command , & (struct nlist_64 ){
282
- .n_type = N_SECT | N_EXT ,
283
- .n_sect = ctx -> data_section -> sh_index ,
284
- .n_value = offset , // in section data offset
285
- },
281
+ mach_put_sym (ctx -> symtab_command , & (struct nlist_64 ) {
282
+ .n_type = N_SECT | N_EXT ,
283
+ .n_sect = ctx -> data_section -> sh_index ,
284
+ .n_value = offset , // in section data offset
285
+ },
286
286
symbol -> name );
287
287
}
288
288
@@ -396,7 +396,7 @@ static int command_exists(const char *cmd) {
396
396
int exists = 0 ;
397
397
398
398
while (dir != NULL ) {
399
- char full_path [1024 ];
399
+ char full_path [8211 ];
400
400
snprintf (full_path , sizeof (full_path ), "%s/%s" , dir , cmd );
401
401
402
402
if (stat (full_path , & st ) == 0 ) {
@@ -649,6 +649,11 @@ static void build_init(char *build_entry) {
649
649
assertf (false, "entry file='%s' not found" , build_entry );
650
650
}
651
651
652
+ // darwin 默认使用 ld 链接
653
+ if (BUILD_OS == OS_DARWIN && strlen (USE_LD ) == 0 ) {
654
+ strcpy (USE_LD , "ld" );
655
+ }
656
+
652
657
// copy
653
658
strcpy (SOURCE_PATH , temp_path );
654
659
assertf (file_exists (SOURCE_PATH ), "full entry file=%s not found" , SOURCE_PATH );
0 commit comments