def instantiate(path): elf=PyELF.elf(path) if elf.typ==PyELF.elf.relocatable: return elfo(elf) if elf.typ==PyELF.elf.executable: return elfx(elf) raise TypeError("Unrecognized ELF file type: %s" % elf.typ)
def __init__(self, opts, debug=False): self.options = opts self.debug = debug or self.options.debug self.objfile = self.options.objfile[0] self.ldsfile = self.options.lds # Values set by input analysis self.area = None # Area into which ELF or TEXT is to be loaded self.processor = None # Processor and supplement of ELF self.ldsctl = None # lds instance defining how to structure script # Process the ELF self.elf = PyELF.elf(PyELF.elf_source(filename=self.objfile)) if self.debug: self.elf.prt(details=True) self.ipl_elf=iplelf(\ loader=self.isSection(".loader"),\ proc=self.identifyProcessor(),\ ipl=self.iplsection()) print("ipldpp.py: IPL ELF object: %s" % self.objfile) print("ipldpp.py: %s" % self.ipl_elf) try: if self.options.addr != None: self.ldaddr = int(self.options.addr, 16) else: self.ldaddr = None except: print("ipldpp.py: invalid addr parameter '%s',"\ " using area start: %06X" \ % self.options.addr,iplelf.areas[self.area].start) self.ldsctl=lds(\ addr=self.ldaddr,\ relo=self.options.relo,\ entry=self.options.entry) print("ipldpp.py: %s" % self.ldsctl)
def __init__(self,opts,debug=False): self.options=opts self.debug=debug or self.options.debug self.objfile=self.options.objfile[0] self.ldsfile=self.options.lds # Values set by input analysis self.area=None # Area into which ELF or TEXT is to be loaded self.processor=None # Processor and supplement of ELF self.ldsctl=None # lds instance defining how to structure script # Process the ELF self.elf=PyELF.elf(PyELF.elf_source(filename=self.objfile)) if self.debug: self.elf.prt(details=True) self.ipl_elf=iplelf(\ loader=self.isSection(".loader"),\ proc=self.identifyProcessor(),\ ipl=self.iplsection()) print("ipldpp.py: IPL ELF object: %s" % self.objfile) print("ipldpp.py: %s" % self.ipl_elf) try: if self.options.addr!=None: self.ldaddr=int(self.options.addr,16) else: self.ldaddr=None except: print("ipldpp.py: invalid addr parameter '%s',"\ " using area start: %06X" \ % self.options.addr,iplelf.areas[self.area].start) self.ldsctl=lds(\ addr=self.ldaddr,\ relo=self.options.relo,\ entry=self.options.entry) print("ipldpp.py: %s" %self.ldsctl)
def convert(self): e=elfbin(self.filename) e.setmach(b"\x00\x09") print("elfs370.py: Changed ELF executable from s390 to s370: %s" \ % self.filename) e.close() if self.p: elf=PyELF.elf(self.filename) elf.prt() sys.exit(0)
def convert(self): e = elfbin(self.filename) e.setmach(b"\x00\x09") print("elfs370.py: Changed ELF executable from s390 to s370: %s" \ % self.filename) e.close() if self.p: elf = PyELF.elf(self.filename) elf.prt() sys.exit(0)
def __init__(self, options, debug=False): self.opts = options self.debug = self.opts.debug or debug # Set debugging option if self.debug: print("exeinobj.py: debug: cli arguments:") for x in sys.argv: print("exeinobj.py: debug: %s" % x) self.files = self.opts.exefile # List of executables destined for deck self.boot = self.opts.boot # Boot loader file or None self.csect = self.opts.csect[:min(8, len(self.opts.csect))] self.elfs = [] # List of PyIPLELF instances (openelfs method) self.modules = [] # List of modules as strings self.amode = None # Entered modules address mode (modes method) self.rmode = None # Entered modules architecture (modes method) # Set entered object module's desired address mode #if self.opts.amode is None: # self.amode=24 #else: # self.amode=self.opts.amode # Set entered object module's desired residency mode #if self.opts.rmode is None: # self.rmode=24 #else: # self.rmode=self.opts.amode self.seqno = 1 # Running sequence number of deck in 72-80 # Establish the constant, if any, to be used starting in column 72 if self.opts.seq is None: self.sequence = "" else: self.sequence = self.opts.seq[:min(4, len(self.opts.seq))] # Build list of PyIPLELF instances for command executables for f in range(len(self.files)): filename = self.files[f] if self.debug: print("exeinobj.py: debug: ELF %s: %s" % (f + 1, filename)) elf = PyELF.elf(filename) iplelf = PyIPLELF.PyIPLELF(elf, self.debug) # Force entire ELF to be booted for first executable in command line if (f == 0) and (iplelf.elf_itself is None) and (not self.opts.bootseg): iplelf.elfseg() self.elfs.append(iplelf) if self.debug: print("exeinobj.py: debug: %s" % iplelf)
def __init__(self,options,debug=False): self.opts=options self.debug=self.opts.debug or debug # Set debugging option if self.debug: print("exeinobj.py: debug: cli arguments:") for x in sys.argv: print("exeinobj.py: debug: %s" % x) self.files=self.opts.exefile # List of executables destined for deck self.boot=self.opts.boot # Boot loader file or None self.csect=self.opts.csect[:min(8,len(self.opts.csect))] self.elfs=[] # List of PyIPLELF instances (openelfs method) self.modules=[] # List of modules as strings self.amode=None # Entered modules address mode (modes method) self.rmode=None # Entered modules architecture (modes method) # Set entered object module's desired address mode #if self.opts.amode is None: # self.amode=24 #else: # self.amode=self.opts.amode # Set entered object module's desired residency mode #if self.opts.rmode is None: # self.rmode=24 #else: # self.rmode=self.opts.amode self.seqno=1 # Running sequence number of deck in 72-80 # Establish the constant, if any, to be used starting in column 72 if self.opts.seq is None: self.sequence="" else: self.sequence=self.opts.seq[:min(4,len(self.opts.seq))] # Build list of PyIPLELF instances for command executables for f in range(len(self.files)): filename=self.files[f] if self.debug: print("exeinobj.py: debug: ELF %s: %s" % (f+1,filename)) elf=PyELF.elf(filename) iplelf=PyIPLELF.PyIPLELF(elf,self.debug) # Force entire ELF to be booted for first executable in command line if (f==0) and (iplelf.elf_itself is None) and (not self.opts.bootseg): iplelf.elfseg() self.elfs.append(iplelf) if self.debug: print("exeinobj.py: debug: %s" % iplelf)
def create(path): # This staticmethod is required by objutil to create an instance elf=PyELF.elf(path) if elf.header.typ!=PyELF.elf.executable: raise TypeError("ELF must be an executable: %s" % path) return elfx(elf).init()
self.flnm, ) self.close() sys.exit(2) def close(self): self.e.close() def setmach(self, mach): self.e.seek(18) self.e.write(mach) def usage(): print "Usage: elfs370.py executable [print]" if __name__ == "__main__": if len(sys.argv) < 2 or len(sys.argv) > 3: usage() sys.exit(1) filename = sys.argv[1] e = elfbin(filename) e.setmach("\x00\x09") print "elfs370.py: Changed ELF executable from s390 to s370: %s" % sys.argv[1] e.close() if len(sys.argv) == 3 and sys.argv[2] == "print": elf = PyELF.elf(filename) elf.prt() sys.exit(0)