static void bin_elf_versioninfo(RCore *r) {
	const char *format = "bin/cur/info/versioninfo/%s%d";
	char path[256] = R_EMPTY;
	int num_versym = 0;
	int num_verneed = 0;
	int num_entry = 0;
	Sdb *sdb = NULL;
	do {
		snprintf (path, sizeof (path), format, "versym", num_versym++);
		if (!(sdb = sdb_ns_path (r->sdb, path, 0))) {
			break;
		}
		ut64 addr = sdb_num_get (sdb, "addr", 0);
		ut64 offset = sdb_num_get (sdb, "offset", 0);
		ut64 link = sdb_num_get (sdb, "link", 0);
		ut64 num_entries = sdb_num_get (sdb, "num_entries", 0);
		const char *section_name = sdb_const_get (sdb, "section_name", 0);
		const char *link_section_name = sdb_const_get (sdb, "link_section_name", 0);

		r_cons_printf ("Version symbols section '%s' contains %"PFMT64u" entries:\n", section_name, num_entries);
		r_cons_printf (" Addr: 0x%08"PFMT64x"  Offset: 0x%08"PFMT64x"  Link: %x (%s)\n",
			(ut64)addr, (ut64)offset, (ut32)link, link_section_name);

		do {
			int num_val = 0;
			char path_entry[256] = R_EMPTY;
			snprintf (path_entry, sizeof (path_entry), "%s/entry%d", path, num_entry++);
			if (!(sdb = sdb_ns_path (r->sdb, path_entry, 0)))
				break;

			r_cons_printf ("  0x%08"PFMT64x": ", sdb_num_get (sdb, "idx", 0));
			const char *value = NULL;

			do {
				char key[32] = R_EMPTY;
				snprintf (key, sizeof (key), "value%d", num_val++);

				if ((value = sdb_const_get (sdb, key, 0)))
					r_cons_printf ("%s ", value);
			} while (value);
			r_cons_newline ();
		} while (sdb);
		r_cons_println ("\n");
	} while (sdb);

	do {
		int num_version = 0;
		char path_version[256] = R_EMPTY;
		snprintf (path, sizeof (path), format, "verneed", num_verneed++);
		if (!(sdb = sdb_ns_path (r->sdb, path, 0)))
			break;

		r_cons_printf ("Version need section '%s' contains %d entries:\n",
			sdb_const_get (sdb, "section_name", 0), (int)sdb_num_get (sdb, "num_entries", 0));

		r_cons_printf (" Addr: 0x%08"PFMT64x, sdb_num_get (sdb, "addr", 0));

		r_cons_printf ("  Offset: 0x%08"PFMT64x"  Link to section: %"PFMT64d" (%s)\n",
			sdb_num_get (sdb, "offset", 0), sdb_num_get (sdb, "link", 0),
			sdb_const_get (sdb, "link_section_name", 0));

		do {
			snprintf (path_version, sizeof (path_version), "%s/version%d", path, num_version++);
			const char *filename = NULL;
			char path_vernaux[256] = R_EMPTY;
			int num_vernaux = 0;
			if (!(sdb = sdb_ns_path (r->sdb, path_version, 0)))
				break;

			r_cons_printf ("  0x%08"PFMT64x": Version: %d",
				sdb_num_get (sdb, "idx", 0), (int)sdb_num_get (sdb, "vn_version", 0));

			if ((filename = sdb_const_get (sdb, "file_name", 0)))
				r_cons_printf ("  File: %s", filename);

			r_cons_printf ("  Cnt: %d\n", (int)sdb_num_get (sdb, "cnt", 0));
			do {
				snprintf (path_vernaux, sizeof (path_vernaux), "%s/vernaux%d",
					path_version, num_vernaux++);
				if (!(sdb = sdb_ns_path (r->sdb, path_vernaux, 0)))
					break;

				r_cons_printf ("  0x%08"PFMT64x":   Name: %s",
					sdb_num_get (sdb, "idx", 0), sdb_const_get (sdb, "name", 0));

				r_cons_printf ("  Flags: %s Version: %d\n",
					sdb_const_get (sdb, "flags", 0), (int)sdb_num_get (sdb, "version", 0));
			} while (sdb);
		} while (sdb);
	} while (sdb);
}
static void bin_elf_versioninfo(RCore *r) {
	const char *format = "bin/cur/info/versioninfo/%s%d";
	char path[256] = R_EMPTY;
	int num_versym = 0;
	int num_verneed = 0;
	int num_entry = 0;
	Sdb *sdb = NULL;
	do {
		snprintf (path, sizeof (path), format, "versym", num_versym++);
		if (!(sdb = sdb_ns_path (r->sdb, path, 0))) {
			break;
		}
		ut64 addr = sdb_num_get (sdb, "addr", 0);
		ut64 offset = sdb_num_get (sdb, "offset", 0);
		ut64 link = sdb_num_get (sdb, "link", 0);
		ut64 num_entries = sdb_num_get (sdb, "num_entries", 0);
		const char *section_name = sdb_const_get (sdb, "section_name", 0);
		const char *link_section_name = sdb_const_get (sdb, "link_section_name", 0);

		r_cons_printf ("Version symbols section '%s' contains %"PFMT64u" entries:\n", section_name, num_entries);
		r_cons_printf (" Addr: 0x%08"PFMT64x"  Offset: 0x%08"PFMT64x"  Link: %x (%s)\n",
			(ut64)addr, (ut64)offset, (ut32)link, link_section_name);

		do {
			int num_val = 0;
			char path_entry[256] = R_EMPTY;
			snprintf (path_entry, sizeof (path_entry), "%s/entry%d", path, num_entry++);
			if (!(sdb = sdb_ns_path (r->sdb, path_entry, 0)))
				break;

			r_cons_printf ("  0x%08"PFMT64x": ", sdb_num_get (sdb, "idx", 0));
			const char *value = NULL;

			do {
				char key[32] = R_EMPTY;
				snprintf (key, sizeof (key), "value%d", num_val++);

				if ((value = sdb_const_get (sdb, key, 0)))
					r_cons_printf ("%s ", value);
			} while (value);
			r_cons_newline ();
		} while (sdb);
		r_cons_println ("\n");
	} while (sdb);

	do {
		int num_version = 0;
		char path_version[256] = R_EMPTY;
		snprintf (path, sizeof (path), format, "verneed", num_verneed++);
		if (!(sdb = sdb_ns_path (r->sdb, path, 0)))
			break;

		r_cons_printf ("Version need section '%s' contains %d entries:\n",
			sdb_const_get (sdb, "section_name", 0), (int)sdb_num_get (sdb, "num_entries", 0));

		r_cons_printf (" Addr: 0x%08"PFMT64x, sdb_num_get (sdb, "addr", 0));

		r_cons_printf ("  Offset: 0x%08"PFMT64x"  Link to section: %"PFMT64d" (%s)\n",
			sdb_num_get (sdb, "offset", 0), sdb_num_get (sdb, "link", 0),
			sdb_const_get (sdb, "link_section_name", 0));

		do {
			snprintf (path_version, sizeof (path_version), "%s/version%d", path, num_version++);
			const char *filename = NULL;
			char path_vernaux[256] = R_EMPTY;
			int num_vernaux = 0;
			if (!(sdb = sdb_ns_path (r->sdb, path_version, 0)))
				break;

			r_cons_printf ("  0x%08"PFMT64x": Version: %d",
				sdb_num_get (sdb, "idx", 0), (int)sdb_num_get (sdb, "vn_version", 0));

			if ((filename = sdb_const_get (sdb, "file_name", 0)))
				r_cons_printf ("  File: %s", filename);

			r_cons_printf ("  Cnt: %d\n", (int)sdb_num_get (sdb, "cnt", 0));
			do {
				snprintf (path_vernaux, sizeof (path_vernaux), "%s/vernaux%d",
					path_version, num_vernaux++);
				if (!(sdb = sdb_ns_path (r->sdb, path_vernaux, 0)))
					break;

				r_cons_printf ("  0x%08"PFMT64x":   Name: %s",
					sdb_num_get (sdb, "idx", 0), sdb_const_get (sdb, "name", 0));

				r_cons_printf ("  Flags: %s Version: %d\n",
					sdb_const_get (sdb, "flags", 0), (int)sdb_num_get (sdb, "version", 0));
			} while (sdb);
		} while (sdb);
	} while (sdb);
}