summaryrefslogtreecommitdiff
path: root/glibc/debugging/ld_so_console/dl-sysdep.c.patch
blob: eec8d7c6e363c24b984a910b5e536868b31143e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index ff37add..7e6d352 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -44,6 +44,8 @@
 #include <dl-machine.h>
 #include <dl-procinfo.h>
 
+#include <device/device.h>
+
 extern void __mach_init (void);
 
 extern int _dl_argc;
@@ -116,6 +118,29 @@ static void fmh(void) {
 /* XXX loser kludge for vm_map kernel bug */
 #endif
 
+/* Return a port to the Mach console.  */
+static mach_port_t
+get_console (void)
+{
+  mach_port_t device_master, console;
+  /* We cannot use __get_privileged_ports (from hurd/privports.c), as this
+     drags in too much other libc stuff.  */
+#if 0
+  error_t err = __get_privileged_ports (0, &device_master);
+
+  if (err)
+    return MACH_PORT_NULL;
+#else
+  error_t err = 0;
+  device_master = 2;
+#endif
+
+  err = __device_open (device_master, D_WRITE | D_READ, "console", &console);
+  if (err)
+    return MACH_PORT_NULL;
+
+  return console;
+}
 
 ElfW(Addr)
 _dl_sysdep_start (void **start_argptr,
@@ -256,6 +279,20 @@ unfmh();			/* XXX */
   /* Set up so we can do RPCs.  */
   __mach_init ();
 
+  /* Open the Mach console so that any message can actually be seen.  This is
+     particularly useful at boot time, when started by the bootstrap file
+     system.  */
+  mach_port_t console = get_console ();
+  if (console != MACH_PORT_NULL)
+    {
+      /* stdout = mach_open_devstream (console, "w"); */
+      /* stderr = stdout; */
+      /* if (stdout != NULL) */
+      /* 	printf ("Hello, world!\n"); */
+      int written;
+      __device_write_inband (console, 0, 0, "hello, world!\n", 14, &written);
+    }
+
   /* Initialize frequently used global variable.  */
   GLRO(dl_pagesize) = __getpagesize ();