Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F155176121
D16530.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D16530.id.diff
View Options
Index: head/libexec/rtld-elf/malloc.c
===================================================================
--- head/libexec/rtld-elf/malloc.c
+++ head/libexec/rtld-elf/malloc.c
@@ -47,6 +47,7 @@
#include <sys/types.h>
#include <sys/sysctl.h>
+#include <errno.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
@@ -55,7 +56,9 @@
#include <unistd.h>
#include <sys/param.h>
#include <sys/mman.h>
+#include "rtld.h"
#include "rtld_printf.h"
+#include "paths.h"
static void morecore();
static int findbucket();
@@ -472,9 +475,11 @@
if (pagepool_end - pagepool_start > pagesz) {
caddr_t addr = (caddr_t)
(((long)pagepool_start + pagesz - 1) & ~(pagesz - 1));
- if (munmap(addr, pagepool_end - addr) != 0)
- rtld_fdprintf(STDERR_FILENO, "morepages: munmap %p",
- addr);
+ if (munmap(addr, pagepool_end - addr) != 0) {
+ rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": "
+ "morepages: cannot munmap %p: %s\n",
+ addr, rtld_strerror(errno));
+ }
}
offset = (long)pagepool_start - ((long)pagepool_start & ~(pagesz - 1));
@@ -482,7 +487,9 @@
if ((pagepool_start = mmap(0, n * pagesz,
PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, fd, 0)) == (caddr_t)-1) {
- rtld_printf("Cannot map anonymous memory\n");
+ rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": morepages: "
+ "cannot mmap anonymous memory: %s\n",
+ rtld_strerror(errno));
return 0;
}
pagepool_end = pagepool_start + n * pagesz;
Index: head/libexec/rtld-elf/paths.h
===================================================================
--- head/libexec/rtld-elf/paths.h
+++ head/libexec/rtld-elf/paths.h
@@ -34,7 +34,7 @@
#ifdef COMPAT_32BIT
#define _PATH_ELF_HINTS "/var/run/ld-elf32.so.hints"
#define _PATH_LIBMAP_CONF "/etc/libmap32.conf"
-#define _PATH_RTLD "/libexec/ld-elf32.so.1"
+#define _BASENAME_RTLD "ld-elf32.so.1"
#define STANDARD_LIBRARY_PATH "/lib32:/usr/lib32"
#define LD_ "LD_32_"
#endif
@@ -47,8 +47,12 @@
#define _PATH_LIBMAP_CONF "/etc/libmap.conf"
#endif
+#ifndef _BASENAME_RTLD
+#define _BASENAME_RTLD "ld-elf.so.1"
+#endif
+
#ifndef _PATH_RTLD
-#define _PATH_RTLD "/libexec/ld-elf.so.1"
+#define _PATH_RTLD "/libexec/" _BASENAME_RTLD
#endif
#ifndef STANDARD_LIBRARY_PATH
Index: head/libexec/rtld-elf/rtld.c
===================================================================
--- head/libexec/rtld-elf/rtld.c
+++ head/libexec/rtld-elf/rtld.c
@@ -408,8 +408,8 @@
phdr = (const Elf_Phdr *)aux_info[AT_PHDR]->a_un.a_ptr;
if (phdr == obj_rtld.phdr) {
if (!trust) {
- rtld_printf("Tainted process refusing to run binary %s\n",
- argv0);
+ _rtld_error("Tainted process refusing to run binary %s",
+ argv0);
rtld_die();
}
dbg("opening main program in direct exec mode");
@@ -420,7 +420,7 @@
if (!explicit_fd)
fd = open_binary_fd(argv0, search_in_path);
if (fstat(fd, &st) == -1) {
- _rtld_error("failed to fstat FD %d (%s): %s", fd,
+ _rtld_error("Failed to fstat FD %d (%s): %s", fd,
explicit_fd ? "user-provided descriptor" : argv0,
rtld_strerror(errno));
rtld_die();
@@ -447,8 +447,8 @@
dir_enable = true;
}
if (!dir_enable) {
- rtld_printf("No execute permission for binary %s\n",
- argv0);
+ _rtld_error("No execute permission for binary %s",
+ argv0);
rtld_die();
}
@@ -477,7 +477,7 @@
break;
}
} else {
- rtld_printf("no binary\n");
+ _rtld_error("No binary");
rtld_die();
}
}
@@ -962,6 +962,7 @@
if (msg == NULL)
msg = "Fatal error";
+ rtld_fdputstr(STDERR_FILENO, _BASENAME_RTLD ": ");
rtld_fdputstr(STDERR_FILENO, msg);
rtld_fdputchar(STDERR_FILENO, '\n');
_exit(1);
@@ -2441,7 +2442,7 @@
return NULL;
}
if (fs.f_flags & MNT_NOEXEC) {
- _rtld_error("Cannot execute objects on %s\n", fs.f_mntonname);
+ _rtld_error("Cannot execute objects on %s", fs.f_mntonname);
return NULL;
}
}
@@ -5317,12 +5318,12 @@
if (search_in_path && strchr(argv0, '/') == NULL) {
pathenv = getenv("PATH");
if (pathenv == NULL) {
- rtld_printf("-p and no PATH environment variable\n");
+ _rtld_error("-p and no PATH environment variable");
rtld_die();
}
pathenv = strdup(pathenv);
if (pathenv == NULL) {
- rtld_printf("Cannot allocate memory\n");
+ _rtld_error("Cannot allocate memory");
rtld_die();
}
fd = -1;
@@ -5348,8 +5349,7 @@
}
if (fd == -1) {
- rtld_printf("Opening %s: %s\n", argv0,
- rtld_strerror(errno));
+ _rtld_error("Cannot open %s: %s", argv0, rtld_strerror(errno));
rtld_die();
}
return (fd);
@@ -5393,7 +5393,7 @@
opt = arg[j];
if (opt == 'h') {
print_usage(argv[0]);
- rtld_die();
+ _exit(0);
} else if (opt == 'f') {
/*
* -f XX can be used to specify a descriptor for the
@@ -5403,13 +5403,13 @@
*/
if (j != arglen - 1) {
/* -f must be the last option in, e.g., -abcf */
- _rtld_error("invalid options: %s", arg);
+ _rtld_error("Invalid options: %s", arg);
rtld_die();
}
i++;
fd = parse_integer(argv[i]);
if (fd == -1) {
- _rtld_error("invalid file descriptor: '%s'",
+ _rtld_error("Invalid file descriptor: '%s'",
argv[i]);
rtld_die();
}
@@ -5418,7 +5418,7 @@
} else if (opt == 'p') {
*use_pathp = true;
} else {
- rtld_printf("invalid argument: '%s'\n", arg);
+ _rtld_error("Invalid argument: '%s'", arg);
print_usage(argv[0]);
rtld_die();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 2, 11:27 PM (4 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32633905
Default Alt Text
D16530.id.diff (5 KB)
Attached To
Mode
D16530: Make sure the rtld(1) error messages go to stderr, not stdout.
Attached
Detach File
Event Timeline
Log In to Comment