about summary refs log tree commit diff
path: root/elf/dl-tunables.h
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-12-06 10:24:01 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-12-19 13:25:45 -0300
commit2a969b53c0b02fed7e43473a92f219d737fd217a (patch)
treeb55eda5dc496c260e9757a5fc3856838d85b38fd /elf/dl-tunables.h
parent5275fc784c8113c84c85ca028ce621f68fe6642b (diff)
downloadglibc-2a969b53c0b02fed7e43473a92f219d737fd217a.tar.gz
glibc-2a969b53c0b02fed7e43473a92f219d737fd217a.tar.xz
glibc-2a969b53c0b02fed7e43473a92f219d737fd217a.zip
elf: Do not duplicate the GLIBC_TUNABLES string
The tunable parsing duplicates the tunable environment variable so it
null-terminates each one since it simplifies the later parsing. It has
the drawback of adding another point of failure (__minimal_malloc
failing), and the memory copy requires tuning the compiler to avoid mem
operations calls.

The parsing now tracks the tunable start and its size. The
dl-tunable-parse.h adds helper functions to help parsing, like a strcmp
that also checks for size and an iterator for suboptions that are
comma-separated (used on hwcap parsing by x86, powerpc, and s390x).

Since the environment variable is allocated on the stack by the kernel,
it is safe to keep the references to the suboptions for later parsing
of string tunables (as done by set_hwcaps by multiple architectures).

Checked on x86_64-linux-gnu, powerpc64le-linux-gnu, and
aarch64-linux-gnu.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'elf/dl-tunables.h')
-rw-r--r--elf/dl-tunables.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/elf/dl-tunables.h b/elf/dl-tunables.h
index 0df4dde24e..5d5ee2c3aa 100644
--- a/elf/dl-tunables.h
+++ b/elf/dl-tunables.h
@@ -30,7 +30,11 @@ typedef intmax_t tunable_num_t;
 typedef union
 {
   tunable_num_t numval;
-  const char *strval;
+  struct tunable_str_t
+  {
+    const char *str;
+    size_t len;
+  } strval;
 } tunable_val_t;
 
 typedef void (*tunable_callback_t) (tunable_val_t *);