Macho uses bind/rebase instead of dynsym so disable them for relocate_sections.
Unified · Split
| @@ -2177,6 +2177,8 @@ ST_FUNC int macho_output_file(TCCState *s1, const char *filename) · 2176 unmodified lines | |||
| 2177 | check_relocs(s1, &mo); | 2177 | check_relocs(s1, &mo); |
| 2178 | ret = check_symbols(s1, &mo); | 2178 | ret = check_symbols(s1, &mo); |
| 2179 | if (!ret) { | 2179 | if (!ret) { |
| 2180 | int save_output = s1->output_type; | ||
| 2181 | |||
| 2180 | collect_sections(s1, &mo, filename); | 2182 | collect_sections(s1, &mo, filename); |
| 2181 | relocate_syms(s1, s1->symtab, 0); | 2183 | relocate_syms(s1, s1->symtab, 0); |
| 2182 | if (s1->output_type == TCC_OUTPUT_EXE) | 2184 | if (s1->output_type == TCC_OUTPUT_EXE) |
| @@ -2184,7 +2186,10 @@ ST_FUNC int macho_output_file(TCCState *s1, const char *filename) · 1 unmodified line | |||
| 2184 | - get_segment(&mo, 1)->vmaddr; | 2186 | - get_segment(&mo, 1)->vmaddr; |
| 2185 | if (s1->nb_errors) | 2187 | if (s1->nb_errors) |
| 2186 | goto do_ret; | 2188 | goto do_ret; |
| 2189 | // Macho uses bind/rebase instead of dynsym | ||
| 2190 | s1->output_type = TCC_OUTPUT_EXE; | ||
| 2187 | relocate_sections(s1); | 2191 | relocate_sections(s1); |
| 2192 | s1->output_type = save_output; | ||
| 2188 | #ifdef CONFIG_NEW_MACHO | 2193 | #ifdef CONFIG_NEW_MACHO |
| 2189 | bind_rebase_import(s1, &mo); | 2194 | bind_rebase_import(s1, &mo); |
| 2190 | #endif | 2195 | #endif |