Unified · Split
| @@ -1335,6 +1335,8 @@ static int tcc_set_linker(TCCState *s, const char *option) · 1334 unmodified lines | ||
| 1335 | 1335 | s->symbolic = 1; |
| 1336 | 1336 | } else if (link_option(option, "nostdlib", &p)) { |
| 1337 | 1337 | s->nostdlib = 1; |
| 1338 | + } else if (link_option(option, "e=", &p)) { | |
| 1339 | + copy_linker_arg(&s->elf_entryname, p, 0); | |
| 1338 | 1340 | } else if (link_option(option, "fini=", &p)) { |
| 1339 | 1341 | copy_linker_arg(&s->fini_symbol, p, 0); |
| 1340 | 1342 | ignoring = 1; |
| @@ -961,6 +961,8 @@ struct TCCState { · 960 unmodified lines | ||
| 961 | 961 | Section *verneed_section; |
| 962 | 962 | #endif |
| 963 | 963 | |
| 964 | + char *elf_entryname; | |
| 965 | + | |
| 964 | 966 | #ifdef TCC_IS_NATIVE |
| 965 | 967 | const char *runtime_main; |
| 966 | 968 | void **runtime_mem; |
| @@ -2322,11 +2322,17 @@ static void tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr, · 2321 unmodified lines | ||
| 2322 | 2322 | default: |
| 2323 | 2323 | case TCC_OUTPUT_EXE: |
| 2324 | 2324 | ehdr.e_type = ET_EXEC; |
| 2325 | − ehdr.e_entry = get_sym_addr(s1, "_start", 1, 0); | |
| 2325 | + ehdr.e_entry = get_sym_addr(s1, | |
| 2326 | + s1->elf_entryname ? | |
| 2327 | + s1->elf_entryname : "_start", | |
| 2328 | + 1, 0); | |
| 2326 | 2329 | break; |
| 2327 | 2330 | case TCC_OUTPUT_DLL: |
| 2328 | 2331 | ehdr.e_type = ET_DYN; |
| 2329 | − ehdr.e_entry = text_section->sh_addr; /* XXX: is it correct ? */ | |
| 2332 | + ehdr.e_entry = s1->elf_entryname ? | |
| 2333 | + get_sym_addr(s1,s1->elf_entryname,1,0) : | |
| 2334 | + text_section->sh_addr; | |
| 2335 | + /* XXX: is it correct ? */ | |
| 2330 | 2336 | break; |
| 2331 | 2337 | case TCC_OUTPUT_OBJ: |
| 2332 | 2338 | ehdr.e_type = ET_REL; |