#! /usr/bin/env python # Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys import struct ROCKY_HEADER_SIZE = 8 ROCKY_HEADER_FMT = "4sB3x" JERRY_HEADER_SIZE = 16 JERRY_HEADER_FMT = "<4I" LIT_TABLE_HEADER_SIZE = 8 LIT_TABLE_HEADER_FMT = "<2I" LIT_STRING_HEADER_SIZE = 2 LIT_STRING_HEADER_FMT = " 0: fin.seek(move, 1) offset += aligned_length remaining_length = jerry_header[2] - offset - LIT_TABLE_HEADER_SIZE number_length = remaining_length / float(lit_number_count) if not number_length.is_integer(): print "Invalid offset for start of number literals" return 1 number_length = int(number_length) for i in xrange(lit_number_count): length = number_length aligned_length = _get_aligned_literal_length(length) n = struct.unpack("d" if length == 8 else "f", fin.read(length))[0] print "0x{:08x}: Number: {}".format(offset, n) move = aligned_length - length if move > 0: fin.seek(move, 1) offset += aligned_length print "Numbers are {}-bit".format(number_length * 8) return 0 if __name__ == "__main__": rc = main(sys.argv[1]) sys.exit(rc)