comparison lwasm/output.c @ 393:c94436adce83

Actually include local symbols in object files
author lost@l-w.ca
date Thu, 22 Jul 2010 23:11:04 -0600
parents a741d2e4869f
children 35a0b086bf4a
comparison
equal deleted inserted replaced
392:e3567a9f0d54 393:c94436adce83
434 writebytes(s -> name, strlen(s -> name) + 1, 1, of); 434 writebytes(s -> name, strlen(s -> name) + 1, 1, of);
435 // address 0; "\0" is not an error 435 // address 0; "\0" is not an error
436 writebytes("\0", 2, 1, of); 436 writebytes("\0", 2, 1, of);
437 for (se = as -> symtab.head; se; se = se -> next) 437 for (se = as -> symtab.head; se; se = se -> next)
438 { 438 {
439 lw_expr_t te;
440
441 debug_message(as, 200, "Consider symbol %s (%p) for export in section %p", se -> symbol, se -> section, s);
442
439 // ignore symbols not in this section 443 // ignore symbols not in this section
440 if (se -> section != s) 444 if (se -> section != s)
441 continue; 445 continue;
442 446
447 debug_message(as, 200, " In section");
448
443 if (se -> flags & symbol_flag_set) 449 if (se -> flags & symbol_flag_set)
444 continue; 450 continue;
445 451
452 debug_message(as, 200, " Not symbol_flag_set");
453
454 te = lw_expr_copy(se -> value);
455 debug_message(as, 200, " Value=%s", lw_expr_print(te));
456 as -> exportcheck = 1;
457 as -> csect = s;
458 lwasm_reduce_expr(as, te);
459 as -> exportcheck = 0;
460
461 debug_message(as, 200, " Value2=%s", lw_expr_print(te));
462
446 // don't output non-constant symbols 463 // don't output non-constant symbols
447 if (!lw_expr_istype(se -> value, lw_expr_type_int)) 464 if (!lw_expr_istype(te, lw_expr_type_int))
448 continue; 465 {
466 lw_expr_destroy(te);
467 continue;
468 }
449 469
450 writebytes(se -> symbol, strlen(se -> symbol), 1, of); 470 writebytes(se -> symbol, strlen(se -> symbol), 1, of);
451 if (se -> context >= 0) 471 if (se -> context >= 0)
452 { 472 {
453 writebytes("\x01", 1, 1, of); 473 writebytes("\x01", 1, 1, of);
456 } 476 }
457 // the "" is NOT an error 477 // the "" is NOT an error
458 writebytes("", 1, 1, of); 478 writebytes("", 1, 1, of);
459 479
460 // write the address 480 // write the address
461 buf[0] = (lw_expr_intval(se -> value) >> 8) & 0xff; 481 buf[0] = (lw_expr_intval(te) >> 8) & 0xff;
462 buf[1] = lw_expr_intval(se -> value) & 0xff; 482 buf[1] = lw_expr_intval(te) & 0xff;
463 writebytes(buf, 2, 1, of); 483 writebytes(buf, 2, 1, of);
484 lw_expr_destroy(te);
464 } 485 }
465 // flag end of local symbol table - "" is NOT an error 486 // flag end of local symbol table - "" is NOT an error
466 writebytes("", 1, 1, of); 487 writebytes("", 1, 1, of);
467 488
468 // now the exports -- FIXME 489 // now the exports -- FIXME