Changeset 171 for soft/giet_vm/memo/src/libelfpp/elfpp_access.cc
- Timestamp:
- Jul 18, 2012, 9:17:22 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/memo/src/libelfpp/elfpp_access.cc
r163 r171 644 644 segment *s = new segment(obj); 645 645 646 if(!(sec->get_flags() & elfpp::SHF_ALLOC)) 647 { 648 s->set_type(PT_NULL); 649 continue; 650 } 651 652 s->set_type(PT_LOAD); 653 s->set_file_offset(0);//done while writing section in file 654 s->set_vaddr(sec->get_vaddr()); 655 s->set_paddr(sec->get_vaddr()); 656 657 s->set_mem_size(sec->get_size()); 658 s->set_file_size(sec->get_size()); 659 660 flag = PF_R ;//ALLOC ==> read ? 661 flag = flag | (p_flags_e)(sec->get_flags() & SHF_WRITE)? PF_W : PF_R ; 662 flag = flag | (p_flags_e)(sec->get_flags() & SHF_EXECINSTR)? PF_X : PF_R ; 663 s->set_flags(flag); 664 s->set_align(0);//FIXME! 665 666 obj.add_segment(*s); 646 if(!(sec->get_flags() & elfpp::SHF_ALLOC)) 647 { 648 s->set_type(PT_NULL); 649 continue; 650 } 651 652 s->set_type(PT_LOAD); 653 s->set_file_offset(0);//done while writing section in file 654 #ifdef MEMO_DEBUG 655 std::cout << "seg building (" << std::hex << sec->get_vaddr() << ") for: " << *sec << std::endl; 656 #endif 657 s->set_vaddr(sec->get_vaddr()); 658 s->set_paddr(sec->get_vaddr()); 659 660 s->set_mem_size(sec->get_size()); 661 s->set_file_size(sec->get_size()); 662 663 flag = PF_R ;//ALLOC ==> read ? 664 flag = flag | (p_flags_e)(sec->get_flags() & SHF_WRITE)? PF_W : PF_R ; 665 flag = flag | (p_flags_e)(sec->get_flags() & SHF_EXECINSTR)? PF_X : PF_R ; 666 s->set_flags(flag); 667 s->set_align(0);//FIXME! 668 669 #ifdef MEMO_DEBUG 670 std::cout <<"New segment " << s->get_file_size() << std::endl; 671 #endif 672 obj.add_segment(*s); 667 673 } 668 674 } … … 675 681 if (obj.generate_symtab_) 676 682 save_symtab(obj); 683 684 // create all segments 677 685 678 686 create_segments(obj); … … 797 805 std::memset(phdr, 0, sizeof(phdr)); 798 806 799 unsigned int i = 0;807 unsigned int i = 1;//to keep the same order as sections 800 808 FOREACH(s, obj.get_segment_table()) 801 809 { … … 812 820 813 821 swap(&phdr[i].p_align, s->get_align()); 814 // offset done while writing sections822 //note: offset done while writing sections 815 823 i++; 816 824 } … … 829 837 FOREACH(s, obj.get_section_table()) 830 838 { 831 if (s->get_type() == SHT_NOBITS) 832 continue; 833 839 if (s->get_type() == SHT_NOBITS) 840 continue; 841 842 #ifdef MEMO_DEBUG 843 std::cout << "offset: " << ftell(file) << " for " << *s << std::endl; 844 std::cout << std::hex << "paddr: " << phdr[s->index_].p_paddr << ", sect vaddr: " << s->get_vaddr() << "/" <<shdr[s->index_].sh_addr << std::endl; 845 #endif 834 846 swap(&shdr[s->index_].sh_offset, ftell(file)); 835 847 swap(&phdr[s->index_].p_offset, ftell(file));
Note: See TracChangeset
for help on using the changeset viewer.