static bool dex_create_relocations(RzBinDex *dex) {
	void **iter_p0;
	RzListIter *iter_l;
	DexClassDef *class_def;
	DexEncodedMethod *encoded_method = NULL;
	DexMethodId *method_id = NULL;

	dex->relocs_size = 0;
	rz_pvector_foreach (dex->method_ids, iter_p0) {
		method_id = (DexMethodId *)*iter_p0;
		if (method_id->code_offset) {
			continue;
		}
		// patch the imported method.
		method_id->code_offset = dex->relocs_offset + dex->relocs_size;
		method_id->code_size = 2;
		dex->relocs_size += 2;
	}

	// sync classes with method_ids
	rz_pvector_foreach (dex->class_defs, iter_p0) {
		class_def = (DexClassDef *)*iter_p0;
		rz_list_foreach (class_def->direct_methods, iter_l, encoded_method) {
			if (encoded_method->code_offset) {
				continue;
			}
			method_id = NULL;
			if (encoded_method->method_idx < rz_pvector_len(dex->method_ids)) {
				method_id = (DexMethodId *)rz_pvector_at(dex->method_ids, encoded_method->method_idx);
				if (method_id->code_offset) {
					encoded_method->code_offset = method_id->code_offset;
					encoded_method->code_size = method_id->code_size;
					continue;
				}
			}

			// patch the imported method.
			encoded_method->code_offset = dex->relocs_offset + dex->relocs_size;
			encoded_method->code_size = 2;
			dex->relocs_size += 2;
			if (method_id) {
				method_id->code_offset = encoded_method->code_offset;
				method_id->code_size = encoded_method->code_size;
			}
		}

		rz_list_foreach (class_def->virtual_methods, iter_l, encoded_method) {
			if (encoded_method->code_offset) {
				continue;
			}
			method_id = NULL;
			if (encoded_method->method_idx < rz_pvector_len(dex->method_ids)) {
				method_id = (DexMethodId *)rz_pvector_at(dex->method_ids, encoded_method->method_idx);
				if (method_id->code_offset) {
					encoded_method->code_offset = method_id->code_offset;
					encoded_method->code_size = method_id->code_size;
					continue;
				}
			}

			// patch the imported method.
			encoded_method->code_offset = dex->relocs_offset + dex->relocs_size;
			encoded_method->code_size = 2;
			dex->relocs_size += 2;
			if (method_id) {
				method_id->code_offset = encoded_method->code_offset;
				method_id->code_size = encoded_method->code_size;
			}
		}
	}

	if (dex->relocs_size < 1) {
		return true;
	}
	dex->relocs_code = malloc(dex->relocs_size);
	if (!dex->relocs_code) {
		return false;
	}
	for (ut32 i = 0; i < dex->relocs_size; i += 2) {
		dex->relocs_code[i] = 0x0e;
		dex->relocs_code[i + 1] = 0x00;
	}
	dex->relocs_buffer = rz_buf_new_with_bytes(dex->relocs_code, dex->relocs_size);
	return dex->relocs_buffer;
}
static bool dex_create_relocations(RzBinDex *dex) {
	void **iter_p0;
	RzListIter *iter_l;
	DexClassDef *class_def;
	DexEncodedMethod *encoded_method = NULL;
	DexMethodId *method_id = NULL;

	dex->relocs_size = 0;
	rz_pvector_foreach (dex->method_ids, iter_p0) {
		method_id = (DexMethodId *)*iter_p0;
		if (method_id->code_offset) {
			continue;
		}
		 
		method_id->code_offset = dex->relocs_offset + dex->relocs_size;
		method_id->code_size = 2;
		dex->relocs_size += 2;
	}

	 
	rz_pvector_foreach (dex->class_defs, iter_p0) {
		class_def = (DexClassDef *)*iter_p0;
		rz_list_foreach (class_def->direct_methods, iter_l, encoded_method) {
			if (encoded_method->code_offset) {
				continue;
			}
			method_id = NULL;
			if (encoded_method->method_idx < rz_pvector_len(dex->method_ids)) {
				method_id = (DexMethodId *)rz_pvector_at(dex->method_ids, encoded_method->method_idx);
				if (method_id->code_offset) {
					encoded_method->code_offset = method_id->code_offset;
					encoded_method->code_size = method_id->code_size;
					continue;
				}
			}

			 
			encoded_method->code_offset = dex->relocs_offset + dex->relocs_size;
			encoded_method->code_size = 2;
			dex->relocs_size += 2;
			if (method_id) {
				method_id->code_offset = encoded_method->code_offset;
				method_id->code_size = encoded_method->code_size;
			}
		}

		rz_list_foreach (class_def->virtual_methods, iter_l, encoded_method) {
			if (encoded_method->code_offset) {
				continue;
			}
			method_id = NULL;
			if (encoded_method->method_idx < rz_pvector_len(dex->method_ids)) {
				method_id = (DexMethodId *)rz_pvector_at(dex->method_ids, encoded_method->method_idx);
				if (method_id->code_offset) {
					encoded_method->code_offset = method_id->code_offset;
					encoded_method->code_size = method_id->code_size;
					continue;
				}
			}

			 
			encoded_method->code_offset = dex->relocs_offset + dex->relocs_size;
			encoded_method->code_size = 2;
			dex->relocs_size += 2;
			if (method_id) {
				method_id->code_offset = encoded_method->code_offset;
				method_id->code_size = encoded_method->code_size;
			}
		}
	}

	if (dex->relocs_size < 1) {
		return true;
	}
	dex->relocs_code = malloc(dex->relocs_size);
	if (!dex->relocs_code) {
		return false;
	}
	for (ut32 i = 0; i < dex->relocs_size; i += 2) {
		dex->relocs_code[i] = 0x0e;
		dex->relocs_code[i + 1] = 0x00;
	}
	dex->relocs_buffer = rz_buf_new_with_bytes(dex->relocs_code, dex->relocs_size);
	return dex->relocs_buffer;
}