def readRawBufferInfo(metaData, hasRandSection): randInfo = shuffleInfo_pb2.ReorderInfo() if hasRandSection: try: randInfo.ParseFromString(gzip.open(metaData, "rb").read()) except IOError: print( "Found a .rand section but not gzipped. Check out the CCR linker!" ) else: randInfo.ParseFromString(open(metaData, "rb").read()) return randInfo
def read(metaData, hasRandSection): """ Deserialize the metadata for randomization in google protobuf format :param metaData: target file name :param isDebug: :return: """ randInfo = shuffleInfo_pb2.ReorderInfo() if hasRandSection: try: randInfo.ParseFromString(gzip.open(metaData, "rb").read()) except IOError: print "Found a .rand section but not gzipped. Check out the CCR linker!" else: randInfo.ParseFromString(open(metaData, "rb").read()) return deserializeInfo(randInfo)
def getMetadata(param): if isMetadata(param): print("Found the metadata at %s" % param) return param if isELF(param): if os.path.exists(C.METADATA_PATH): os.remove(C.METADATA_PATH) os.system(' '.join([ 'objcopy', '--dump-section', C.RAND_SECTION + '=' + C.METADATA_PATH, param, '2> /dev/null' ])) return C.METADATA_PATH fn = getMetadata(sys.argv[1]) ri = shuffleInfo_pb2.ReorderInfo() if isMetadata(fn): ri = shuffleInfo_pb2.ReorderInfo() ri.ParseFromString(open(fn, "rb").read()) readOnly(fn + C.METADESC_POSTFIX, ri) elif isELF(sys.argv[1]): try: ri.ParseFromString(gzip.open(fn, "rb").read()) print( "Found the .rand section, dumping into %s (will be removed at the end)" % C.METADATA_PATH) readOnly(sys.argv[1] + C.METADATA_POSTFIX + C.METADESC_POSTFIX, ri) os.remove(C.METADATA_PATH) except IOError: print(
print "obj_func_cnt", obj_func_cnt print "fun_size", fun_size print "fun_bb_cnt", fun_bb_cnt print "bbk_size", bbk_size print "bbk_fixup_cnt", bbk_fixup_cnt print "fixup_deref_size", fixup_deref_size print "fixup_offset", fixup_offset print "fixup_is_rela", fixup_is_rela print "fixup_deref_size_ro", fixup_deref_size_ro print "fixup_offset_ro", fixup_offset_ro print "fixup_is_rela_ro", fixup_is_rela_ro if __name__ == '__main__': if len(sys.argv) != 2: print "Usage:", sys.argv[0], "INFO_FILE" sys.exit(-1) reorder_info = shuffleInfo_pb2.ReorderInfo() # Read the existing address book. f = open(sys.argv[1], "rb") reorder_info.ParseFromString(f.read()) f.close() deserializeInfo(reorder_info)