Index: kernel/generic/include/lib/elf_load.h
===================================================================
--- kernel/generic/include/lib/elf_load.h	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ kernel/generic/include/lib/elf_load.h	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -38,16 +38,5 @@
 #include <abi/elf.h>
 
-/**
- * ELF error return codes
- */
-#define EE_OK             0  /* No error */
-#define EE_INVALID        1  /* Invalid ELF image */
-#define EE_MEMORY         2  /* Cannot allocate address space */
-#define EE_INCOMPATIBLE   3  /* ELF image is not compatible with current architecture */
-#define EE_UNSUPPORTED    4  /* Non-supported ELF (e.g. dynamic ELFs) */
-#define EE_IRRECOVERABLE  5  /* Irrecoverable error. */
-
-extern unsigned int elf_load(elf_header_t *, as_t *);
-extern const char *elf_error(unsigned int rc);
+extern errno_t elf_load(elf_header_t *, as_t *);
 
 #endif
Index: kernel/generic/include/proc/program.h
===================================================================
--- kernel/generic/include/proc/program.h	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ kernel/generic/include/proc/program.h	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -50,5 +50,5 @@
 	struct task *task;           /**< Program task */
 	struct thread *main_thread;  /**< Program main thread */
-	unsigned int loader_status;  /**< Binary loader error status */
+	errno_t loader_status;  /**< Binary loader error status */
 } program_t;
 
Index: kernel/generic/src/lib/elf.c
===================================================================
--- kernel/generic/src/lib/elf.c	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ kernel/generic/src/lib/elf.c	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -50,14 +50,5 @@
 #include <lib/elf_load.h>
 
-static const char *error_codes[] = {
-	"no error",
-	"invalid image",
-	"address space error",
-	"incompatible image",
-	"unsupported image type",
-	"irrecoverable error"
-};
-
-static int load_segment(elf_segment_header_t *, elf_header_t *, as_t *);
+static errno_t load_segment(elf_segment_header_t *, elf_header_t *, as_t *);
 
 /** ELF loader
@@ -67,8 +58,8 @@
  * @param flags  A combination of ELD_F_*
  *
- * @return EE_OK on success
+ * @return EOK on success
  *
  */
-unsigned int elf_load(elf_header_t *header, as_t *as)
+errno_t elf_load(elf_header_t *header, as_t *as)
 {
 	/* Identify ELF */
@@ -77,5 +68,5 @@
 	    (header->e_ident[EI_MAG2] != ELFMAG2) ||
 	    (header->e_ident[EI_MAG3] != ELFMAG3))
-		return EE_INVALID;
+		return EINVAL;
 
 	/* Identify ELF compatibility */
@@ -85,16 +76,16 @@
 	    (header->e_version != EV_CURRENT) ||
 	    (header->e_ident[EI_CLASS] != ELF_CLASS))
-		return EE_INCOMPATIBLE;
+		return EINVAL;
 
 	if (header->e_phentsize != sizeof(elf_segment_header_t))
-		return EE_INCOMPATIBLE;
+		return EINVAL;
 
 	/* Check if the object type is supported. */
 	if (header->e_type != ET_EXEC)
-		return EE_UNSUPPORTED;
+		return ENOTSUP;
 
 	/* Check if the ELF image starts on a page boundary */
 	if (ALIGN_UP((uintptr_t) header, PAGE_SIZE) != (uintptr_t) header)
-		return EE_UNSUPPORTED;
+		return ENOTSUP;
 
 	/* Walk through all segment headers and process them. */
@@ -108,24 +99,10 @@
 			continue;
 
-		int rc = load_segment(seghdr, header, as);
-		if (rc != EE_OK)
+		errno_t rc = load_segment(seghdr, header, as);
+		if (rc != EOK)
 			return rc;
 	}
 
-	return EE_OK;
-}
-
-/** Print error message according to error code.
- *
- * @param rc Return code returned by elf_load().
- *
- * @return NULL terminated description of error.
- *
- */
-const char *elf_error(unsigned int rc)
-{
-	assert(rc < sizeof(error_codes) / sizeof(char *));
-
-	return error_codes[rc];
+	return EOK;
 }
 
@@ -136,8 +113,8 @@
  * @param as    Address space into wich the ELF is being loaded.
  *
- * @return EE_OK on success, error code otherwise.
+ * @return EOK on success, error code otherwise.
  *
  */
-int load_segment(elf_segment_header_t *entry, elf_header_t *elf, as_t *as)
+errno_t load_segment(elf_segment_header_t *entry, elf_header_t *elf, as_t *as)
 {
 	mem_backend_data_t backend_data;
@@ -146,5 +123,5 @@
 		if ((entry->p_offset % entry->p_align) !=
 		    (entry->p_vaddr % entry->p_align))
-			return EE_INVALID;
+			return EINVAL;
 	}
 
@@ -177,5 +154,5 @@
 	    AS_AREA_ATTR_NONE, &elf_backend, &backend_data, &base, 0);
 	if (!area)
-		return EE_MEMORY;
+		return ENOMEM;
 
 	/*
@@ -184,5 +161,5 @@
 	 */
 
-	return EE_OK;
+	return EOK;
 }
 
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ kernel/generic/src/main/kinit.c	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -291,6 +291,6 @@
 			log(LF_OTHER, LVL_ERROR,
 			    "init[%zu]: Init binary load failed "
-			    "(error %s, loader status %u)", i,
-			    str_error_name(rc), programs[i].loader_status);
+			    "(error %s, loader status %s)", i,
+			    str_error_name(rc), str_error_name(programs[i].loader_status));
 		}
 	}
Index: kernel/generic/src/proc/program.c
===================================================================
--- kernel/generic/src/proc/program.c	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ kernel/generic/src/proc/program.c	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -48,5 +48,5 @@
 #include <security/perm.h>
 #include <lib/elf_load.h>
-#include <errno.h>
+#include <str.h>
 #include <log.h>
 #include <syscall/copy.h>
@@ -76,5 +76,5 @@
 		return ENOMEM;
 
-	prg->loader_status = EE_OK;
+	prg->loader_status = EOK;
 	prg->task = task_create(as, name);
 	if (!prg->task) {
@@ -149,5 +149,5 @@
 
 	prg->loader_status = elf_load((elf_header_t *) image_addr, as);
-	if (prg->loader_status != EE_OK) {
+	if (prg->loader_status != EOK) {
 		as_release(as);
 		prg->task = NULL;
@@ -183,8 +183,8 @@
 
 	prg->loader_status = elf_load((elf_header_t *) program_loader, as);
-	if (prg->loader_status != EE_OK) {
+	if (prg->loader_status != EOK) {
 		as_release(as);
 		log(LF_OTHER, LVL_ERROR, "Cannot spawn loader (%s)",
-		    elf_error(prg->loader_status));
+		    str_error(prg->loader_status));
 		return ENOENT;
 	}
Index: uspace/lib/c/generic/elf/elf_load.c
===================================================================
--- uspace/lib/c/generic/elf/elf_load.c	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ uspace/lib/c/generic/elf/elf_load.c	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -53,15 +53,15 @@
  * @param file File handle
  * @param info Place to store ELF program information
- * @return EE_OK on success or an EE_x error code
+ * @return EOK on success or an error code
  */
-int elf_load(int file, elf_info_t *info)
+errno_t elf_load(int file, elf_info_t *info)
 {
 #ifdef CONFIG_RTLD
 	rtld_t *env;
 #endif
-	int rc;
+	errno_t rc;
 
 	rc = elf_load_file(file, 0, &info->finfo);
-	if (rc != EE_OK) {
+	if (rc != EOK) {
 		DPRINTF("Failed to load executable '%s'.\n", file_name);
 		return rc;
@@ -72,5 +72,5 @@
 		DPRINTF("Binary is statically linked.\n");
 		info->env = NULL;
-		return EE_OK;
+		return EOK;
 	}
 
@@ -79,20 +79,8 @@
 	DPRINTF("- prog dynamic: %p\n", info->finfo.dynamic);
 
-	errno_t rc2 = rtld_prog_process(&info->finfo, &env);
-	switch (rc2) {
-	case EOK:
-		rc = EE_OK;
-		break;
-	case ENOMEM:
-		rc = EE_MEMORY;
-		break;
-	default:
-		DPRINTF("Unexpected error code from rtld_prog_process(): %s\n", str_error_name(rc2));
-		rc = EE_INVALID;
-	}
-
+	rc = rtld_prog_process(&info->finfo, &env);
 	info->env = env;
 #else
-	rc = EE_UNSUPPORTED;
+	rc = ENOTSUP;
 #endif
 	return rc;
Index: uspace/lib/c/generic/elf/elf_mod.c
===================================================================
--- uspace/lib/c/generic/elf/elf_mod.c	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ uspace/lib/c/generic/elf/elf_mod.c	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -64,17 +64,7 @@
 #define DPRINTF(...)
 
-static const char *error_codes[] = {
-	"no error",
-	"invalid image",
-	"address space error",
-	"incompatible image",
-	"unsupported image type",
-	"irrecoverable error",
-	"file io error"
-};
-
-static unsigned int elf_load_module(elf_ld_t *elf);
-static int segment_header(elf_ld_t *elf, elf_segment_header_t *entry);
-static int load_segment(elf_ld_t *elf, elf_segment_header_t *entry);
+static errno_t elf_load_module(elf_ld_t *elf);
+static errno_t segment_header(elf_ld_t *elf, elf_segment_header_t *entry);
+static errno_t load_segment(elf_ld_t *elf, elf_segment_header_t *entry);
 
 /** Load ELF binary from a file.
@@ -90,8 +80,8 @@
  *                  extracted from the binary.
  *
- * @return EE_OK on success or EE_xx error code.
- *
- */
-int elf_load_file(int file, eld_flags_t flags, elf_finfo_t *info)
+ * @return EOK on success or an error code.
+ *
+ */
+errno_t elf_load_file(int file, eld_flags_t flags, elf_finfo_t *info)
 {
 	elf_ld_t elf;
@@ -103,5 +93,5 @@
 	}
 	if (rc != EOK) {
-		return EE_IO;
+		return rc;
 	}
 
@@ -110,20 +100,20 @@
 	elf.flags = flags;
 
-	int ret = elf_load_module(&elf);
+	rc = elf_load_module(&elf);
 
 	vfs_put(ofile);
-	return ret;
-}
-
-int elf_load_file_name(const char *path, eld_flags_t flags, elf_finfo_t *info)
+	return rc;
+}
+
+errno_t elf_load_file_name(const char *path, eld_flags_t flags, elf_finfo_t *info)
 {
 	int file;
 	errno_t rc = vfs_lookup(path, 0, &file);
 	if (rc == EOK) {
-		int ret = elf_load_file(file, flags, info);
+		rc = elf_load_file(file, flags, info);
 		vfs_put(file);
-		return ret;
+		return rc;
 	} else {
-		return EE_IO;
+		return EIO;
 	}
 }
@@ -136,7 +126,7 @@
  *
  * @param elf		Pointer to loader state buffer.
- * @return EE_OK on success or EE_xx error code.
- */
-static unsigned int elf_load_module(elf_ld_t *elf)
+ * @return EOK on success or an error code.
+ */
+static errno_t elf_load_module(elf_ld_t *elf)
 {
 	elf_header_t header_buf;
@@ -144,5 +134,5 @@
 	aoff64_t pos = 0;
 	size_t nr;
-	int i, ret;
+	int i;
 	errno_t rc;
 
@@ -150,5 +140,5 @@
 	if (rc != EOK || nr != sizeof(elf_header_t)) {
 		DPRINTF("Read error.\n");
-		return EE_IO;
+		return EIO;
 	}
 
@@ -159,5 +149,5 @@
 	    header->e_ident[EI_MAG3] != ELFMAG3) {
 		DPRINTF("Invalid header.\n");
-		return EE_INVALID;
+		return EINVAL;
 	}
 
@@ -169,5 +159,5 @@
 	    header->e_ident[EI_CLASS] != ELF_CLASS) {
 		DPRINTF("Incompatible data/version/class.\n");
-		return EE_INCOMPATIBLE;
+		return EINVAL;
 	}
 
@@ -175,5 +165,5 @@
 		DPRINTF("e_phentsize: %u != %zu\n", header->e_phentsize,
 		    sizeof(elf_segment_header_t));
-		return EE_INCOMPATIBLE;
+		return EINVAL;
 	}
 
@@ -181,10 +171,10 @@
 	if (header->e_type != ET_EXEC && header->e_type != ET_DYN) {
 		DPRINTF("Object type %d is not supported\n", header->e_type);
-		return EE_UNSUPPORTED;
+		return ENOTSUP;
 	}
 
 	if (header->e_phoff == 0) {
 		DPRINTF("Program header table is not present!\n");
-		return EE_UNSUPPORTED;
+		return ENOTSUP;
 	}
 
@@ -203,5 +193,5 @@
 	if (phdr_len > sizeof(phdr)) {
 		DPRINTF("more than %d program headers\n", phdr_cap);
-		return EE_UNSUPPORTED;
+		return ENOTSUP;
 	}
 
@@ -210,5 +200,5 @@
 	if (rc != EOK || nr != phdr_len) {
 		DPRINTF("Read error.\n");
-		return EE_IO;
+		return EIO;
 	}
 
@@ -231,5 +221,5 @@
 	if (base_offset != 0) {
 		DPRINTF("ELF headers not present in the text segment.\n");
-		return EE_INVALID;
+		return EINVAL;
 	}
 
@@ -240,5 +230,5 @@
 		if (module_base != 0) {
 			DPRINTF("Unexpected shared object format.\n");
-			return EE_INVALID;
+			return EINVAL;
 		}
 
@@ -258,5 +248,5 @@
 		if (area == AS_MAP_FAILED) {
 			DPRINTF("Can't find suitable memory area.\n");
-			return EE_MEMORY;
+			return ENOMEM;
 		}
 
@@ -270,7 +260,7 @@
 			continue;
 
-		ret = load_segment(elf, &phdr[i]);
-		if (ret != EE_OK)
-			return ret;
+		rc = load_segment(elf, &phdr[i]);
+		if (rc != EOK)
+			return rc;
 	}
 
@@ -292,7 +282,7 @@
 			continue;
 
-		ret = segment_header(elf, &phdr[i]);
-		if (ret != EE_OK)
-			return ret;
+		rc = segment_header(elf, &phdr[i]);
+		if (rc != EOK)
+			return rc;
 	}
 
@@ -302,18 +292,5 @@
 	DPRINTF("Done.\n");
 
-	return EE_OK;
-}
-
-/** Print error message according to error code.
- *
- * @param rc Return code returned by elf_load().
- *
- * @return NULL terminated description of error.
- */
-const char *elf_error(unsigned int rc)
-{
-	assert(rc < sizeof(error_codes) / sizeof(char *));
-
-	return error_codes[rc];
+	return EOK;
 }
 
@@ -338,7 +315,7 @@
  * @param entry	Segment header.
  *
- * @return EE_OK on success, error code otherwise.
- */
-static int segment_header(elf_ld_t *elf, elf_segment_header_t *entry)
+ * @return EOK on success, error code otherwise.
+ */
+static errno_t segment_header(elf_ld_t *elf, elf_segment_header_t *entry)
 {
 	switch (entry->p_type) {
@@ -358,9 +335,9 @@
 		if (entry->p_filesz == 0) {
 			DPRINTF("Zero-sized ELF interp string.\n");
-			return EE_INVALID;
+			return EINVAL;
 		}
 		if (elf->info->interp[entry->p_filesz - 1] != '\0') {
 			DPRINTF("Unterminated ELF interp string.\n");
-			return EE_INVALID;
+			return EINVAL;
 		}
 		DPRINTF("interpreter: \"%s\"\n", elf->info->interp);
@@ -389,8 +366,8 @@
 	default:
 		DPRINTF("Segment p_type %d unknown.\n", entry->p_type);
-		return EE_UNSUPPORTED;
-		break;
-	}
-	return EE_OK;
+		return ENOTSUP;
+		break;
+	}
+	return EOK;
 }
 
@@ -400,7 +377,7 @@
  * @param entry Program header entry describing segment to be loaded.
  *
- * @return EE_OK on success, error code otherwise.
- */
-int load_segment(elf_ld_t *elf, elf_segment_header_t *entry)
+ * @return EOK on success, error code otherwise.
+ */
+errno_t load_segment(elf_ld_t *elf, elf_segment_header_t *entry)
 {
 	void *a;
@@ -435,5 +412,5 @@
 			    entry->p_offset % entry->p_align,
 			    seg_addr % entry->p_align, entry->p_align);
-			return EE_INVALID;
+			return EINVAL;
 		}
 	}
@@ -466,5 +443,5 @@
 		DPRINTF("memory mapping failed (%p, %zu)\n",
 		    (void *) (base + bias), mem_sz);
-		return EE_MEMORY;
+		return ENOMEM;
 	}
 
@@ -479,5 +456,5 @@
 	if (rc != EOK || nr != entry->p_filesz) {
 		DPRINTF("read error\n");
-		return EE_IO;
+		return EIO;
 	}
 
@@ -487,5 +464,5 @@
 	 */
 	if ((elf->flags & ELDF_RW) != 0)
-		return EE_OK;
+		return EOK;
 
 	DPRINTF("as_area_change_flags(%p, %x)\n",
@@ -494,5 +471,5 @@
 	if (rc != EOK) {
 		DPRINTF("Failed to set memory area flags.\n");
-		return EE_MEMORY;
+		return ENOMEM;
 	}
 
@@ -500,8 +477,8 @@
 		/* Enforce SMC coherence for the segment */
 		if (smc_coherence(seg_ptr, entry->p_filesz))
-			return EE_MEMORY;
-	}
-
-	return EE_OK;
+			return ENOMEM;
+	}
+
+	return EOK;
 }
 
Index: uspace/lib/c/generic/rtld/module.c
===================================================================
--- uspace/lib/c/generic/rtld/module.c	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ uspace/lib/c/generic/rtld/module.c	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -65,6 +65,8 @@
 
 	module = calloc(1, sizeof(module_t));
-	if (module == NULL)
+	if (module == NULL) {
+		DPRINTF("malloc failed\n");
 		return ENOMEM;
+	}
 
 	module->id = rtld_get_next_id(rtld);
@@ -182,9 +184,9 @@
 	char name_buf[NAME_BUF_SIZE];
 	module_t *m;
-	int rc;
+	errno_t rc;
 
 	m = calloc(1, sizeof(module_t));
 	if (m == NULL) {
-		printf("malloc failed\n");
+		DPRINTF("malloc failed\n");
 		goto error;
 	}
@@ -197,5 +199,5 @@
 
 	if (str_size(name) > NAME_BUF_SIZE - 2) {
-		printf("soname too long. increase NAME_BUF_SIZE\n");
+		DPRINTF("soname too long. increase NAME_BUF_SIZE\n");
 		goto error;
 	}
@@ -208,6 +210,6 @@
 
 	rc = elf_load_file_name(name_buf, RTLD_MODULE_LDF, &info);
-	if (rc != EE_OK) {
-		printf("Failed to load '%s'\n", name_buf);
+	if (rc != EOK) {
+		DPRINTF("Failed to load '%s'\n", name_buf);
 		goto error;
 	}
@@ -218,5 +220,5 @@
 
 	if (info.dynamic == NULL) {
-		printf("Error: '%s' is not a dynamically-linked object.\n",
+		DPRINTF("Error: '%s' is not a dynamically-linked object.\n",
 		    name_buf);
 		goto error;
@@ -285,5 +287,5 @@
 	m->deps = malloc(n * sizeof(module_t *));
 	if (!m->deps) {
-		printf("malloc failed\n");
+		DPRINTF("malloc failed\n");
 		return ENOMEM;
 	}
Index: uspace/lib/c/include/elf/elf_load.h
===================================================================
--- uspace/lib/c/include/elf/elf_load.h	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ uspace/lib/c/include/elf/elf_load.h	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -45,5 +45,5 @@
 } elf_info_t;
 
-extern int elf_load(int, elf_info_t *);
+extern errno_t elf_load(int, elf_info_t *);
 extern void elf_set_pcb(elf_info_t *, pcb_t *);
 
Index: uspace/lib/c/include/elf/elf_mod.h
===================================================================
--- uspace/lib/c/include/elf/elf_mod.h	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ uspace/lib/c/include/elf/elf_mod.h	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -42,15 +42,4 @@
 #include <stdint.h>
 #include <loader/pcb.h>
-
-/**
- * ELF error return codes
- */
-#define EE_OK			0	/* No error */
-#define EE_INVALID		1	/* Invalid ELF image */
-#define EE_MEMORY		2	/* Cannot allocate address space */
-#define EE_INCOMPATIBLE		3	/* ELF image is not compatible with current architecture */
-#define EE_UNSUPPORTED		4	/* Non-supported ELF (e.g. dynamic ELFs) */
-#define EE_IRRECOVERABLE	5
-#define EE_IO			6	/* Could not read file. */
 
 typedef enum {
@@ -110,7 +99,6 @@
 } elf_ld_t;
 
-extern const char *elf_error(unsigned int);
-extern int elf_load_file(int, eld_flags_t, elf_finfo_t *);
-extern int elf_load_file_name(const char *, eld_flags_t, elf_finfo_t *);
+extern errno_t elf_load_file(int, eld_flags_t, elf_finfo_t *);
+extern errno_t elf_load_file_name(const char *, eld_flags_t, elf_finfo_t *);
 
 #endif
Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision 985e0f158464dec99e0760a13f626453991d6c60)
+++ uspace/srv/loader/main.c	(revision 87bc11f722d98210560560c402918869124ed08e)
@@ -290,6 +290,6 @@
 	DPRINTF("LOADER_LOAD()\n");
 
-	int rc = elf_load(program_fd, &prog_info);
-	if (rc != EE_OK) {
+	errno_t rc = elf_load(program_fd, &prog_info);
+	if (rc != EOK) {
 		DPRINTF("Failed to load executable for '%s'.\n", progname);
 		async_answer_0(req, EINVAL);
