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 | 2177 | check_relocs(s1, &mo); |
| 2178 | 2178 | ret = check_symbols(s1, &mo); |
| 2179 | 2179 | if (!ret) { |
| 2180 | + int save_output = s1->output_type; | |
| 2181 | + | |
| 2180 | 2182 | collect_sections(s1, &mo, filename); |
| 2181 | 2183 | relocate_syms(s1, s1->symtab, 0); |
| 2182 | 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 | 2186 | - get_segment(&mo, 1)->vmaddr; |
| 2185 | 2187 | if (s1->nb_errors) |
| 2186 | 2188 | goto do_ret; |
| 2189 | + // Macho uses bind/rebase instead of dynsym | |
| 2190 | + s1->output_type = TCC_OUTPUT_EXE; | |
| 2187 | 2191 | relocate_sections(s1); |
| 2192 | + s1->output_type = save_output; | |
| 2188 | 2193 | #ifdef CONFIG_NEW_MACHO |
| 2189 | 2194 | bind_rebase_import(s1, &mo); |
| 2190 | 2195 | #endif |