[DTrace-devel] [PATCH] link: introduce -o linknommap
Kris Van Hees
kris.van.hees at oracle.com
Thu May 25 20:55:55 UTC 2023
On Tue, May 23, 2023 at 10:12:03PM +0100, Nick Alcock via DTrace-devel wrote:
> This option allows users of dtrace -G to force elfutils to not use
> mmap(), avoiding various bugs in elfutils which can break mmap() usage
> with large projects.
>
> It's rather horrible and (I hope) a stopgap we can eventually turn into
> a NOP.
>
> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
> libdtrace/dt_impl.h | 1 +
> libdtrace/dt_link.c | 3 ++-
> libdtrace/dt_options.c | 10 ++++++++++
> 3 files changed, 13 insertions(+), 1 deletion(-)
>
> This might work better (replacing the earlier patch).
>
> No test, because it's clear I don't actually have a way to provoke this
> to fail.
>
> diff --git a/libdtrace/dt_impl.h b/libdtrace/dt_impl.h
> index 581bb8a644e7c..6eedb8541dc73 100644
> --- a/libdtrace/dt_impl.h
> +++ b/libdtrace/dt_impl.h
> @@ -371,6 +371,7 @@ struct dtrace_hdl {
> uint_t dt_prcmode; /* dtrace process create mode (see dt_proc.h) */
> uint_t dt_linkmode; /* dtrace symbol linking mode (see below) */
> uint_t dt_linktype; /* dtrace link output file type (see below) */
> + uint_t dt_link_no_mmap; /* whether linking should avoid mmap() */
> uint_t dt_xlatemode; /* dtrace translator linking mode (see below) */
> uint_t dt_stdcmode; /* dtrace stdc compatibility mode (see below) */
> uint_t dt_treedump; /* dtrace tree debug bitmap (see below) */
> diff --git a/libdtrace/dt_link.c b/libdtrace/dt_link.c
> index a27ca7212b54c..b2148a8b21d6d 100644
> --- a/libdtrace/dt_link.c
> +++ b/libdtrace/dt_link.c
> @@ -1042,13 +1042,14 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
> key_t objkey;
> dt_link_pair_t *pair, *bufs = NULL;
> dt_strtab_t *strtab;
> + int flags = dtp->dt_link_no_mmap ? ELF_C_RDWR : ELF_C_RDWR_MMAP;
>
> if ((fd = open64(obj, O_RDWR)) == -1) {
> return dt_link_error(dtp, elf, fd, bufs,
> "failed to open %s: %s", obj, strerror(errno));
> }
>
> - if ((elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL)) == NULL) {
> + if ((elf = elf_begin(fd, flags, NULL)) == NULL) {
> return dt_link_error(dtp, elf, fd, bufs,
> "failed to process %s: %s", obj, elf_errmsg(elf_errno()));
> }
> diff --git a/libdtrace/dt_options.c b/libdtrace/dt_options.c
> index 1c32dc3d4c150..faa28268c5e67 100644
> --- a/libdtrace/dt_options.c
> +++ b/libdtrace/dt_options.c
> @@ -376,6 +376,15 @@ dt_opt_linktype(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
> return 0;
> }
>
> +/*ARGSUSED*/
> +static int
> +dt_opt_linknommap(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
> +{
> + dtp->dt_link_no_mmap = 1;
> +
> + return 0;
> +}
> +
> /*ARGSUSED*/
> static int
> dt_opt_module_path(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
> @@ -1095,6 +1104,7 @@ static const dt_option_t _dtrace_ctoptions[] = {
> { "libdir", dt_opt_libdir },
> { "linkmode", dt_opt_linkmode },
> { "linktype", dt_opt_linktype },
> + { "linknommap", dt_opt_linknommap },
> { "modpath", dt_opt_module_path },
> { "nolibs", dt_opt_cflags, DTRACE_C_NOLIBS },
> { "pgmax", dt_opt_pgmax },
>
> base-commit: f543fa6706c0b31364356c01bf3de63e3cce8ad1
> prerequisite-patch-id: fa667248b7b02e92ee6b3807123ebcf2ac0acc38
> prerequisite-patch-id: 0cec5f1a31d528a493d6143644c1e6b78c7f403b
> prerequisite-patch-id: 1e1ced5fcec01a0c2e38d12f1ae5a124c8f93860
> prerequisite-patch-id: eb290f098e38981181d85240150e1713979dc505
> prerequisite-patch-id: c25b38ab68e815a63f064aff7496408684f94a36
> prerequisite-patch-id: b86eb7e00b5883a586bd4dc7143ab25094912288
> prerequisite-patch-id: 85d3c176dc4a7105e4f04dbcdb4ccbdf18741795
> prerequisite-patch-id: 94206b53a67820bb1c9e828c11e57a0cb36949b6
> prerequisite-patch-id: c5a64d246ff26047723e5e1a9c16b42a1d5fbf87
> prerequisite-patch-id: 89cf4c6b9242525883ac02bb8ef90856ef908d0f
> prerequisite-patch-id: 0992642ac657a1da617588a6d7b28f3669960374
> prerequisite-patch-id: e8a65c309b3eaf3341ceac421ef602bcc3f057fa
> prerequisite-patch-id: 4d38462a4bf2b242f8fcec3bf28f1ad97fa40ca7
> prerequisite-patch-id: 6430030eaa9b5f09eedf6d41b698549096905c56
> prerequisite-patch-id: aefef52e1438f34dd49e0cde010e791d96ef06d9
> prerequisite-patch-id: f9ca834410ab770ec2d0b4f4f1ea70d5bea37c84
> prerequisite-patch-id: a2e41bc39d3eb5bea3c1543928d1a695320cce52
> prerequisite-patch-id: 5998403c58e4b48f0cb0d87971e553d2999421fc
> prerequisite-patch-id: 8766128335d133bdd548ed5978aa9eefeb6f7b6d
> prerequisite-patch-id: 35e83414bbe54be31fe7cc15c7d6368543cd4e8f
> prerequisite-patch-id: fe12afceb640e98f3e1c71915e005f114677b22c
> --
> 2.39.1.268.g9de2f9a303
>
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
More information about the DTrace-devel
mailing list