macos: set LC_MAIN entrypoint correctly
to the file offset of 'main' not simply to the start of TEXT.
This commit is contained in:
		
							parent
							
								
									84c3fecf5e
								
							
						
					
					
						commit
						1ca209dad0
					
				
					 1 changed files with 2 additions and 1 deletions
				
			
		| 
						 | 
					@ -558,7 +558,7 @@ static void collect_sections(TCCState *s1, struct macho *mo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mo->ep.cmd = LC_MAIN;
 | 
					    mo->ep.cmd = LC_MAIN;
 | 
				
			||||||
    mo->ep.cmdsize = sizeof(mo->ep);
 | 
					    mo->ep.cmdsize = sizeof(mo->ep);
 | 
				
			||||||
    mo->ep.entryoff = 4096; // XXX
 | 
					    mo->ep.entryoff = 4096;
 | 
				
			||||||
    mo->ep.stacksize = 0;
 | 
					    mo->ep.stacksize = 0;
 | 
				
			||||||
    add_lc(mo, &mo->ep);
 | 
					    add_lc(mo, &mo->ep);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -810,6 +810,7 @@ ST_FUNC int macho_output_file(TCCState *s1, const char *filename)
 | 
				
			||||||
        Section *s;
 | 
					        Section *s;
 | 
				
			||||||
        collect_sections(s1, &mo);
 | 
					        collect_sections(s1, &mo);
 | 
				
			||||||
        relocate_syms(s1, s1->symtab, 0);
 | 
					        relocate_syms(s1, s1->symtab, 0);
 | 
				
			||||||
 | 
					        mo.ep.entryoff = get_elf_sym_addr(s1, "main", 1) - mo.seg[1]->vmaddr;
 | 
				
			||||||
        if (s1->nb_errors)
 | 
					        if (s1->nb_errors)
 | 
				
			||||||
          goto do_ret;
 | 
					          goto do_ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue