summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/rtld.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-03-14 15:39:59 +0000
committerkib <kib@FreeBSD.org>2012-03-14 15:39:59 +0000
commit6232e80d5b9d3267fc60990bf37056e5e44468d5 (patch)
tree6cb1f7004b97ad903055090950327ef825b31f96 /libexec/rtld-elf/rtld.c
parent2d6797921217c9d1d60d7950f1c8f104eb18b7ae (diff)
downloadFreeBSD-src-6232e80d5b9d3267fc60990bf37056e5e44468d5.zip
FreeBSD-src-6232e80d5b9d3267fc60990bf37056e5e44468d5.tar.gz
Rtld on diet 3.
Stop using strerror(3) in rtld, which brings in msgcat and stdio. Directly access sys_errlist array of errno messages with private rtld_strerror() function. Now, $ size /libexec/ld-elf.so.1 text data bss dec hex filename 96983 2480 8744 108207 1a6af /libexec/ld-elf.so.1 Reviewed by: dim, kan MFC after: 2 weeks
Diffstat (limited to 'libexec/rtld-elf/rtld.c')
-rw-r--r--libexec/rtld-elf/rtld.c15
1 files changed, 12 insertions, 3 deletions
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]);
+}
OpenPOWER on IntegriCloud