Rev 9615 | Rev 9619 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9615 | Rev 9617 | ||
---|---|---|---|
Line 17... | Line 17... | ||
17 | * You should have received a copy of the GNU Lesser General Public |
17 | * You should have received a copy of the GNU Lesser General Public |
18 | * License along with this library; if not, write to the Free Software |
18 | * License along with this library; if not, write to the Free Software |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ |
20 | */ |
Line -... | Line 21... | ||
- | 21 | ||
- | 22 | #include "tcc.h" |
|
21 | 23 | ||
22 | typedef struct { |
24 | typedef struct { |
23 | char magic[8]; |
25 | char magic[8]; |
24 | int version; |
26 | int version; |
25 | int entry_point; |
27 | int entry_point; |
Line 240... | Line 242... | ||
240 | { |
242 | { |
241 | const char *sym_name = strtab_section->data + st_name; |
243 | const char *sym_name = strtab_section->data + st_name; |
242 | return sym_name; |
244 | return sym_name; |
243 | } |
245 | } |
Line 244... | Line 246... | ||
244 | 246 | ||
245 | int tcc_find_symbol_me(me_info* me, const char *sym_name) |
247 | int tcc_find_symbol_me(me_info* me, const char *sym_name, int* addr) |
246 | { |
- | |
247 | int i; |
- | |
248 | int symtab; |
248 | { |
249 | int strtab; |
- | |
250 | symtab=0; |
249 | int i, symtab = 0, strtab = 0; |
251 | strtab=0; |
250 | *addr = 0; |
252 | for (i=1;i |
251 | for (i=1;i |
253 | { |
252 | { |
254 | Section* s; |
253 | Section* s; |
255 | s=me->s1->sections[i]; |
254 | s=me->s1->sections[i]; |
Line 274... | Line 273... | ||
274 | name=(char*)me->s1->sections[strtab]->data; |
273 | name=(char*)me->s1->sections[strtab]->data; |
275 | while (s |
274 | while (s |
276 | { |
275 | { |
277 | if (strcmp(name+s->st_name,sym_name)==0) |
276 | if (strcmp(name+s->st_name,sym_name)==0) |
278 | { |
277 | { |
279 | return s->st_value+findsection(me,s->st_shndx)->sh_addr; |
278 | *addr = s->st_value+findsection(me,s->st_shndx)->sh_addr; |
- | 279 | return 1; |
|
280 | } |
280 | } |
281 | s++; |
281 | s++; |
282 | } |
282 | } |
283 | tcc_error_noabort("undefined symbol '%s'", sym_name); |
283 | tcc_error_noabort("undefined symbol '%s'", sym_name); |
284 | return 0; |
284 | return 0; |
Line 301... | Line 301... | ||
301 | assign_addresses(&me); |
301 | assign_addresses(&me); |
Line 302... | Line 302... | ||
302 | 302 | ||
303 | if (s1->do_debug) |
303 | if (s1->do_debug) |
Line 304... | Line 304... | ||
304 | tcc_output_dbgme(filename, &me); |
304 | tcc_output_dbgme(filename, &me); |
305 | 305 | ||
306 | me.header.entry_point=tcc_find_symbol_me(&me,"start"); |
306 | if (!tcc_find_symbol_me(&me, "start", &me.header.entry_point) | |
307 | me.header.params= tcc_find_symbol_me(&me,"__argv"); // <-- |
- | |
308 | me.header.argv= tcc_find_symbol_me(&me,"__path"); // <-- |
- | |
309 | 307 | !tcc_find_symbol_me(&me, "__argv", &me.header.params) | |
|
310 | if (!me.header.entry_point || !me.header.params || me.header.argv) { |
308 | !tcc_find_symbol_me(&me, "__path", &me.header.argv)) { |
Line 311... | Line 309... | ||
311 | exit(1); |
309 | exit(1); |
312 | } |
310 | } |
Line 482... | Line 480... | ||
482 | if (stab->n_strx) |
480 | if (stab->n_strx) |
483 | { |
481 | { |
484 | strcpy(cur_fun, stabstr_section->data + stab->n_strx); |
482 | strcpy(cur_fun, stabstr_section->data + stab->n_strx); |
485 | str = strchr(cur_fun, ':'); |
483 | str = strchr(cur_fun, ':'); |
486 | if (str) *str = '\0'; |
484 | if (str) *str = '\0'; |
487 | cur_fun_addr = tcc_find_symbol_me(me, cur_fun); |
485 | tcc_find_symbol_me(me, cur_fun, &cur_fun_addr); |
488 | cur_line = stab->n_desc; |
486 | cur_line = stab->n_desc; |
489 | fun_flag = 1; |
487 | fun_flag = 1; |
490 | //fprintf(fdbg, "0x%X %s() line(%d)\n", cur_fun_addr, cur_fun, cur_line); // commented as conflicted with direct address |
488 | //fprintf(fdbg, "0x%X %s() line(%d)\n", cur_fun_addr, cur_fun, cur_line); // commented as conflicted with direct address |
491 | } |
489 | } |
492 | else |
490 | else |