comparison lwasm/output.c @ 156:fc8386b13399

Added 'constant' sections to object file handling for lwasm and lwlink
author lost@l-w.ca
date Sun, 28 Aug 2011 02:06:42 -0600
parents d92b9c968731
children 17bd59f045af
comparison
equal deleted inserted replaced
155:1571e150f1fd 156:fc8386b13399
425 writebytes(s -> name, strlen(s -> name) + 1, 1, of); 425 writebytes(s -> name, strlen(s -> name) + 1, 1, of);
426 426
427 // write the flags 427 // write the flags
428 if (s -> flags & section_flag_bss) 428 if (s -> flags & section_flag_bss)
429 writebytes("\x01", 1, 1, of); 429 writebytes("\x01", 1, 1, of);
430 430 if (s -> flags & section_flag_constant)
431 writebytes("\x02", 1, 1, of);
432
431 // indicate end of flags - the "" is NOT an error 433 // indicate end of flags - the "" is NOT an error
432 writebytes("", 1, 1, of); 434 writebytes("", 1, 1, of);
433 435
434 // now the local symbols 436 // now the local symbols
435 437
436 // a symbol for section base address 438 // a symbol for section base address
437 writebytes("\x02", 1, 1, of); 439 if ((s -> flags & section_flag_constant) == 0)
438 writebytes(s -> name, strlen(s -> name) + 1, 1, of); 440 {
439 // address 0; "\0" is not an error 441 writebytes("\x02", 1, 1, of);
440 writebytes("\0", 2, 1, of); 442 writebytes(s -> name, strlen(s -> name) + 1, 1, of);
443 // address 0; "\0" is not an error
444 writebytes("\0", 2, 1, of);
445 }
441 for (se = as -> symtab.head; se; se = se -> next) 446 for (se = as -> symtab.head; se; se = se -> next)
442 { 447 {
443 lw_expr_t te; 448 lw_expr_t te;
444 449
445 debug_message(as, 200, "Consider symbol %s (%p) for export in section %p", se -> symbol, se -> section, s); 450 debug_message(as, 200, "Consider symbol %s (%p) for export in section %p", se -> symbol, se -> section, s);
580 writebytes("", 1, 1, of); 585 writebytes("", 1, 1, of);
581 586
582 // now blast out the code 587 // now blast out the code
583 588
584 // length 589 // length
585 buf[0] = s -> oblen >> 8 & 0xff; 590 if (s -> flags & section_flag_constant)
586 buf[1] = s -> oblen & 0xff; 591 {
592 buf[0] = 0;
593 buf[1] = 0;
594 }
595 else
596 {
597 buf[0] = s -> oblen >> 8 & 0xff;
598 buf[1] = s -> oblen & 0xff;
599 }
587 writebytes(buf, 2, 1, of); 600 writebytes(buf, 2, 1, of);
588 601
589 if (!(s -> flags & section_flag_bss)) 602
603 if (!(s -> flags & section_flag_bss) && !(s -> flags & section_flag_constant))
590 { 604 {
591 writebytes(s -> obytes, s -> oblen, 1, of); 605 writebytes(s -> obytes, s -> oblen, 1, of);
592 } 606 }
593 } 607 }
594 608