From: Florian Weimer <fweimer@redhat.com>
To: Stefan Liebler <stli@linux.ibm.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 7/7] s390x: Use <gcc-macros.h> in early HWCAP check
Date: Tue, 18 Jan 2022 13:54:40 +0100 [thread overview]
Message-ID: <87czkpjjan.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <81a3cde1-250e-b04a-0037-4fb7f363fd42@linux.ibm.com> (Stefan Liebler's message of "Tue, 18 Jan 2022 13:42:26 +0100")
[-- Attachment #1: Type: text/plain, Size: 902 bytes --]
* Stefan Liebler:
> I'm not quite sure if all your patches are already committed. I've just
> give it a try with commit f8b765bec44e6c464a7eabf80e58c6851ca15ac3:
>
> - configure glibc with --with-rtld-early-cflags=-march=zEC12 and
> CFLAGS=-march=z15 on a z15.
>
> - Rebooted with novx-kernel-parameter => vector-related HWCAPs are
> disabled and executing vector-instructions leads to a crash
>
> - run a helloworld-program: crash due to vector-instruction in
> _dl_setup_hash, which is called in _dl_start_final before
> _dl_sysdep_start is called which runs dl_hwcap_check.
>
> I've checked the build-log and see that the following files are compiled
> with -march=zEC12:
> - dl-printf.c
> - ../sysdeps/unix/sysv/linux/dl-write.c
> - dl-tunables.c
> - ../sysdeps/unix/sysv/linux/dl-sysdep.c
> - rtld.c
Sorry, I missed that requirement.
Would you mind testing the attached patch?
Thanks,
Florian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-elf-Move-_dl_setup_hash-to-its-own-file.patch --]
[-- Type: text/x-patch, Size: 5233 bytes --]
From dae7882e11191cab17afb22dba4ebba69f433d93 Mon Sep 17 00:00:00 2001
Message-Id: <dae7882e11191cab17afb22dba4ebba69f433d93.1642510437.git.fweimer@redhat.com>
From: Florian Weimer <fweimer@redhat.com>
Date: Tue, 18 Jan 2022 13:53:11 +0100
Subject: [PATCH] elf: Move _dl_setup_hash to its own file
To: libc-alpha@sourceware.org
And compile it with the early CFLAGS. _dl_setup_hash is called
very early for the ld.so link map, so it should be compiled
differently.
---
elf/Makefile | 2 ++
elf/dl-lookup.c | 45 --------------------------------
elf/dl-setup_hash.c | 63 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 65 insertions(+), 45 deletions(-)
create mode 100644 elf/dl-setup_hash.c
diff --git a/elf/Makefile b/elf/Makefile
index c6c4710e16..692a65b061 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -74,6 +74,7 @@ dl-routines = \
dl-reloc \
dl-runtime \
dl-scope \
+ dl-setup_hash \
dl-sort-maps \
dl-thread_gscope_wait \
dl-tls \
@@ -169,6 +170,7 @@ CFLAGS-.os += $(call elide-stack-protector,.os,$(all-rtld-routines))
# Add the requested compiler flags to the early startup code.
CFLAGS-dl-printf.os += $(rtld-early-cflags)
+CFLAGS-dl-setup_hash.os += $(rtld-early-cflags)
CFLAGS-dl-sysdep.os += $(rtld-early-cflags)
CFLAGS-dl-tunables.os += $(rtld-early-cflags)
CFLAGS-dl-write.os += $(rtld-early-cflags)
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index f43ae150b7..cbf46fda62 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -953,51 +953,6 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map,
}
-/* Cache the location of MAP's hash table. */
-
-void
-_dl_setup_hash (struct link_map *map)
-{
- Elf_Symndx *hash;
-
- if (__glibc_likely (map->l_info[ELF_MACHINE_GNU_HASH_ADDRIDX] != NULL))
- {
- Elf32_Word *hash32
- = (void *) D_PTR (map, l_info[ELF_MACHINE_GNU_HASH_ADDRIDX]);
- map->l_nbuckets = *hash32++;
- Elf32_Word symbias = *hash32++;
- Elf32_Word bitmask_nwords = *hash32++;
- /* Must be a power of two. */
- assert ((bitmask_nwords & (bitmask_nwords - 1)) == 0);
- map->l_gnu_bitmask_idxbits = bitmask_nwords - 1;
- map->l_gnu_shift = *hash32++;
-
- map->l_gnu_bitmask = (ElfW(Addr) *) hash32;
- hash32 += __ELF_NATIVE_CLASS / 32 * bitmask_nwords;
-
- map->l_gnu_buckets = hash32;
- hash32 += map->l_nbuckets;
- map->l_gnu_chain_zero = hash32 - symbias;
-
- /* Initialize MIPS xhash translation table. */
- ELF_MACHINE_XHASH_SETUP (hash32, symbias, map);
-
- return;
- }
-
- if (!map->l_info[DT_HASH])
- return;
- hash = (void *) D_PTR (map, l_info[DT_HASH]);
-
- map->l_nbuckets = *hash++;
- /* Skip nchain. */
- hash++;
- map->l_buckets = hash;
- hash += map->l_nbuckets;
- map->l_chain = hash;
-}
-
-
static void
_dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
const ElfW(Sym) **ref, struct sym_val *value,
diff --git a/elf/dl-setup_hash.c b/elf/dl-setup_hash.c
new file mode 100644
index 0000000000..6dd57c5c94
--- /dev/null
+++ b/elf/dl-setup_hash.c
@@ -0,0 +1,63 @@
+/* Cache the location of a link map hash table.
+ Copyright (C) 1995-2022 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 <assert.h>
+#include <link.h>
+#include <ldsodefs.h>
+
+void
+_dl_setup_hash (struct link_map *map)
+{
+ Elf_Symndx *hash;
+
+ if (__glibc_likely (map->l_info[ELF_MACHINE_GNU_HASH_ADDRIDX] != NULL))
+ {
+ Elf32_Word *hash32
+ = (void *) D_PTR (map, l_info[ELF_MACHINE_GNU_HASH_ADDRIDX]);
+ map->l_nbuckets = *hash32++;
+ Elf32_Word symbias = *hash32++;
+ Elf32_Word bitmask_nwords = *hash32++;
+ /* Must be a power of two. */
+ assert ((bitmask_nwords & (bitmask_nwords - 1)) == 0);
+ map->l_gnu_bitmask_idxbits = bitmask_nwords - 1;
+ map->l_gnu_shift = *hash32++;
+
+ map->l_gnu_bitmask = (ElfW(Addr) *) hash32;
+ hash32 += __ELF_NATIVE_CLASS / 32 * bitmask_nwords;
+
+ map->l_gnu_buckets = hash32;
+ hash32 += map->l_nbuckets;
+ map->l_gnu_chain_zero = hash32 - symbias;
+
+ /* Initialize MIPS xhash translation table. */
+ ELF_MACHINE_XHASH_SETUP (hash32, symbias, map);
+
+ return;
+ }
+
+ if (!map->l_info[DT_HASH])
+ return;
+ hash = (void *) D_PTR (map, l_info[DT_HASH]);
+
+ map->l_nbuckets = *hash++;
+ /* Skip nchain. */
+ hash++;
+ map->l_buckets = hash;
+ hash += map->l_nbuckets;
+ map->l_chain = hash;
+}
--
2.34.1
next prev parent reply other threads:[~2022-01-18 12:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-14 12:40 [PATCH 0/7] Reliable CPU compatibility diagnostics in ld.so Florian Weimer
2022-01-14 12:40 ` [PATCH 1/7] x86: HAVE_X86_LAHF_SAHF, HAVE_X86_MOVBE and -march=x86-64-vN (bug 28782) Florian Weimer
2022-01-14 14:21 ` H.J. Lu
2022-01-14 12:40 ` [PATCH 2/7] Generate gcc-macros.h Florian Weimer
2022-01-14 14:24 ` H.J. Lu
2022-01-14 12:40 ` [PATCH 3/7] elf: Split dl-printf.c from dl-misc.c Florian Weimer
2022-01-14 14:25 ` H.J. Lu
2022-01-14 14:27 ` Florian Weimer
2022-01-14 14:32 ` H.J. Lu
2022-01-14 12:40 ` [PATCH 4/7] Add --early-cflags configure option Florian Weimer
2022-01-14 14:27 ` H.J. Lu
2022-01-14 14:29 ` Florian Weimer
2022-01-14 14:33 ` H.J. Lu
2022-01-14 14:34 ` Florian Weimer
2022-01-14 12:40 ` [PATCH 5/7] powerpc64le: Use <gcc-macros.h> in early HWCAP check Florian Weimer
2022-01-14 12:41 ` [PATCH 6/7] x86: Add x86-64-vN check to early startup Florian Weimer
2022-01-14 12:41 ` [PATCH 7/7] s390x: Use <gcc-macros.h> in early HWCAP check Florian Weimer
2022-01-18 12:42 ` Stefan Liebler
2022-01-18 12:54 ` Florian Weimer [this message]
2022-01-18 13:31 ` Stefan Liebler
2022-01-18 13:33 ` Florian Weimer
2022-01-18 13:38 ` Stefan Liebler
2022-01-18 21:03 ` Joseph Myers
2022-01-18 21:21 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87czkpjjan.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=stli@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).