name = retrieveStr(strTab, sh.get('name_index')) body = byteList[sh.get('offset'):sh.get('offset')+sh.get('size')] secAggr.append(Section(body, name, sh)) # restruct phase segMake = SegmentMaker() segMake.make(secAggr) headerSize = 0x40 + 56 * len(segMake.getSegmentList()) newBody = secAggr.makeBody(headerSize) segMake.makePh(secAggr) segMake.setOffset(secAggr) ''' segMake.setOffset() segMake.setSize() segMake.setAddr(0x400000) # make shstrtbl endOfBody = segMake.resetSection() # remake ELF header eh.set('entry_addr', segMake.getEntryAddr()) eh.set('ph_offset', 0x40) eh.set('sh_offset', endOfBody) eh.set('ph_num', segMake.getCount())
continue shStart = shOff + shSize * idx sh = Sh() sh.retrieve(byteList[shStart:shStart+shSize]) name = retrieveStr(strTab, sh.get('name_index')) body = byteList[sh.get('offset'):sh.get('offset')+sh.get('size')] secAggr.append(Section(body, name, sh)) # restruct phase segMake = SegmentMaker(secAggr) segMake.make() segMake.setOffset() segMake.setSize() segMake.setAddr(0x400000) # make shstrtbl endOfBody = segMake.resetSection() # remake ELF header eh.set('entry_addr', segMake.getEntryAddr()) eh.set('ph_offset', 0x40) eh.set('sh_offset', endOfBody) eh.set('ph_num', segMake.getCount()) eh.set('sh_num', secAggr.count()+1) # plus null section eh.set('shstrndx', secAggr.find('.shstrtab')+1) # plus null section # make output byte list