static void set_bin_relocs(RCore *r, RBinReloc *reloc, ut64 addr, Sdb **db, char **sdb_module) {
	int bin_demangle = r_config_get_i (r->config, "bin.demangle");
	const char *lang = r_config_get (r->config, "bin.lang");
	char *reloc_name, *demname = NULL;
	bool is_pe = true;
	int is_sandbox = r_sandbox_enable (0);

	if (reloc->import && reloc->import->name[0]) {
		char str[R_FLAG_NAME_SIZE];
		RFlagItem *fi;

		if (is_pe && !is_sandbox && strstr (reloc->import->name, "Ordinal")) {
			const char *TOKEN = ".dll_Ordinal_";
			char *module = strdup (reloc->import->name);
			char *import = strstr (module, TOKEN);

			r_str_case (module, false);
			if (import) {
				char *filename = NULL;
				int ordinal;
				*import = 0;
				import += strlen (TOKEN);
				ordinal = atoi (import);
				if (!*sdb_module || strcmp (module, *sdb_module)) {
					sdb_free (*db);
					*db = NULL;
					free (*sdb_module);
					*sdb_module = strdup (module);
					/* always lowercase */
					filename = sdb_fmt ("%s.sdb", module);
					r_str_case (filename, false);
					if (r_file_exists (filename)) {
						*db = sdb_new (NULL, filename, 0);
					} else {
					// XXX. we have dir.prefix, windows shouldnt work different
						filename = sdb_fmt ("%s/share/radare2/" R2_VERSION"/format/dll/%s.sdb", r_config_get (r->config, "dir.prefix"), module);
						if (r_file_exists (filename)) {
							*db = sdb_new (NULL, filename, 0);
#if __WINDOWS__
						} else {
							char invoke_dir[MAX_PATH];
							if (r_sys_get_src_dir_w32 (invoke_dir)) {
								filename = sdb_fmt ("%s/share/radare2/"R2_VERSION "/format/dll/%s.sdb", invoke_dir, module);
							} else {
								filename = sdb_fmt ("share/radare2/"R2_VERSION"/format/dll/%s.sdb", module);
							}
#else
							filename = sdb_fmt ("%s/share/radare2/" R2_VERSION"/format/dll/%s.sdb", r_config_get (r->config, "dir.prefix"), module);
							if (r_file_exists (filename)) {
								*db = sdb_new (NULL, filename, 0);
							}
#endif
						}
					}
				}
				if (*db) {
					// ordinal-1 because we enumerate starting at 0
					char *symname = resolveModuleOrdinal (*db, module, ordinal - 1);  // uses sdb_get
					if (symname) {
						if (r->bin->prefix) {
							reloc->import->name = r_str_newf
								("%s.%s.%s", r->bin->prefix, module, symname);
						} else {
							reloc->import->name = r_str_newf
								("%s.%s", module, symname);
						}
						R_FREE (symname);
					}
				}
			}
			free (module);
			r_anal_hint_set_size (r->anal, reloc->vaddr, 4);
			r_meta_add (r->anal, R_META_TYPE_DATA, reloc->vaddr, reloc->vaddr+4, NULL);
		}
		reloc_name = reloc->import->name;
		if (r->bin->prefix) {
			snprintf (str, R_FLAG_NAME_SIZE, "%s.reloc.%s", r->bin->prefix, reloc_name);
		} else {
			snprintf (str, R_FLAG_NAME_SIZE, "reloc.%s", reloc_name);
		}
		if (bin_demangle) {
			demname = r_bin_demangle (r->bin->cur, lang, str, addr);
		}
		r_name_filter (str, 0);
		fi = r_flag_set (r->flags, str, addr, bin_reloc_size (reloc));
		if (demname) {
			char *realname;
			if (r->bin->prefix) {
				realname = sdb_fmt ("%s.reloc.%s", r->bin->prefix, demname);
			} else {
				realname = sdb_fmt ("reloc.%s", demname);
			}
			r_flag_item_set_realname (fi, realname);
		}
	} else {
		char *reloc_name = get_reloc_name (reloc, addr);
		r_flag_set (r->flags, reloc_name, addr, bin_reloc_size (reloc));
	}
}