author | Mike Sullivan <Mike.Sullivan@Oracle.COM> |
Mon, 06 Oct 2014 14:54:16 -0700 | |
branch | s11-update |
changeset 3371 | 4d8465c4afb8 |
parent 3072 | 1d751f6f8e9d |
child 1895 | 1f133713df64 |
child 5249 | 8a7aa7f8367e |
permissions | -rw-r--r-- |
3072
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
1 |
Changes needed to get stdbuf to successfully preload libstdbuf.so |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
2 |
for both 32-bit and 64-bit applications. See comment in the patch |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
3 |
for more details. |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
4 |
|
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
5 |
--- coreutils-8.16/src/stdbuf.c.orig 2013-09-04 19:05:35.225857588 -0700 |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
6 |
+++ coreutils-8.16/src/stdbuf.c 2013-09-04 19:11:51.945113130 -0700 |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
7 |
@@ -195,37 +195,13 @@ |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
8 |
gcc stdbuf.c -Wl,-rpath,'$ORIGIN' -Wl,-rpath,$PKGLIBEXECDIR |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
9 |
However we want the lookup done for the exec'd command not stdbuf. |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
10 |
|
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
11 |
- Since we don't link against libstdbuf.so add it to PKGLIBEXECDIR |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
12 |
- rather than to LIBDIR. */ |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
13 |
- char const *const search_path[] = { |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
14 |
- program_path, |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
15 |
- PKGLIBEXECDIR, |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
16 |
- NULL |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
17 |
- }; |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
18 |
+ Since we don't link against libstdbuf.so, we need to LD_PRELOAD it. |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
19 |
+ As libstdbuf.so lives in /usr/lib and /usr/lib/64, we just use |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
20 |
+ LD_PRELOAD=libstdbuf.so, and ld.so.1 finds the right one associated |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
21 |
+ with the process class. ie. we don't use full path names for the |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
22 |
+ preload names. */ |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
23 |
|
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
24 |
- char const *const *path = search_path; |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
25 |
- char *libstdbuf; |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
26 |
- |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
27 |
- while (true) |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
28 |
- { |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
29 |
- struct stat sb; |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
30 |
- |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
31 |
- if (!**path) /* system default */ |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
32 |
- { |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
33 |
- libstdbuf = xstrdup (LIB_NAME); |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
34 |
- break; |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
35 |
- } |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
36 |
- ret = asprintf (&libstdbuf, "%s/%s", *path, LIB_NAME); |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
37 |
- if (ret < 0) |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
38 |
- xalloc_die (); |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
39 |
- if (stat (libstdbuf, &sb) == 0) /* file_exists */ |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
40 |
- break; |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
41 |
- free (libstdbuf); |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
42 |
- |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
43 |
- ++path; |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
44 |
- if ( ! *path) |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
45 |
- error (EXIT_CANCELED, 0, _("failed to find %s"), quote (LIB_NAME)); |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
46 |
- } |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
47 |
+ char *libstdbuf = xstrdup (LIB_NAME); |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
48 |
|
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
49 |
/* FIXME: Do we need to support libstdbuf.dll, c:, '\' separators etc? */ |
1d751f6f8e9d
17408935 GNU coreutils should be 64-bit
Rich Burridge <rich.burridge@oracle.com>
parents:
diff
changeset
|
50 |