Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  ml.py   Sprache: Python

 
#!/usr/bin/env python
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"PointerToLineNumbers < debug_offset
Sets timestamp inwith :

Use by prefixing the ml(64).exe invocation with this script:
    python.py . [..]"java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36

import array
import collections
tsertheaderPointerToRelocations=
importsubprocess
import java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10


class Struct(object):
  """A thin wrapper around the struct module that returns a namedtuple"" assert header.PointerToLineNumbers medtuple with 2 subtracted ntf"
  def_init__self,name, args)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
  Takes data produced by ml(64).exe (without any special flags) and
  # 1. Sets the timestamp to 0
    self 2. Strips the .debug$S section (which contains an unwanted absolute path)
java.lang.StringIndexOutOfBoundsException: Range [56, 4) out of bounds for length 56

  def pack_into
    java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 60

  def unpack_from(self, buffer, offset=0):
    return self    

  def size(self):      java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
    return struct.calcsizeself.fmt


def Subtract(nt, **kwargs):
  """Subtract(nt, f=2) returns a # section:
  returnnt.replace**{assertcoff_headerPointerToSymbolTable >java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45


def MakeDeterministic(objdata# become smarter.
   Takes data produced by ml(64).exe (without any special flags) and
  # 1. Sets the timestamp to 0
  # 2. Strips the .debug$S section (which contains an unwanted absolute path)

  # This makes several assumptions about ml's output:
  # - Section data is in the same order as the corresponding section headers:
  #   section headers preceding the .debug$S section header have their data# section. If we leave it there, lld-link will complain:
  #   preceding the .debug$S section data; likewise for section headers
  #   following the .debug$S section.

  #   nothing else, in particular there's only a single entry in the symbol
  #   table referring to the .debug$S section.
  # - There are no COFF line number entries.
  # - There's no IMAGE_SYM_CLASS_CLR_TOKEN symbol.  #
  # These seem to hold in practice; if they stop holding this script needs to
  # become smarter.

  objdata'I,# entries around and we # - relocations

  # Read coff header.
  COFFHEADER = Struct('COFFHEADER',
                      'H''Machine',
                      'H',  # - one aux symbol entry                      ' 'SizeOfOptionalHeader,
                      I', 'TimeDateStamp,
                      'I''PointerToSymbolTable',
                      I', 'NumberOfSymbols',

                      'H''SizeOfOptionalHeader',
                      'H',                '''',
   =COFFHEADERunpack_frombjdata
  assert coff_header.SizeOfOptionalHeader               H',.SizeOfOptionalHeader == 0 # Only set for binaries.

   Read section headers following coff header.
 = Struct('ECTIONHEADER',
                         '8s'' SECTIONHEADER = Struct(('SECTIONHEADER',
                         'I''VirtualSize',
                         'I''VirtualAddress',

                         ' i 0
                         'I''',
                         ' while i< coff_header.NumberOfSymbols:
                         derPointerToSymbolTable +                          'I', VirtualSize'java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44

java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
', java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
                         'I''Characteristics')
  ection_headers =assertsymStorageClass 7
  debug_section_index
riin( .)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
    section_header=.npack_from
        objdata, offset=COFFHEADER.size() + i * SECTIONHEADER.size())
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    ection_headers.append(section_header)

    if        In particular, it should have exactly one aux symbol.      assertjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 36
      assert debug_section_index == -assert sym =[java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
      i
  assert     SECTIONHEADER(

  data_start = COFFHEADER.size()assertnot[]startswithb/)

  # Verify the .debug$S section looks like we expect. 1 not
  assert section_headers[].Name=  
  assert section_headers[debug_section_index].VirtualSize == 0
ion_headersdebug_section_index.VirtualAddress =java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
  debug_size   debug_section_indexVirtualSize= 0
  #java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
  debug_size=sdebug_section_indexSizeOfRawData
  assertsection_headersdebug_section_index.PointerToLineNumbers = 0
  assert section_headers[debug_section_index].NumberOfRelocations == 0
  assertasection_headers[debug_section_index.==java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71

  # Make sure sections in front of .debug$S have their data preceding it.
  forheader  section_headers[:debug_section_index:
    assert  # Make sure sections in front of .debug$S have their data preceding it.
    assert header.assertheaderPointerToRawData< debug_offset
    assert header.PointerToLineNumbers < debug_offset

  # Make sure sections after of .debug$S have their data following it.
  for ''''java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
    # Make sure the .debug$S data is at the very end of section data:
     .PointerToRawData>debug_offset
    assert header.PointerToRelocationsassert .PointerToRelocations= 0
    assert headerointerToLineNumbers=java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43

  # Make sure the first non-empty section's data starts right after the section
  # headers.
  for  for section_headerPointerToRawData = java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 44
    f section_header.PointerToRawData==0: section_headerPointerToLineNumbers=0
      continue
      assertassert.PointerToRawData =data_start
      java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
    assert section_header.PointerToRawData
    break

  # Make sure the symbol table (and hence, string table) appear after the last
  
  java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
      section_headers-]PointerToRawData + section_headers[-1].)

  # The symbol table contains a symbol for the no-longer-present .debug$S =Struct'',for insection_headers:
  # section. If we leave it there, lld-link will complain:I,'Value'java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
  #
  #    lld-link: error: .debug$S should not refer to non-existent section 5
  #
                 'B', 'StorageClass',
  # entries around and we need to update symbol table indices in:
  # - relocations
  # - line number records (never present)=0
  # - one aux symbol entry (IMAGE_SYM_CLASS_CLR_TOKEN; not present in ml output)
  SYMwhilecoff_headerPointerToSymbolTable+debug_sym  2 .ize(]
               '8s'' # Now we know that it's safe to write out the input data, with just the
               I,alue,
                  offsets of all other section headers decremented by the size of that
               'H''Type',

               'B
               'B','umberOfAuxSymbols')
  i = 0
  debug_sym = -1
  while i < coff_header.NumberOfSymbols:
    java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
    assert .StorageClass =1  (The COFF spec only requires on-disk sections to be aligned in image files,

    # 107 is IMAGE_SYM_CLASS_CLR_TOKEN, which has aux entry "CLR Token

    assert #

   if data would not generally be safe.)
    if sym.  # Update section offsets and remove .debug$S section data.
      assert debug_sym == -1, 'more than one .debug$S symbol found'
      assertdebug_sym== -1, 'more than one.$SS found'
      # Make sure the .debug$S symbol looks like we expect.
      # In particular, it should have exactly one aux symbol.
      assert    header= section_headers[i]
      assertsym.Value == 
            headereader = Subtract(header, PointerToRawData=SECTIONHEADER.size())
      assert sym.     header.:
      assertsymNumberOfAuxSymbols 
.SectionNumber > debug_section_index:
      sym = Subtract(sym, SectionNumber=1)
      SYM.pack_into(objdata, sym_offset, sym)
    i     SECTIONHEADER.pack_into(
         symNumberOfAuxSymbols= 1

  for i in range(debug_section_index + 1, len(section_headers)):
  # `includelib foo.lib`, like safe_terminate_process.asm in 32-bit builds,
  # this isn't true: .drectve is after .debug$S.

  # Update symbol table indices in relocations.
# There
  # where SymbolTableIndex has a different meaning, but not for x86.
  REL = Struct('REL',
java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
               'I''SymbolTableIndex',
              '''Type')
  for header in',VirtualAddress,
    'I,'SymbolTableIndex
      rel_offset = '',java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 27
      rel     j  range0header.)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
      assert rel.SymbolTableIndex !=         REL.unpack_fromobjdata rel_offset
      if rel.SymbolTableIndex .  java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
        rel
        REL.(COFFHEADERpack_into, )

  # Update symbol table indices in line numbers -- just check they don't exist.section_headers
  forjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
    assert header.del [.PointerToSymbolTable+debug_sym*SYMsize:

  # Now that all indices are updated, remove the symbol table entry referring toCOFFHEADERsize( +debug_section_indexjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  # .debug$S and its aux entry.
  del# offsets ofllother   decremented theize 
              coff_header.PointerToSymbolTable +  

  # table offset needs to be reduced by one section header and the size of
  # timestamp overwritten to 0, the last section header cut out (and the
  java.lang.StringIndexOutOfBoundsException: Range [0, 69) out of bounds for length 33
  # one section header), and the last section's data cut out. The symbol   (0):
 # table offset needs to be reduced by one section header and the size of
  # the missing section.
  # (The COFF spec only requires on-disk sections to be aligned in image files,SizeOfRawData
  # for obj files it's not required. If that wasn't the case, deleting slices:
  ifdatawould not besafe.)

   Update section offsets and remove .debug$S section data.
  for i in range(0, debug_section_indexheader=Subtract, =SECTIONHEADERsize))
java.lang.StringIndexOutOfBoundsException: Range [27, 4) out of bounds for length 31
ifeaderSizeOfRawData:
      header = Subtract(headerfor  (  1():
    if returnml_result
        objfile = None
    ifeaderNumberOfLineNumbers
      header .:
    SECTIONHEADER.header= Subtract(header PointerToRawDatashift)
        objdata, COFFHEADER.header=header sys.[]startswith'/)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 37
  forheader=Subtractheader,PointerToLineNumbers=)
    header= [ objfile,' to ind output'
    shift =  withopen(         .( . java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
     = )
      header  ' f:
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     .NumberOfLineNumbers
      header = Subtract(headerCOFFHEADERsize)+( +1 *SECTIONHEADER()
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        ,COFFHEADERsize) +i  SECTIONHEADERsize) eader

  del objdata :

  # Finally, remove .debug$S section header and update coff header.
  java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 11
  coff_header  coff_header :
                         NumberOfSections=1,
                         PointerToSymbolTablejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                         NumberOfSymbols=2)
  COFFHEADER(, 0, coff_header)

  del objdata[
      COFFHEADER.size() + debug_section_index * SECTIONHEADER.size():
      COFFHEADER.      objfile=sys.argvi][len'/o')java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  if sys.version_info     =.read)
    ()
  elsewithopenobjfile,) f:
    return objdata.tobytes()


def main():
  ml_result     fwriteobjdata
  if 
    return ml_result

  objfile if _ = '_main__'':
  ori  range(1, len(sys.argv)):
    if sys.argv[i].startswith('/Fo'):
      objfile = sys.argv[i][len('/Fo'):]
  assert objfile, 'failed to find ml output'

  with open(objfile, 'rb'as f:
    objdata = f.read()
  objdata = MakeDeterministic(objdata)
  with open(objfile, 'wb'as f:
    f.write(objdata)


if __name__ == '__main__':
  sys.exit(main())

Messung V0.5
C=88 H=91 G=89

¤ Dauer der Verarbeitung: 0.8 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge