Skip to content
Snippets Groups Projects
Commit 29e26d3b authored by Rocky Automation's avatar Rocky Automation :tv:
Browse files

import glibc-2.28-151.el8

parent 6d8f86a7
No related branches found
No related tags found
No related merge requests found
Showing
with 4952 additions and 0 deletions
commit 583dd860d5b833037175247230a328f0050dbfe9
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon Jan 21 11:08:13 2019 -0800
regex: fix read overrun [BZ #24114]
Problem found by AddressSanitizer, reported by Hongxu Chen in:
https://debbugs.gnu.org/34140
* posix/regexec.c (proceed_next_node):
Do not read past end of input buffer.
diff --git a/posix/regexec.c b/posix/regexec.c
index 73644c2341336e66..06b8487c3e3eab0e 100644
--- a/posix/regexec.c
+++ b/posix/regexec.c
@@ -1289,8 +1289,10 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
else if (naccepted)
{
char *buf = (char *) re_string_get_buffer (&mctx->input);
- if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
- naccepted) != 0)
+ if (mctx->input.valid_len - *pidx < naccepted
+ || (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
+ naccepted)
+ != 0))
return -1;
}
}
This diff is collapsed.
commit 7d4ec75e111291851620c6aa2c4460647b7fd50d
Author: Arjun Shankar <arjun@redhat.com>
Date: Fri Sep 25 14:47:06 2020 +0200
intl: Handle translation output codesets with suffixes [BZ #26383]
Commit 91927b7c7643 (Rewrite iconv option parsing [BZ #19519]) did not
handle cases where the output codeset for translations (via the `gettext'
family of functions) might have a caller specified encoding suffix such as
TRANSLIT or IGNORE. This led to a regression where translations did not
work when the codeset had a suffix.
This commit fixes the above issue by parsing any suffixes passed to
__dcigettext and adds two new test-cases to intl/tst-codeset.c to
verify correct behaviour. The iconv-internal function __gconv_create_spec
and the static iconv-internal function gconv_destroy_spec are now visible
internally within glibc and used in intl/dcigettext.c.
diff --git a/iconv/Versions b/iconv/Versions
index 8a5f4cf780b18925..d51af52fa34b8793 100644
--- a/iconv/Versions
+++ b/iconv/Versions
@@ -6,7 +6,9 @@ libc {
GLIBC_PRIVATE {
# functions shared with iconv program
__gconv_get_alias_db; __gconv_get_cache; __gconv_get_modules_db;
- __gconv_open; __gconv_create_spec;
+
+ # functions used elsewhere in glibc
+ __gconv_open; __gconv_create_spec; __gconv_destroy_spec;
# function used by the gconv modules
__gconv_transliterate;
diff --git a/iconv/gconv_charset.c b/iconv/gconv_charset.c
index 6ccd0773ccb6cd27..4ba0aa99f5dae7f7 100644
--- a/iconv/gconv_charset.c
+++ b/iconv/gconv_charset.c
@@ -216,3 +216,13 @@ out:
return ret;
}
libc_hidden_def (__gconv_create_spec)
+
+
+void
+__gconv_destroy_spec (struct gconv_spec *conv_spec)
+{
+ free (conv_spec->fromcode);
+ free (conv_spec->tocode);
+ return;
+}
+libc_hidden_def (__gconv_destroy_spec)
diff --git a/iconv/gconv_charset.h b/iconv/gconv_charset.h
index b85d80313030b649..4b98073389bd8707 100644
--- a/iconv/gconv_charset.h
+++ b/iconv/gconv_charset.h
@@ -48,33 +48,6 @@
#define GCONV_IGNORE_ERRORS_SUFFIX "IGNORE"
-/* This function accepts the charset names of the source and destination of the
- conversion and populates *conv_spec with an equivalent conversion
- specification that may later be used by __gconv_open. The charset names
- might contain options in the form of suffixes that alter the conversion,
- e.g. "ISO-10646/UTF-8/TRANSLIT". It processes the charset names, ignoring
- and truncating any suffix options in fromcode, and processing and truncating
- any suffix options in tocode. Supported suffix options ("TRANSLIT" or
- "IGNORE") when found in tocode lead to the corresponding flag in *conv_spec
- to be set to true. Unrecognized suffix options are silently discarded. If
- the function succeeds, it returns conv_spec back to the caller. It returns
- NULL upon failure. */
-struct gconv_spec *
-__gconv_create_spec (struct gconv_spec *conv_spec, const char *fromcode,
- const char *tocode);
-libc_hidden_proto (__gconv_create_spec)
-
-
-/* This function frees all heap memory allocated by __gconv_create_spec. */
-static void __attribute__ ((unused))
-gconv_destroy_spec (struct gconv_spec *conv_spec)
-{
- free (conv_spec->fromcode);
- free (conv_spec->tocode);
- return;
-}
-
-
/* This function copies in-order, characters from the source 's' that are
either alpha-numeric or one in one of these: "_-.,:/" - into the destination
'wp' while dropping all other characters. In the process, it converts all
diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h
index 4748e9b1fa3b5426..8067a341b0903e1b 100644
--- a/iconv/gconv_int.h
+++ b/iconv/gconv_int.h
@@ -170,6 +170,27 @@ extern int __gconv_open (struct gconv_spec *conv_spec,
__gconv_t *handle, int flags);
libc_hidden_proto (__gconv_open)
+/* This function accepts the charset names of the source and destination of the
+ conversion and populates *conv_spec with an equivalent conversion
+ specification that may later be used by __gconv_open. The charset names
+ might contain options in the form of suffixes that alter the conversion,
+ e.g. "ISO-10646/UTF-8/TRANSLIT". It processes the charset names, ignoring
+ and truncating any suffix options in fromcode, and processing and truncating
+ any suffix options in tocode. Supported suffix options ("TRANSLIT" or
+ "IGNORE") when found in tocode lead to the corresponding flag in *conv_spec
+ to be set to true. Unrecognized suffix options are silently discarded. If
+ the function succeeds, it returns conv_spec back to the caller. It returns
+ NULL upon failure. */
+extern struct gconv_spec *
+__gconv_create_spec (struct gconv_spec *conv_spec, const char *fromcode,
+ const char *tocode);
+libc_hidden_proto (__gconv_create_spec)
+
+/* This function frees all heap memory allocated by __gconv_create_spec. */
+extern void
+__gconv_destroy_spec (struct gconv_spec *conv_spec);
+libc_hidden_proto (__gconv_destroy_spec)
+
/* Free resources associated with transformation descriptor CD. */
extern int __gconv_close (__gconv_t cd)
attribute_hidden;
diff --git a/iconv/iconv_open.c b/iconv/iconv_open.c
index 59d1ef4f07ed1022..46da33bca6c24af0 100644
--- a/iconv/iconv_open.c
+++ b/iconv/iconv_open.c
@@ -39,7 +39,7 @@ iconv_open (const char *tocode, const char *fromcode)
int res = __gconv_open (&conv_spec, &cd, 0);
- gconv_destroy_spec (&conv_spec);
+ __gconv_destroy_spec (&conv_spec);
if (__builtin_expect (res, __GCONV_OK) != __GCONV_OK)
{
diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c
index 552efac81660e82a..e26e9d02ca4121a7 100644
--- a/iconv/iconv_prog.c
+++ b/iconv/iconv_prog.c
@@ -184,7 +184,7 @@ main (int argc, char *argv[])
/* Let's see whether we have these coded character sets. */
res = __gconv_open (&conv_spec, &cd, 0);
- gconv_destroy_spec (&conv_spec);
+ __gconv_destroy_spec (&conv_spec);
if (res != __GCONV_OK)
{
diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index ed48fc8d3e96c7ba..7ebe67b4ac2113e9 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -1121,15 +1121,18 @@ _nl_find_msg (struct loaded_l10nfile *domain_file,
# ifdef _LIBC
- struct gconv_spec conv_spec
- = { .fromcode = norm_add_slashes (charset, ""),
- .tocode = norm_add_slashes (outcharset, ""),
- /* We always want to use transliteration. */
- .translit = true,
- .ignore = false
- };
+ struct gconv_spec conv_spec;
+
+ __gconv_create_spec (&conv_spec, charset, outcharset);
+
+ /* We always want to use transliteration. */
+ conv_spec.translit = true;
+
int r = __gconv_open (&conv_spec, &convd->conv,
GCONV_AVOID_NOCONV);
+
+ __gconv_destroy_spec (&conv_spec);
+
if (__builtin_expect (r != __GCONV_OK, 0))
{
/* If the output encoding is the same there is
diff --git a/intl/tst-codeset.c b/intl/tst-codeset.c
index e71382aeeeca477b..52e4aaa6ffd3afdb 100644
--- a/intl/tst-codeset.c
+++ b/intl/tst-codeset.c
@@ -22,13 +22,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <support/check.h>
static int
do_test (void)
{
- char *s;
- int result = 0;
-
unsetenv ("LANGUAGE");
unsetenv ("OUTPUT_CHARSET");
setlocale (LC_ALL, "de_DE.ISO-8859-1");
@@ -36,25 +34,21 @@ do_test (void)
bindtextdomain ("codeset", OBJPFX "domaindir");
/* Here we expect output in ISO-8859-1. */
- s = gettext ("cheese");
- if (strcmp (s, "K\344se"))
- {
- printf ("call 1 returned: %s\n", s);
- result = 1;
- }
+ TEST_COMPARE_STRING (gettext ("cheese"), "K\344se");
+ /* Here we expect output in UTF-8. */
bind_textdomain_codeset ("codeset", "UTF-8");
+ TEST_COMPARE_STRING (gettext ("cheese"), "K\303\244se");
- /* Here we expect output in UTF-8. */
- s = gettext ("cheese");
- if (strcmp (s, "K\303\244se"))
- {
- printf ("call 2 returned: %s\n", s);
- result = 1;
- }
-
- return result;
+ /* `a with umlaut' is transliterated to `ae'. */
+ bind_textdomain_codeset ("codeset", "ASCII//TRANSLIT");
+ TEST_COMPARE_STRING (gettext ("cheese"), "Kaese");
+
+ /* Transliteration also works by default even if not set. */
+ bind_textdomain_codeset ("codeset", "ASCII");
+ TEST_COMPARE_STRING (gettext ("cheese"), "Kaese");
+
+ return 0;
}
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
commit 9a99c682144bdbd40792ebf822fe9264e0376fb5
Author: Arjun Shankar <arjun@redhat.com>
Date: Wed Nov 4 12:19:38 2020 +0100
iconv: Accept redundant shift sequences in IBM1364 [BZ #26224]
The IBM1364, IBM1371, IBM1388, IBM1390 and IBM1399 character sets
share converter logic (iconvdata/ibm1364.c) which would reject
redundant shift sequences when processing input in these character
sets. This led to a hang in the iconv program (CVE-2020-27618).
This commit adjusts the converter to ignore redundant shift sequences
and adds test cases for iconv_prog hangs that would be triggered upon
their rejection. This brings the implementation in line with other
converters that also ignore redundant shift sequences (e.g. IBM930
etc., fixed in commit 692de4b3960d).
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/iconv/tst-iconv_prog.sh b/iconv/tst-iconv_prog.sh
index 8298136b7f45d855..d8db7b335c1fcca2 100644
--- a/iconv/tst-iconv_prog.sh
+++ b/iconv/tst-iconv_prog.sh
@@ -102,12 +102,16 @@ hangarray=(
"\x00\x80;-c;IBM1161;UTF-8//TRANSLIT//IGNORE"
"\x00\xdb;-c;IBM1162;UTF-8//TRANSLIT//IGNORE"
"\x00\x70;-c;IBM12712;UTF-8//TRANSLIT//IGNORE"
-# These are known hangs that are yet to be fixed:
-# "\x00\x0f;-c;IBM1364;UTF-8"
-# "\x00\x0f;-c;IBM1371;UTF-8"
-# "\x00\x0f;-c;IBM1388;UTF-8"
-# "\x00\x0f;-c;IBM1390;UTF-8"
-# "\x00\x0f;-c;IBM1399;UTF-8"
+"\x00\x0f;-c;IBM1364;UTF-8"
+"\x0e\x0e;-c;IBM1364;UTF-8"
+"\x00\x0f;-c;IBM1371;UTF-8"
+"\x0e\x0e;-c;IBM1371;UTF-8"
+"\x00\x0f;-c;IBM1388;UTF-8"
+"\x0e\x0e;-c;IBM1388;UTF-8"
+"\x00\x0f;-c;IBM1390;UTF-8"
+"\x0e\x0e;-c;IBM1390;UTF-8"
+"\x00\x0f;-c;IBM1399;UTF-8"
+"\x0e\x0e;-c;IBM1399;UTF-8"
"\x00\x53;-c;IBM16804;UTF-8//TRANSLIT//IGNORE"
"\x00\x41;-c;IBM274;UTF-8//TRANSLIT//IGNORE"
"\x00\x41;-c;IBM275;UTF-8//TRANSLIT//IGNORE"
diff --git a/iconvdata/ibm1364.c b/iconvdata/ibm1364.c
index 517fe60813be0472..ecc3f8ddddbdbc8c 100644
--- a/iconvdata/ibm1364.c
+++ b/iconvdata/ibm1364.c
@@ -158,24 +158,14 @@ enum
\
if (__builtin_expect (ch, 0) == SO) \
{ \
- /* Shift OUT, change to DBCS converter. */ \
- if (curcs == db) \
- { \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ /* Shift OUT, change to DBCS converter (redundant escape okay). */ \
curcs = db; \
++inptr; \
continue; \
} \
if (__builtin_expect (ch, 0) == SI) \
{ \
- /* Shift IN, change to SBCS converter. */ \
- if (curcs == sb) \
- { \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
+ /* Shift IN, change to SBCS converter (redundant escape okay). */ \
curcs = sb; \
++inptr; \
continue; \
commit cce35a50c1de0cec5cd1f6c18979ff6ee3ea1dd1
Author: Arjun Shankar <arjun@redhat.com>
Date: Mon Nov 11 14:57:23 2019 +0100
support: Add xsetlocale function
diff --git a/support/Makefile b/support/Makefile
index 37d5dcc92a5c6dee..6afaa6836c944398 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -148,6 +148,7 @@ libsupport-routines = \
xrealloc \
xrecvfrom \
xsendto \
+ xsetlocale \
xsetsockopt \
xsigaction \
xsignal \
diff --git a/support/support.h b/support/support.h
index 61a10c34982134ff..97d142e9b6f68188 100644
--- a/support/support.h
+++ b/support/support.h
@@ -91,6 +91,7 @@ char *xasprintf (const char *format, ...)
__attribute__ ((format (printf, 1, 2), malloc));
char *xstrdup (const char *);
char *xstrndup (const char *, size_t);
+char *xsetlocale (int category, const char *locale);
/* These point to the TOP of the source/build tree, not your (or
support's) subdirectory. */
diff --git a/support/xsetlocale.c b/support/xsetlocale.c
new file mode 100644
index 0000000000000000..063ed4b0d63af884
--- /dev/null
+++ b/support/xsetlocale.c
@@ -0,0 +1,30 @@
+/* setlocale with error checking.
+ Copyright (C) 2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+
+#include <locale.h>
+
+char *
+xsetlocale (int category, const char *locale)
+{
+ char *p = setlocale (category, locale);
+ if (p == NULL)
+ FAIL_EXIT1 ("error: setlocale (%d, \"%s\")\n", category, locale);
+ return p;
+}
The patch (glibc-rh1704868-1.patch) for commit 91927b7c7643
(Rewrite iconv option parsing) contains a test that depends on
commit 513aaa0d782f (Add Transliterations for Unicode Misc.
Mathematical Symbols-A/B), which is not applied in RHEL-8. This
patch edits the test so as not to depend on the unapplied patch
and its additional transliterations.
diff --git a/iconv/tst-iconv-opt.c b/iconv/tst-iconv-opt.c
index 669d812a6a9b8749..21e6d887501450a7 100644
--- a/iconv/tst-iconv-opt.c
+++ b/iconv/tst-iconv-opt.c
@@ -82,18 +82,18 @@ char u2a_ignore[] = "UTF-8 text with couple f non-ASCII characters";
/* 3. Invalid UTF-8 input and some corresponding expected outputs. \xff is
invalid UTF-8. It's followed by some valid but non-ASCII UTF-8. */
-char iutf8[] = "Invalid UTF-8 \xff\u27E6text\u27E7";
+char iutf8[] = "Invalid UTF-8 \xff\u00B7text\u00B7";
char iu2a[] = "Invalid UTF-8 ";
char iu2a_ignore[] = "Invalid UTF-8 text";
-char iu2a_both[] = "Invalid UTF-8 [|text|]";
+char iu2a_both[] = "Invalid UTF-8 .text.";
/* 4. Another invalid UTF-8 input and corresponding expected outputs. This time
the valid non-ASCII UTF-8 characters appear before the invalid \xff. */
-char jutf8[] = "Invalid \u27E6UTF-8\u27E7 \xfftext";
+char jutf8[] = "Invalid \u00B7UTF-8\u00B7 \xfftext";
char ju2a[] = "Invalid ";
-char ju2a_translit[] = "Invalid [|UTF-8|] ";
+char ju2a_translit[] = "Invalid .UTF-8. ";
char ju2a_ignore[] = "Invalid UTF-8 text";
-char ju2a_both[] = "Invalid [|UTF-8|] text";
+char ju2a_both[] = "Invalid .UTF-8. text";
/* We also test option handling for character set names that have the form
"A/B". In this test, we test conversions "ISO-10646/UTF-8", and either
commit 82c80ac2ebf9acc81ec460adfd951d4884836c7c
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Aug 1 04:57:34 2018 -0700
x86: Rename get_common_indeces to get_common_indices
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* sysdeps/x86/cpu-features.c (get_common_indeces): Renamed to
...
(get_common_indices): This.
(init_cpu_features): Updated.
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index ac74f408343191b0..41f2d15fa5c8a756 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -56,7 +56,7 @@ get_extended_indices (struct cpu_features *cpu_features)
}
static void
-get_common_indeces (struct cpu_features *cpu_features,
+get_common_indices (struct cpu_features *cpu_features,
unsigned int *family, unsigned int *model,
unsigned int *extended_model, unsigned int *stepping)
{
@@ -234,7 +234,7 @@ init_cpu_features (struct cpu_features *cpu_features)
kind = arch_kind_intel;
- get_common_indeces (cpu_features, &family, &model, &extended_model,
+ get_common_indices (cpu_features, &family, &model, &extended_model,
&stepping);
get_extended_indices (cpu_features);
@@ -356,7 +356,7 @@ init_cpu_features (struct cpu_features *cpu_features)
kind = arch_kind_amd;
- get_common_indeces (cpu_features, &family, &model, &extended_model,
+ get_common_indices (cpu_features, &family, &model, &extended_model,
&stepping);
get_extended_indices (cpu_features);
@@ -393,7 +393,7 @@ init_cpu_features (struct cpu_features *cpu_features)
else
{
kind = arch_kind_other;
- get_common_indeces (cpu_features, NULL, NULL, NULL, NULL);
+ get_common_indices (cpu_features, NULL, NULL, NULL, NULL);
}
/* Support i586 if CX8 is available. */
commit 2dd8e58cc533ee840d37725b11bc0dc0308a5dc0
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun Oct 21 00:37:11 2018 -0700
x86: Don't include <x86intrin.h>
Use __builtin_ia32_rdtsc directly since including <x86intrin.h> makes
building glibc very slow. On Intel Core i5-6260U, this patch reduces
x86-64 build time from 8 minutes 33 seconds to 3 minutes 48 seconds
with "make -j4" and GCC 8.2.1.
* sysdeps/x86/hp-timing.h: Don't include <x86intrin.h>.
(HP_TIMING_NOW): Replace _rdtsc with __builtin_ia32_rdtsc.
diff --git a/sysdeps/x86/hp-timing.h b/sysdeps/x86/hp-timing.h
index 1c20e9d8289cc15b..77a1360748ca4535 100644
--- a/sysdeps/x86/hp-timing.h
+++ b/sysdeps/x86/hp-timing.h
@@ -22,8 +22,6 @@
#include <isa.h>
#if MINIMUM_ISA == 686 || MINIMUM_ISA == 8664
-# include <x86intrin.h>
-
/* We always assume having the timestamp register. */
# define HP_TIMING_AVAIL (1)
# define HP_SMALL_TIMING_AVAIL (1)
@@ -38,8 +36,11 @@ typedef unsigned long long int hp_timing_t;
might not be 100% accurate since there might be some more instructions
running in this moment. This could be changed by using a barrier like
'cpuid' right before the `rdtsc' instruciton. But we are not interested
- in accurate clock cycles here so we don't do this. */
-# define HP_TIMING_NOW(Var) ((Var) = _rdtsc ())
+ in accurate clock cycles here so we don't do this.
+
+ NB: Use __builtin_ia32_rdtsc directly since including <x86intrin.h>
+ makes building glibc very slow. */
+# define HP_TIMING_NOW(Var) ((Var) = __builtin_ia32_rdtsc ())
# include <hp-timing-common.h>
#else
commit bb5fd5ce64b598085bdb8a05cb53777480fe093c
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Oct 9 10:13:14 2020 +0200
elf: Do not pass GLRO(dl_platform), GLRO(dl_platformlen) to _dl_important_hwcaps
In the current code, the function can easily obtain the information
on its own.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
diff --git a/elf/dl-hwcaps.c b/elf/dl-hwcaps.c
index ae2e4ca7fe91d407..82ee89c36a1eb4ab 100644
--- a/elf/dl-hwcaps.c
+++ b/elf/dl-hwcaps.c
@@ -28,13 +28,12 @@
/* Return an array of useful/necessary hardware capability names. */
const struct r_strlenpair *
-_dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
- size_t *max_capstrlen)
+_dl_important_hwcaps (size_t *sz, size_t *max_capstrlen)
{
uint64_t hwcap_mask = GET_HWCAP_MASK();
/* Determine how many important bits are set. */
uint64_t masked = GLRO(dl_hwcap) & hwcap_mask;
- size_t cnt = platform != NULL;
+ size_t cnt = GLRO (dl_platform) != NULL;
size_t n, m;
size_t total;
struct r_strlenpair *result;
@@ -60,10 +59,10 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
masked ^= 1ULL << n;
++m;
}
- if (platform != NULL)
+ if (GLRO (dl_platform) != NULL)
{
- temp[m].str = platform;
- temp[m].len = platform_len;
+ temp[m].str = GLRO (dl_platform);
+ temp[m].len = GLRO (dl_platformlen);
++m;
}
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 2eb4f35b2467f7d8..d2be21ea7d1545fe 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -697,8 +697,7 @@ _dl_init_paths (const char *llp, const char *source)
#ifdef SHARED
/* Get the capabilities. */
- capstr = _dl_important_hwcaps (GLRO(dl_platform), GLRO(dl_platformlen),
- &ncapstr, &max_capstrlen);
+ capstr = _dl_important_hwcaps (&ncapstr, &max_capstrlen);
#endif
/* First set up the rest of the default search directory entries. */
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index aa006afafaf46dee..2c9fdeb286bdaadf 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -1069,12 +1069,12 @@ extern void _dl_show_auxv (void) attribute_hidden;
other. */
extern char *_dl_next_ld_env_entry (char ***position) attribute_hidden;
-/* Return an array with the names of the important hardware capabilities. */
-extern const struct r_strlenpair *_dl_important_hwcaps (const char *platform,
- size_t paltform_len,
- size_t *sz,
- size_t *max_capstrlen)
- attribute_hidden;
+/* Return an array with the names of the important hardware
+ capabilities. The length of the array is written to *SZ, and the
+ maximum of all strings length is written to *MAX_CAPSTRLEN. */
+const struct r_strlenpair *_dl_important_hwcaps (size_t *sz,
+ size_t *max_capstrlen)
+ attribute_hidden;
/* Look up NAME in ld.so.cache and return the file name stored there,
or null if none is found. Caller must free returned string. */
commit 7674695cf7e28528be7243ceb30c9a600bbaa7b5
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Oct 8 08:19:15 2020 -0700
<sys/platform/x86.h>: Add Intel UINTR support
Add Intel UINTR support to <sys/platform/x86.h>.
diff --git a/manual/platform.texi b/manual/platform.texi
index 95b0ed0642c9f8a9..0dd12a4353a93bf2 100644
--- a/manual/platform.texi
+++ b/manual/platform.texi
@@ -583,6 +583,9 @@ using a TSC deadline value.
@item
@code{TSXLDTRK} -- TSXLDTRK instructions.
+@item
+@code{UINTR} -- User interrupts.
+
@item
@code{UMIP} -- User-mode instruction prevention.
diff --git a/sysdeps/x86/sys/platform/x86.h b/sysdeps/x86/sys/platform/x86.h
index bcc81ab5f8ac8265..2760b81a56e6c7d7 100644
--- a/sysdeps/x86/sys/platform/x86.h
+++ b/sysdeps/x86/sys/platform/x86.h
@@ -241,7 +241,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
#define bit_cpu_AVX512_4VNNIW (1u << 2)
#define bit_cpu_AVX512_4FMAPS (1u << 3)
#define bit_cpu_FSRM (1u << 4)
-#define bit_cpu_INDEX_7_EDX_5 (1u << 5)
+#define bit_cpu_UINTR (1u << 5)
#define bit_cpu_INDEX_7_EDX_6 (1u << 6)
#define bit_cpu_INDEX_7_EDX_7 (1u << 7)
#define bit_cpu_AVX512_VP2INTERSECT (1u << 8)
@@ -460,7 +460,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
#define index_cpu_AVX512_4VNNIW COMMON_CPUID_INDEX_7
#define index_cpu_AVX512_4FMAPS COMMON_CPUID_INDEX_7
#define index_cpu_FSRM COMMON_CPUID_INDEX_7
-#define index_cpu_INDEX_7_EDX_5 COMMON_CPUID_INDEX_7
+#define index_cpu_UINTR COMMON_CPUID_INDEX_7
#define index_cpu_INDEX_7_EDX_6 COMMON_CPUID_INDEX_7
#define index_cpu_INDEX_7_EDX_7 COMMON_CPUID_INDEX_7
#define index_cpu_AVX512_VP2INTERSECT COMMON_CPUID_INDEX_7
@@ -679,7 +679,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
#define reg_AVX512_4VNNIW edx
#define reg_AVX512_4FMAPS edx
#define reg_FSRM edx
-#define reg_INDEX_7_EDX_5 edx
+#define reg_UINTR edx
#define reg_INDEX_7_EDX_6 edx
#define reg_INDEX_7_EDX_7 edx
#define reg_AVX512_VP2INTERSECT edx
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
index 3ec94e0c9a191f36..6fa092a8c10486a0 100644
--- a/sysdeps/x86/tst-get-cpu-features.c
+++ b/sysdeps/x86/tst-get-cpu-features.c
@@ -180,6 +180,7 @@ do_test (void)
CHECK_CPU_FEATURE (AVX512_4VNNIW);
CHECK_CPU_FEATURE (AVX512_4FMAPS);
CHECK_CPU_FEATURE (FSRM);
+ CHECK_CPU_FEATURE (UINTR);
CHECK_CPU_FEATURE (AVX512_VP2INTERSECT);
CHECK_CPU_FEATURE (MD_CLEAR);
CHECK_CPU_FEATURE (SERIALIZE);
commit ebe454bcca6a5421512ad228595a5391506e990a
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Oct 8 08:24:47 2020 -0700
<sys/platform/x86.h>: Add AVX512_FP16 support
Add AVX512_FP16 support to <sys/platform/x86.h>.
diff --git a/manual/platform.texi b/manual/platform.texi
index 0dd12a4353a93bf2..4f5fdff9d9ef16fd 100644
--- a/manual/platform.texi
+++ b/manual/platform.texi
@@ -210,6 +210,9 @@ The supported processor features are:
@item
@code{AVX512_BITALG} -- The AVX512_BITALG instruction extensions.
+@item
+@code{AVX512_FP16} -- The AVX512_FP16 instruction extensions.
+
@item
@code{AVX512_IFMA} -- The AVX512_IFMA instruction extensions.
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 7f2ff00f2b4b45f2..67f137259fccf4ad 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -175,6 +175,8 @@ update_usable (struct cpu_features *cpu_features)
AVX512_VP2INTERSECT);
/* Determine if AVX512_BF16 is usable. */
CPU_FEATURE_SET_USABLE (cpu_features, AVX512_BF16);
+ /* Determine if AVX512_FP16 is usable. */
+ CPU_FEATURE_SET_USABLE (cpu_features, AVX512_FP16);
}
}
}
diff --git a/sysdeps/x86/sys/platform/x86.h b/sysdeps/x86/sys/platform/x86.h
index 2760b81a56e6c7d7..0b18257e20105ea4 100644
--- a/sysdeps/x86/sys/platform/x86.h
+++ b/sysdeps/x86/sys/platform/x86.h
@@ -259,7 +259,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
#define bit_cpu_IBT (1u << 20)
#define bit_cpu_INDEX_7_EDX_21 (1u << 21)
#define bit_cpu_AMX_BF16 (1u << 22)
-#define bit_cpu_INDEX_7_EDX_23 (1u << 23)
+#define bit_cpu_AVX512_FP16 (1u << 23)
#define bit_cpu_AMX_TILE (1u << 24)
#define bit_cpu_AMX_INT8 (1u << 25)
#define bit_cpu_IBRS_IBPB (1u << 26)
@@ -478,7 +478,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
#define index_cpu_IBT COMMON_CPUID_INDEX_7
#define index_cpu_INDEX_7_EDX_21 COMMON_CPUID_INDEX_7
#define index_cpu_AMX_BF16 COMMON_CPUID_INDEX_7
-#define index_cpu_INDEX_7_EDX_23 COMMON_CPUID_INDEX_7
+#define index_cpu_AVX512_FP16 COMMON_CPUID_INDEX_7
#define index_cpu_AMX_TILE COMMON_CPUID_INDEX_7
#define index_cpu_AMX_INT8 COMMON_CPUID_INDEX_7
#define index_cpu_IBRS_IBPB COMMON_CPUID_INDEX_7
@@ -697,7 +697,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
#define reg_IBT edx
#define reg_INDEX_7_EDX_21 edx
#define reg_AMX_BF16 edx
-#define reg_INDEX_7_EDX_23 edx
+#define reg_AVX512_FP16 edx
#define reg_AMX_TILE edx
#define reg_AMX_INT8 edx
#define reg_IBRS_IBPB edx
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
index 6fa092a8c10486a0..bcdeb243a82c4adc 100644
--- a/sysdeps/x86/tst-get-cpu-features.c
+++ b/sysdeps/x86/tst-get-cpu-features.c
@@ -189,6 +189,7 @@ do_test (void)
CHECK_CPU_FEATURE (PCONFIG);
CHECK_CPU_FEATURE (IBT);
CHECK_CPU_FEATURE (AMX_BF16);
+ CHECK_CPU_FEATURE (AVX512_FP16);
CHECK_CPU_FEATURE (AMX_TILE);
CHECK_CPU_FEATURE (AMX_INT8);
CHECK_CPU_FEATURE (IBRS_IBPB);
@@ -343,6 +344,7 @@ do_test (void)
CHECK_CPU_FEATURE_USABLE (TSXLDTRK);
CHECK_CPU_FEATURE_USABLE (PCONFIG);
CHECK_CPU_FEATURE_USABLE (AMX_BF16);
+ CHECK_CPU_FEATURE_USABLE (AVX512_FP16);
CHECK_CPU_FEATURE_USABLE (AMX_TILE);
CHECK_CPU_FEATURE_USABLE (AMX_INT8);
CHECK_CPU_FEATURE_USABLE (IBRS_IBPB);
commit 875a50ff63b2c86af770949d563ee851d08eb46e
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Oct 8 08:33:45 2020 -0700
<sys/platform/x86.h>: Add AVX-VNNI support
Add AVX-VNNI support to <sys/platform/x86.h>.
diff --git a/manual/platform.texi b/manual/platform.texi
index 4f5fdff9d9ef16fd..283f255679643d3e 100644
--- a/manual/platform.texi
+++ b/manual/platform.texi
@@ -198,6 +198,9 @@ The supported processor features are:
@item
@code{AVX2} -- The AVX2 instruction extensions.
+@item
+@code{AVX_VNNI} -- The AVX-VNNI instruction extensions.
+
@item
@code{AVX512_4FMAPS} -- The AVX512_4FMAPS instruction extensions.
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 67f137259fccf4ad..3e5b9341c9756009 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -119,6 +119,8 @@ update_usable (struct cpu_features *cpu_features)
cpu_features->preferred[index_arch_AVX_Fast_Unaligned_Load]
|= bit_arch_AVX_Fast_Unaligned_Load;
}
+ /* Determine if AVX-VNNI is usable. */
+ CPU_FEATURE_SET_USABLE (cpu_features, AVX_VNNI);
/* Determine if FMA is usable. */
CPU_FEATURE_SET_USABLE (cpu_features, FMA);
/* Determine if VAES is usable. */
diff --git a/sysdeps/x86/sys/platform/x86.h b/sysdeps/x86/sys/platform/x86.h
index 0b18257e20105ea4..0942ad7a7f7d4ce2 100644
--- a/sysdeps/x86/sys/platform/x86.h
+++ b/sysdeps/x86/sys/platform/x86.h
@@ -311,6 +311,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
/* COMMON_CPUID_INDEX_7_ECX_1. */
/* EAX. */
+#define bit_cpu_AVX_VNNI (1u << 4)
#define bit_cpu_AVX512_BF16 (1u << 5)
/* COMMON_CPUID_INDEX_19. */
@@ -530,6 +531,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
/* COMMON_CPUID_INDEX_7_ECX_1. */
/* EAX. */
+#define index_cpu_AVX_VNNI COMMON_CPUID_INDEX_7_ECX_1
#define index_cpu_AVX512_BF16 COMMON_CPUID_INDEX_7_ECX_1
/* COMMON_CPUID_INDEX_19. */
@@ -749,6 +751,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
/* COMMON_CPUID_INDEX_7_ECX_1. */
/* EAX. */
+#define reg_AVX_VNNI eax
#define reg_AVX512_BF16 eax
/* COMMON_CPUID_INDEX_19. */
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
index bcdeb243a82c4adc..8894d9f08ac36633 100644
--- a/sysdeps/x86/tst-get-cpu-features.c
+++ b/sysdeps/x86/tst-get-cpu-features.c
@@ -219,6 +219,7 @@ do_test (void)
CHECK_CPU_FEATURE (XFD);
CHECK_CPU_FEATURE (INVARIANT_TSC);
CHECK_CPU_FEATURE (WBNOINVD);
+ CHECK_CPU_FEATURE (AVX_VNNI);
CHECK_CPU_FEATURE (AVX512_BF16);
CHECK_CPU_FEATURE (AESKLE);
CHECK_CPU_FEATURE (WIDE_KL);
@@ -374,6 +375,7 @@ do_test (void)
CHECK_CPU_FEATURE_USABLE (XFD);
CHECK_CPU_FEATURE_USABLE (INVARIANT_TSC);
CHECK_CPU_FEATURE_USABLE (WBNOINVD);
+ CHECK_CPU_FEATURE_USABLE (AVX_VNNI);
CHECK_CPU_FEATURE_USABLE (AVX512_BF16);
CHECK_CPU_FEATURE_USABLE (AESKLE);
CHECK_CPU_FEATURE_USABLE (WIDE_KL);
commit c712401bc641b66d9bd558884751d8979e2e0e96
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Oct 8 08:38:03 2020 -0700
<sys/platform/x86.h>: Add Intel HRESET support
Add Intel HRESET support to <sys/platform/x86.h>.
diff --git a/manual/platform.texi b/manual/platform.texi
index 283f255679643d3e..1e44525552f5bda5 100644
--- a/manual/platform.texi
+++ b/manual/platform.texi
@@ -346,6 +346,9 @@ extensions.
@item
@code{HTT} -- Max APIC IDs reserved field is Valid.
+@item
+@code{HRESET} -- History reset.
+
@item
@code{HYBRID} -- Hybrid processor.
diff --git a/sysdeps/x86/sys/platform/x86.h b/sysdeps/x86/sys/platform/x86.h
index 0942ad7a7f7d4ce2..357c6f1c5605d82d 100644
--- a/sysdeps/x86/sys/platform/x86.h
+++ b/sysdeps/x86/sys/platform/x86.h
@@ -313,6 +313,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
/* EAX. */
#define bit_cpu_AVX_VNNI (1u << 4)
#define bit_cpu_AVX512_BF16 (1u << 5)
+#define bit_cpu_HRESET (1u << 22)
/* COMMON_CPUID_INDEX_19. */
@@ -533,6 +534,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
/* EAX. */
#define index_cpu_AVX_VNNI COMMON_CPUID_INDEX_7_ECX_1
#define index_cpu_AVX512_BF16 COMMON_CPUID_INDEX_7_ECX_1
+#define index_cpu_HRESET COMMON_CPUID_INDEX_7_ECX_1
/* COMMON_CPUID_INDEX_19. */
@@ -753,6 +755,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
/* EAX. */
#define reg_AVX_VNNI eax
#define reg_AVX512_BF16 eax
+#define reg_HRESET eax
/* COMMON_CPUID_INDEX_19. */
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
index 8894d9f08ac36633..1516af1d461a801b 100644
--- a/sysdeps/x86/tst-get-cpu-features.c
+++ b/sysdeps/x86/tst-get-cpu-features.c
@@ -221,6 +221,7 @@ do_test (void)
CHECK_CPU_FEATURE (WBNOINVD);
CHECK_CPU_FEATURE (AVX_VNNI);
CHECK_CPU_FEATURE (AVX512_BF16);
+ CHECK_CPU_FEATURE (HRESET);
CHECK_CPU_FEATURE (AESKLE);
CHECK_CPU_FEATURE (WIDE_KL);
commit 428985c436f442e91e27173bccaf28f547233586
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Oct 8 08:50:44 2020 -0700
<sys/platform/x86.h>: Add FSRCS/FSRS/FZLRM support
Add Fast Short REP CMP and SCA (FSRCS), Fast Short REP STO (FSRS) and
Fast Zero-Length REP MOV (FZLRM) support to <sys/platform/x86.h>.
diff --git a/manual/platform.texi b/manual/platform.texi
index 1e44525552f5bda5..8fec2933d6442823 100644
--- a/manual/platform.texi
+++ b/manual/platform.texi
@@ -331,12 +331,21 @@ extensions.
@item
@code{FSGSBASE} -- RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE instructions.
+@item
+@code{FSRCS} -- Fast Short REP CMP and SCA.
+
@item
@code{FSRM} -- Fast Short REP MOV.
+@item
+@code{FSRS} -- Fast Short REP STO.
+
@item
@code{FXSR} -- FXSAVE and FXRSTOR instructions.
+@item
+@code{FZLRM} -- Fast Zero-Length REP MOV.
+
@item
@code{GFNI} -- GFNI instruction extensions.
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 3e5b9341c9756009..5f0548fe08134236 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -93,6 +93,9 @@ update_usable (struct cpu_features *cpu_features)
CPU_FEATURE_SET_USABLE (cpu_features, TBM);
CPU_FEATURE_SET_USABLE (cpu_features, RDTSCP);
CPU_FEATURE_SET_USABLE (cpu_features, WBNOINVD);
+ CPU_FEATURE_SET_USABLE (cpu_features, FZLRM);
+ CPU_FEATURE_SET_USABLE (cpu_features, FSRS);
+ CPU_FEATURE_SET_USABLE (cpu_features, FSRCS);
/* Can we call xgetbv? */
if (CPU_FEATURES_CPU_P (cpu_features, OSXSAVE))
diff --git a/sysdeps/x86/sys/platform/x86.h b/sysdeps/x86/sys/platform/x86.h
index 357c6f1c5605d82d..e5cc7c683a20b5a0 100644
--- a/sysdeps/x86/sys/platform/x86.h
+++ b/sysdeps/x86/sys/platform/x86.h
@@ -313,6 +313,9 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
/* EAX. */
#define bit_cpu_AVX_VNNI (1u << 4)
#define bit_cpu_AVX512_BF16 (1u << 5)
+#define bit_cpu_FZLRM (1u << 10)
+#define bit_cpu_FSRS (1u << 11)
+#define bit_cpu_FSRCS (1u << 12)
#define bit_cpu_HRESET (1u << 22)
/* COMMON_CPUID_INDEX_19. */
@@ -534,6 +537,9 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
/* EAX. */
#define index_cpu_AVX_VNNI COMMON_CPUID_INDEX_7_ECX_1
#define index_cpu_AVX512_BF16 COMMON_CPUID_INDEX_7_ECX_1
+#define index_cpu_FZLRM COMMON_CPUID_INDEX_7_ECX_1
+#define index_cpu_FSRS COMMON_CPUID_INDEX_7_ECX_1
+#define index_cpu_FSRCS COMMON_CPUID_INDEX_7_ECX_1
#define index_cpu_HRESET COMMON_CPUID_INDEX_7_ECX_1
/* COMMON_CPUID_INDEX_19. */
@@ -755,6 +761,9 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
/* EAX. */
#define reg_AVX_VNNI eax
#define reg_AVX512_BF16 eax
+#define reg_FZLRM eax
+#define reg_FSRS eax
+#define reg_FSRCS eax
#define reg_HRESET eax
/* COMMON_CPUID_INDEX_19. */
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
index 1516af1d461a801b..2763deb6d008597f 100644
--- a/sysdeps/x86/tst-get-cpu-features.c
+++ b/sysdeps/x86/tst-get-cpu-features.c
@@ -221,6 +221,9 @@ do_test (void)
CHECK_CPU_FEATURE (WBNOINVD);
CHECK_CPU_FEATURE (AVX_VNNI);
CHECK_CPU_FEATURE (AVX512_BF16);
+ CHECK_CPU_FEATURE (FZLRM);
+ CHECK_CPU_FEATURE (FSRS);
+ CHECK_CPU_FEATURE (FSRCS);
CHECK_CPU_FEATURE (HRESET);
CHECK_CPU_FEATURE (AESKLE);
CHECK_CPU_FEATURE (WIDE_KL);
@@ -378,6 +381,9 @@ do_test (void)
CHECK_CPU_FEATURE_USABLE (WBNOINVD);
CHECK_CPU_FEATURE_USABLE (AVX_VNNI);
CHECK_CPU_FEATURE_USABLE (AVX512_BF16);
+ CHECK_CPU_FEATURE_USABLE (FZLRM);
+ CHECK_CPU_FEATURE_USABLE (FSRS);
+ CHECK_CPU_FEATURE_USABLE (FSRCS);
CHECK_CPU_FEATURE_USABLE (AESKLE);
CHECK_CPU_FEATURE_USABLE (WIDE_KL);
commit 21181d1c7b181c4bb71e587c7944e100d923b393
Author: Matheus Castanho <msc@linux.ibm.com>
Date: Mon Oct 12 11:28:18 2020 +0200
elf: Add missing <dl-procinfo.h> header to elf/dl-usage.c
diff --git a/elf/dl-usage.c b/elf/dl-usage.c
index c07f43835bd771cf..796ad38b43c2211b 100644
--- a/elf/dl-usage.c
+++ b/elf/dl-usage.c
@@ -22,6 +22,7 @@
#include <unistd.h>
#include "version.h"
+#include <dl-procinfo.h>
#include <dl-hwcaps.h>
void
This diff is collapsed.
commit de1a9197af7f67a89f929dcadb8ceca8c3846b1c
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Oct 30 11:57:59 2020 +0100
elf: Unify old and new format cache handling code in ld.so
struct file_entry_new starts with the fields of struct file_entry,
so the code can be shared if the size computation is made dynamic.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
diff --git a/elf/dl-cache.c b/elf/dl-cache.c
index ef37ca18fa9fb6e0..366a051dfcd26132 100644
--- a/elf/dl-cache.c
+++ b/elf/dl-cache.c
@@ -35,103 +35,141 @@ static struct cache_file *cache;
static struct cache_file_new *cache_new;
static size_t cachesize;
-/* 1 if cache_data + PTR points into the cache. */
-#define _dl_cache_verify_ptr(ptr) (ptr < cache_data_size)
-
-#define SEARCH_CACHE(cache) \
-/* We use binary search since the table is sorted in the cache file. \
- The first matching entry in the table is returned. \
- It is important to use the same algorithm as used while generating \
- the cache file. */ \
-do \
- { \
- left = 0; \
- right = cache->nlibs - 1; \
- \
- while (left <= right) \
- { \
- __typeof__ (cache->libs[0].key) key; \
- \
- middle = (left + right) / 2; \
- \
- key = cache->libs[middle].key; \
- \
- /* Make sure string table indices are not bogus before using \
- them. */ \
- if (! _dl_cache_verify_ptr (key)) \
- { \
- cmpres = 1; \
- break; \
- } \
- \
- /* Actually compare the entry with the key. */ \
- cmpres = _dl_cache_libcmp (name, cache_data + key); \
- if (__glibc_unlikely (cmpres == 0)) \
- { \
- /* Found it. LEFT now marks the last entry for which we \
- know the name is correct. */ \
- left = middle; \
- \
- /* There might be entries with this name before the one we \
- found. So we have to find the beginning. */ \
- while (middle > 0) \
- { \
- __typeof__ (cache->libs[0].key) key; \
- \
- key = cache->libs[middle - 1].key; \
- /* Make sure string table indices are not bogus before \
- using them. */ \
- if (! _dl_cache_verify_ptr (key) \
- /* Actually compare the entry. */ \
- || _dl_cache_libcmp (name, cache_data + key) != 0) \
- break; \
- --middle; \
- } \
- \
- do \
- { \
- int flags; \
- __typeof__ (cache->libs[0]) *lib = &cache->libs[middle]; \
- \
- /* Only perform the name test if necessary. */ \
- if (middle > left \
- /* We haven't seen this string so far. Test whether the \
- index is ok and whether the name matches. Otherwise \
- we are done. */ \
- && (! _dl_cache_verify_ptr (lib->key) \
- || (_dl_cache_libcmp (name, cache_data + lib->key) \
- != 0))) \
- break; \
- \
- flags = lib->flags; \
- if (_dl_cache_check_flags (flags) \
- && _dl_cache_verify_ptr (lib->value)) \
- { \
- if (best == NULL || flags == GLRO(dl_correct_cache_id)) \
- { \
- HWCAP_CHECK; \
- best = cache_data + lib->value; \
- \
- if (flags == GLRO(dl_correct_cache_id)) \
- /* We've found an exact match for the shared \
- object and no general `ELF' release. Stop \
- searching. */ \
- break; \
- } \
- } \
- } \
- while (++middle <= right); \
- break; \
- } \
- \
- if (cmpres < 0) \
- left = middle + 1; \
- else \
- right = middle - 1; \
- } \
- } \
-while (0)
+/* True if PTR is a valid string table index. */
+static inline bool
+_dl_cache_verify_ptr (uint32_t ptr, size_t string_table_size)
+{
+ return ptr < string_table_size;
+}
+
+/* Compute the address of the element INDEX of the array at LIBS.
+ Conceptually, this is &LIBS[INDEX], but use ENTRY_SIZE for the size
+ of *LIBS. */
+static inline const struct file_entry *
+_dl_cache_file_entry (const struct file_entry *libs, size_t entry_size,
+ size_t index)
+{
+ return (const void *) libs + index * entry_size;
+}
+
+/* We use binary search since the table is sorted in the cache file.
+ The first matching entry in the table is returned. It is important
+ to use the same algorithm as used while generating the cache file.
+ STRING_TABLE_SIZE indicates the maximum offset in STRING_TABLE at
+ which data is mapped; it is not exact. */
+static const char *
+search_cache (const char *string_table, uint32_t string_table_size,
+ struct file_entry *libs, uint32_t nlibs, uint32_t entry_size,
+ const char *name)
+{
+ /* Used by the HWCAP check in the struct file_entry_new case. */
+ uint64_t platform = _dl_string_platform (GLRO (dl_platform));
+ if (platform != (uint64_t) -1)
+ platform = 1ULL << platform;
+ uint64_t hwcap_mask = GET_HWCAP_MASK ();
+#define _DL_HWCAP_TLS_MASK (1LL << 63)
+ uint64_t hwcap_exclude = ~((GLRO (dl_hwcap) & hwcap_mask)
+ | _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK);
+
+ int left = 0;
+ int right = nlibs - 1;
+ const char *best = NULL;
+
+ while (left <= right)
+ {
+ int middle = (left + right) / 2;
+ uint32_t key = _dl_cache_file_entry (libs, entry_size, middle)->key;
+
+ /* Make sure string table indices are not bogus before using
+ them. */
+ if (!_dl_cache_verify_ptr (key, string_table_size))
+ return NULL;
+
+ /* Actually compare the entry with the key. */
+ int cmpres = _dl_cache_libcmp (name, string_table + key);
+ if (__glibc_unlikely (cmpres == 0))
+ {
+ /* Found it. LEFT now marks the last entry for which we
+ know the name is correct. */
+ left = middle;
+
+ /* There might be entries with this name before the one we
+ found. So we have to find the beginning. */
+ while (middle > 0)
+ {
+ key = _dl_cache_file_entry (libs, entry_size, middle - 1)->key;
+ /* Make sure string table indices are not bogus before
+ using them. */
+ if (!_dl_cache_verify_ptr (key, string_table_size)
+ /* Actually compare the entry. */
+ || _dl_cache_libcmp (name, string_table + key) != 0)
+ break;
+ --middle;
+ }
+
+ do
+ {
+ int flags;
+ const struct file_entry *lib
+ = _dl_cache_file_entry (libs, entry_size, middle);
+
+ /* Only perform the name test if necessary. */
+ if (middle > left
+ /* We haven't seen this string so far. Test whether the
+ index is ok and whether the name matches. Otherwise
+ we are done. */
+ && (! _dl_cache_verify_ptr (lib->key, string_table_size)
+ || (_dl_cache_libcmp (name, string_table + lib->key)
+ != 0)))
+ break;
+
+ flags = lib->flags;
+ if (_dl_cache_check_flags (flags)
+ && _dl_cache_verify_ptr (lib->value, string_table_size))
+ {
+ if (best == NULL || flags == GLRO (dl_correct_cache_id))
+ {
+ if (entry_size >= sizeof (struct file_entry_new))
+ {
+ /* The entry is large enough to include
+ HWCAP data. Check it. */
+ struct file_entry_new *libnew
+ = (struct file_entry_new *) lib;
+
+ if (libnew->hwcap & hwcap_exclude)
+ continue;
+ if (GLRO (dl_osversion)
+ && libnew->osversion > GLRO (dl_osversion))
+ continue;
+ if (_DL_PLATFORMS_COUNT
+ && (libnew->hwcap & _DL_HWCAP_PLATFORM) != 0
+ && ((libnew->hwcap & _DL_HWCAP_PLATFORM)
+ != platform))
+ continue;
+ }
+
+ best = string_table + lib->value;
+
+ if (flags == GLRO (dl_correct_cache_id))
+ /* We've found an exact match for the shared
+ object and no general `ELF' release. Stop
+ searching. */
+ break;
+ }
+ }
+ }
+ while (++middle <= right);
+ break;
+ }
+ if (cmpres < 0)
+ left = middle + 1;
+ else
+ right = middle - 1;
+ }
+
+ return best;
+}
int
_dl_cache_libcmp (const char *p1, const char *p2)
@@ -182,12 +220,6 @@ _dl_cache_libcmp (const char *p1, const char *p2)
char *
_dl_load_cache_lookup (const char *name)
{
- int left, right, middle;
- int cmpres;
- const char *cache_data;
- uint32_t cache_data_size;
- const char *best;
-
/* Print a message if the loading of libs is traced. */
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
_dl_debug_printf (" search cache=%s\n", LD_SO_CACHE);
@@ -247,51 +279,22 @@ _dl_load_cache_lookup (const char *name)
/* Previously looked for the cache file and didn't find it. */
return NULL;
- best = NULL;
-
+ const char *best;
if (cache_new != (void *) -1)
{
- uint64_t platform;
-
- /* This is where the strings start. */
- cache_data = (const char *) cache_new;
-
- /* Now we can compute how large the string table is. */
- cache_data_size = (const char *) cache + cachesize - cache_data;
-
- platform = _dl_string_platform (GLRO(dl_platform));
- if (platform != (uint64_t) -1)
- platform = 1ULL << platform;
-
- uint64_t hwcap_mask = GET_HWCAP_MASK();
-
-#define _DL_HWCAP_TLS_MASK (1LL << 63)
- uint64_t hwcap_exclude = ~((GLRO(dl_hwcap) & hwcap_mask)
- | _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK);
-
- /* Only accept hwcap if it's for the right platform. */
-#define HWCAP_CHECK \
- if (lib->hwcap & hwcap_exclude) \
- continue; \
- if (GLRO(dl_osversion) && lib->osversion > GLRO(dl_osversion)) \
- continue; \
- if (_DL_PLATFORMS_COUNT \
- && (lib->hwcap & _DL_HWCAP_PLATFORM) != 0 \
- && (lib->hwcap & _DL_HWCAP_PLATFORM) != platform) \
- continue
- SEARCH_CACHE (cache_new);
+ const char *string_table = (const char *) cache_new;
+ best = search_cache (string_table, cachesize,
+ &cache_new->libs[0].entry, cache_new->nlibs,
+ sizeof (cache_new->libs[0]), name);
}
else
{
- /* This is where the strings start. */
- cache_data = (const char *) &cache->libs[cache->nlibs];
-
- /* Now we can compute how large the string table is. */
- cache_data_size = (const char *) cache + cachesize - cache_data;
-
-#undef HWCAP_CHECK
-#define HWCAP_CHECK do {} while (0)
- SEARCH_CACHE (cache);
+ const char *string_table = (const char *) &cache->libs[cache->nlibs];
+ uint32_t string_table_size
+ = (const char *) cache + cachesize - string_table;
+ best = search_cache (string_table, string_table_size,
+ &cache->libs[0], cache->nlibs,
+ sizeof (cache->libs[0]), name);
}
/* Print our result if wanted. */
diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
index cf43f1cf3b441bc7..3c5730dfe42c7c88 100644
--- a/sysdeps/generic/dl-cache.h
+++ b/sysdeps/generic/dl-cache.h
@@ -59,8 +59,8 @@
*/
struct file_entry
{
- int flags; /* This is 1 for an ELF library. */
- unsigned int key, value; /* String table indices. */
+ int32_t flags; /* This is 1 for an ELF library. */
+ uint32_t key, value; /* String table indices. */
};
struct cache_file
@@ -77,8 +77,17 @@ struct cache_file
struct file_entry_new
{
- int32_t flags; /* This is 1 for an ELF library. */
- uint32_t key, value; /* String table indices. */
+ union
+ {
+ /* Fields shared with struct file_entry. */
+ struct file_entry entry;
+ /* Also expose these fields directly. */
+ struct
+ {
+ int32_t flags; /* This is 1 for an ELF library. */
+ uint32_t key, value; /* String table indices. */
+ };
+ };
uint32_t osversion; /* Required OS version. */
uint64_t hwcap; /* Hwcap entry. */
};
commit 5e598c2bbf938eac0f4045f5143f9dd723646672
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Oct 30 18:40:28 2020 +0100
elf: In ldconfig, extract the new_sub_entry function from search_dir
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 7c8fd29387463a8a..be730ceb075f6c1f 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -328,6 +328,23 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"Andreas Jaeger");
}
+/* Allocate a new subdirectory with full path PATH under ENTRY, using
+ inode data from *ST. */
+static struct dir_entry *
+new_sub_entry (const struct dir_entry *entry, const char *path,
+ const struct stat64 *st)
+{
+ struct dir_entry *new_entry = xmalloc (sizeof (struct dir_entry));
+ new_entry->from_file = entry->from_file;
+ new_entry->from_line = entry->from_line;
+ new_entry->path = xstrdup (path);
+ new_entry->flag = entry->flag;
+ new_entry->next = NULL;
+ new_entry->ino = st->st_ino;
+ new_entry->dev = st->st_dev;
+ return new_entry;
+}
+
/* Add a single directory entry. */
static void
add_single_dir (struct dir_entry *entry, int verbose)
@@ -823,26 +840,17 @@ search_dir (const struct dir_entry *entry)
if (is_dir && is_hwcap_platform (direntry->d_name))
{
- /* Handle subdirectory later. */
- struct dir_entry *new_entry;
-
- new_entry = xmalloc (sizeof (struct dir_entry));
- new_entry->from_file = entry->from_file;
- new_entry->from_line = entry->from_line;
- new_entry->path = xstrdup (file_name);
- new_entry->flag = entry->flag;
- new_entry->next = NULL;
if (!is_link
&& direntry->d_type != DT_UNKNOWN
&& __builtin_expect (lstat64 (real_file_name, &lstat_buf), 0))
{
error (0, errno, _("Cannot lstat %s"), file_name);
- free (new_entry->path);
- free (new_entry);
continue;
}
- new_entry->ino = lstat_buf.st_ino;
- new_entry->dev = lstat_buf.st_dev;
+
+ /* Handle subdirectory later. */
+ struct dir_entry *new_entry = new_sub_entry (entry, file_name,
+ &lstat_buf);
add_single_dir (new_entry, 0);
continue;
}
commit 7cc65773f04e0f4252428c40dcbb784a39b58cd1
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Oct 24 02:19:15 2018 -0700
x86: Support RDTSCP for benchtests
RDTSCP waits until all previous instructions have executed and all
previous loads are globally visible before reading the counter. RDTSC
doesn't wait until all previous instructions have been executed before
reading the counter. All x86 processors since 2010 support RDTSCP
instruction. This patch adds RDTSCP support to benchtests.
* benchtests/Makefile (CPPFLAGS-nonlib): Add -DUSE_RDTSCP if
USE_RDTSCP is defined.
* sysdeps/x86/hp-timing.h (HP_TIMING_NOW): Use RDTSCP if
USE_RDTSCP is defined.
diff --git a/benchtests/Makefile b/benchtests/Makefile
index 28d6b0c43f5bd390..bde0caf140e8cf17 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -131,6 +131,12 @@ CPPFLAGS-nonlib += -DDURATION=$(BENCH_DURATION) -D_ISOMAC
# HP_TIMING if it is available.
ifdef USE_CLOCK_GETTIME
CPPFLAGS-nonlib += -DUSE_CLOCK_GETTIME
+else
+# On x86 processors, use RDTSCP, instead of RDTSC, to measure performance
+# of functions. All x86 processors since 2010 support RDTSCP instruction.
+ifdef USE_RDTSCP
+CPPFLAGS-nonlib += -DUSE_RDTSCP
+endif
endif
DETAILED_OPT :=
diff --git a/benchtests/README b/benchtests/README
index 4ddff794d136f65f..aaf0b659e2b25627 100644
--- a/benchtests/README
+++ b/benchtests/README
@@ -34,6 +34,15 @@ the benchmark to use clock_gettime by invoking make as follows:
Again, one must run `make bench-clean' before changing the measurement method.
+On x86 processors, RDTSCP instruction provides more precise timing data
+than RDTSC instruction. All x86 processors since 2010 support RDTSCP
+instruction. One can force the benchmark to use RDTSCP by invoking make
+as follows:
+
+ $ make USE_RDTSCP=1 bench
+
+One must run `make bench-clean' before changing the measurement method.
+
Running benchmarks on another target:
====================================
diff --git a/sysdeps/x86/hp-timing.h b/sysdeps/x86/hp-timing.h
index 77a1360748ca4535..0aa6f5e3f83e0d34 100644
--- a/sysdeps/x86/hp-timing.h
+++ b/sysdeps/x86/hp-timing.h
@@ -40,7 +40,19 @@ typedef unsigned long long int hp_timing_t;
NB: Use __builtin_ia32_rdtsc directly since including <x86intrin.h>
makes building glibc very slow. */
-# define HP_TIMING_NOW(Var) ((Var) = __builtin_ia32_rdtsc ())
+# ifdef USE_RDTSCP
+/* RDTSCP waits until all previous instructions have executed and all
+ previous loads are globally visible before reading the counter.
+ RDTSC doesn't wait until all previous instructions have been executed
+ before reading the counter. */
+# define HP_TIMING_NOW(Var) \
+ (__extension__ ({ \
+ unsigned int __aux; \
+ (Var) = __builtin_ia32_rdtscp (&__aux); \
+ }))
+# else
+# define HP_TIMING_NOW(Var) ((Var) = __builtin_ia32_rdtsc ())
+# endif
# include <hp-timing-common.h>
#else
commit df5f473ed5ee95e3179fcb239e33e971619626cd
Author: Shuo Wang <wangshuo47@huawei.com>
Date: Tue Nov 24 16:42:18 2020 -0300
elf: Fix uninitialized variable for _dl_write
Variable ret in elf/dl-write.c is uninitialized, which should get
return value from __writev.
diff --git a/elf/dl-write.c b/elf/dl-write.c
index 7350aff0035d4fbc..9b741c8a8fe12f6c 100644
--- a/elf/dl-write.c
+++ b/elf/dl-write.c
@@ -41,7 +41,7 @@ _dl_write (int fd, const void *buffer, size_t length)
else
{
__rtld_lock_lock_recursive (GL(dl_load_lock));
- __writev (fd, &iov, 1);
+ ret = __writev (fd, &iov, 1);
if (ret < 0)
ret = -errno;
__rtld_lock_unlock_recursive (GL(dl_load_lock));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment