History

Add option -e for setting ELF file's entry

Ziyao committed 4 years ago

Commit 39ea3401 parent 03669243 files · +12 −2Browse files

Unified · Split

3 files
  1. libtcc.c +2 −0
  2. tcc.h +2 −0
  3. tccelf.c +8 −2
libtcc.c+2−0
@@ -1335,6 +1335,8 @@ static int tcc_set_linker(TCCState *s, const char *option) · 1334 unmodified lines
1335 s->symbolic = 1;1335 s->symbolic = 1;
1336 } else if (link_option(option, "nostdlib", &p)) {1336 } else if (link_option(option, "nostdlib", &p)) {
1337 s->nostdlib = 1;1337 s->nostdlib = 1;
1338 } else if (link_option(option, "e=", &p)) {
1339 copy_linker_arg(&s->elf_entryname, p, 0);
1338 } else if (link_option(option, "fini=", &p)) {1340 } else if (link_option(option, "fini=", &p)) {
1339 copy_linker_arg(&s->fini_symbol, p, 0);1341 copy_linker_arg(&s->fini_symbol, p, 0);
1340 ignoring = 1;1342 ignoring = 1;
tcc.h+2−0
@@ -961,6 +961,8 @@ struct TCCState { · 960 unmodified lines
961 Section *verneed_section;961 Section *verneed_section;
962#endif962#endif
963 963
964 char *elf_entryname;
965
964#ifdef TCC_IS_NATIVE966#ifdef TCC_IS_NATIVE
965 const char *runtime_main;967 const char *runtime_main;
966 void **runtime_mem;968 void **runtime_mem;
tccelf.c+8−2
@@ -2322,11 +2322,17 @@ static void tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr, · 2321 unmodified lines
2322 default:2322 default:
2323 case TCC_OUTPUT_EXE:2323 case TCC_OUTPUT_EXE:
2324 ehdr.e_type = ET_EXEC;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 break;2329 break;
2327 case TCC_OUTPUT_DLL:2330 case TCC_OUTPUT_DLL:
2328 ehdr.e_type = ET_DYN;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 break;2336 break;
2331 case TCC_OUTPUT_OBJ:2337 case TCC_OUTPUT_OBJ:
2332 ehdr.e_type = ET_REL;2338 ehdr.e_type = ET_REL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t