summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libexec/rtld-elf/libmap.c6
-rw-r--r--libexec/rtld-elf/map_object.c11
-rw-r--r--libexec/rtld-elf/rtld.c15
-rw-r--r--libexec/rtld-elf/rtld.h1
4 files changed, 22 insertions, 11 deletions
diff --git a/libexec/rtld-elf/libmap.c b/libexec/rtld-elf/libmap.c
index 92a0469..cf86703 100644
--- a/libexec/rtld-elf/libmap.c
+++ b/libexec/rtld-elf/libmap.c
@@ -71,20 +71,20 @@ lm_init(char *libmap_override)
fd = open(_PATH_LIBMAP_CONF, O_RDONLY);
if (fd == -1) {
dbg("lm_init: open(\"%s\") failed, %s", _PATH_LIBMAP_CONF,
- strerror(errno));
+ rtld_strerror(errno));
goto override;
}
if (fstat(fd, &st) == -1) {
close(fd);
dbg("lm_init: fstat(\"%s\") failed, %s", _PATH_LIBMAP_CONF,
- strerror(errno));
+ rtld_strerror(errno));
goto override;
}
lm_map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (lm_map == (const char *)MAP_FAILED) {
close(fd);
dbg("lm_init: mmap(\"%s\") failed, %s", _PATH_LIBMAP_CONF,
- strerror(errno));
+ rtld_strerror(errno));
goto override;
}
close(fd);
diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c
index f142819..9f4a499 100644
--- a/libexec/rtld-elf/map_object.c
+++ b/libexec/rtld-elf/map_object.c
@@ -184,7 +184,7 @@ map_object(int fd, const char *path, const struct stat *sb)
MAP_NOCORE, -1, 0);
if (mapbase == (caddr_t) -1) {
_rtld_error("%s: mmap of entire address space failed: %s",
- path, strerror(errno));
+ path, rtld_strerror(errno));
return NULL;
}
if (base_addr != NULL && mapbase != base_addr) {
@@ -204,7 +204,8 @@ map_object(int fd, const char *path, const struct stat *sb)
data_flags = convert_flags(segs[i]->p_flags) | MAP_FIXED;
if (mmap(data_addr, data_vlimit - data_vaddr, data_prot,
data_flags, fd, data_offset) == (caddr_t) -1) {
- _rtld_error("%s: mmap of data failed: %s", path, strerror(errno));
+ _rtld_error("%s: mmap of data failed: %s", path,
+ rtld_strerror(errno));
return NULL;
}
@@ -221,7 +222,7 @@ map_object(int fd, const char *path, const struct stat *sb)
if ((data_prot & PROT_WRITE) == 0 && -1 ==
mprotect(clear_page, PAGE_SIZE, data_prot|PROT_WRITE)) {
_rtld_error("%s: mprotect failed: %s", path,
- strerror(errno));
+ rtld_strerror(errno));
return NULL;
}
@@ -240,7 +241,7 @@ map_object(int fd, const char *path, const struct stat *sb)
if (mmap(bss_addr, bss_vlimit - bss_vaddr, data_prot,
data_flags | MAP_ANON, -1, 0) == (caddr_t)-1) {
_rtld_error("%s: mmap of bss failed: %s", path,
- strerror(errno));
+ rtld_strerror(errno));
return NULL;
}
}
@@ -307,7 +308,7 @@ get_elf_header (int fd, const char *path)
ssize_t nbytes;
if ((nbytes = pread(fd, u.buf, PAGE_SIZE, 0)) == -1) {
- _rtld_error("%s: read error: %s", path, strerror(errno));
+ _rtld_error("%s: read error: %s", path, rtld_strerror(errno));
return NULL;
}
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 1ca5ba0..3432232 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -2163,7 +2163,7 @@ relocate_objects(Obj_Entry *first, bool bind_now, Obj_Entry *rtldobj,
if (mprotect(obj->mapbase, obj->textsize,
PROT_READ|PROT_WRITE|PROT_EXEC) == -1) {
_rtld_error("%s: Cannot write-enable text segment: %s",
- obj->path, strerror(errno));
+ obj->path, rtld_strerror(errno));
return -1;
}
}
@@ -2176,7 +2176,7 @@ relocate_objects(Obj_Entry *first, bool bind_now, Obj_Entry *rtldobj,
if (mprotect(obj->mapbase, obj->textsize,
PROT_READ|PROT_EXEC) == -1) {
_rtld_error("%s: Cannot write-protect text segment: %s",
- obj->path, strerror(errno));
+ obj->path, rtld_strerror(errno));
return -1;
}
}
@@ -2196,7 +2196,7 @@ relocate_objects(Obj_Entry *first, bool bind_now, Obj_Entry *rtldobj,
if (obj->relro_size > 0) {
if (mprotect(obj->relro_page, obj->relro_size, PROT_READ) == -1) {
_rtld_error("%s: Cannot enforce relro protection: %s",
- obj->path, strerror(errno));
+ obj->path, rtld_strerror(errno));
return -1;
}
}
@@ -4353,3 +4353,12 @@ __chk_fail(void)
_rtld_error("buffer overflow detected; terminated");
die();
}
+
+const char *
+rtld_strerror(int errnum)
+{
+
+ if (errnum < 0 || errnum >= sys_nerr)
+ return ("Unknown error");
+ return (sys_errlist[errnum]);
+}
diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h
index 09d3dfc..9dfa0a2 100644
--- a/libexec/rtld-elf/rtld.h
+++ b/libexec/rtld-elf/rtld.h
@@ -313,6 +313,7 @@ typedef struct Struct_SymLook {
} SymLook;
extern void _rtld_error(const char *, ...) __printflike(1, 2);
+extern const char *rtld_strerror(int);
extern Obj_Entry *map_object(int, const char *, const struct stat *);
extern void *xcalloc(size_t);
extern void *xmalloc(size_t);
OpenPOWER on IntegriCloud