diff options
Diffstat (limited to 'elf')
-rw-r--r-- | elf/Makefile | 1 | ||||
-rw-r--r-- | elf/dl-rseq-symbols.S | 64 | ||||
-rw-r--r-- | elf/endswith.h | 33 | ||||
-rw-r--r-- | elf/ldconfig.c | 12 | ||||
-rw-r--r-- | elf/readlib.c | 11 | ||||
-rw-r--r-- | elf/tst-rtld-does-not-exist.sh | 4 | ||||
-rw-r--r-- | elf/tst-tunables-enable_secure-env.c | 2 |
7 files changed, 45 insertions, 82 deletions
diff --git a/elf/Makefile b/elf/Makefile index 147f1d3437..a3475f3fb5 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -73,7 +73,6 @@ dl-routines = \ dl-origin \ dl-printf \ dl-reloc \ - dl-rseq-symbols \ dl-runtime \ dl-scope \ dl-setup_hash \ diff --git a/elf/dl-rseq-symbols.S b/elf/dl-rseq-symbols.S deleted file mode 100644 index b4bba06a99..0000000000 --- a/elf/dl-rseq-symbols.S +++ /dev/null @@ -1,64 +0,0 @@ -/* Define symbols used by rseq. - Copyright (C) 2024 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 <sysdep.h> - -#if __WORDSIZE == 64 -#define RSEQ_OFFSET_SIZE 8 -#else -#define RSEQ_OFFSET_SIZE 4 -#endif - -/* Some targets define a macro to denote the zero register. */ -#undef zero - -/* Define 2 symbols: '__rseq_size' is public const and '_rseq_size' (an - alias of '__rseq_size') is hidden and writable for internal use by the - dynamic linker which will initialize the value both symbols point to - before copy relocations take place. */ - - .globl __rseq_size - .type __rseq_size, %object - .size __rseq_size, 4 - .hidden _rseq_size - .globl _rseq_size - .type _rseq_size, %object - .size _rseq_size, 4 - .section .data.rel.ro - .balign 4 -__rseq_size: -_rseq_size: - .zero 4 - -/* Define 2 symbols: '__rseq_offset' is public const and '_rseq_offset' (an - alias of '__rseq_offset') is hidden and writable for internal use by the - dynamic linker which will initialize the value both symbols point to - before copy relocations take place. */ - - .globl __rseq_offset - .type __rseq_offset, %object - .size __rseq_offset, RSEQ_OFFSET_SIZE - .hidden _rseq_offset - .globl _rseq_offset - .type _rseq_offset, %object - .size _rseq_offset, RSEQ_OFFSET_SIZE - .section .data.rel.ro - .balign RSEQ_OFFSET_SIZE -__rseq_offset: -_rseq_offset: - .zero RSEQ_OFFSET_SIZE diff --git a/elf/endswith.h b/elf/endswith.h new file mode 100644 index 0000000000..c6430c48be --- /dev/null +++ b/elf/endswith.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2023-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <https://www.gnu.org/licenses/>. */ + +#ifndef _ENDSWITH_H +#define _ENDSWITH_H + +#include <string.h> + +/* Return true if the N bytes at NAME end with with the characters in + the string SUFFIX. (NAME[N + 1] does not have to be a null byte.) + Expected to be called with a string literal for SUFFIX. */ +static inline bool +endswithn (const char *name, size_t n, const char *suffix) +{ + return (n >= strlen (suffix) + && memcmp (name + n - strlen (suffix), suffix, + strlen (suffix)) == 0); +} + +#endif /* _ENDSWITH_H */ diff --git a/elf/ldconfig.c b/elf/ldconfig.c index b64c54b53e..0f3ef707dd 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -40,6 +40,7 @@ #include <libgen.h> #include <ldconfig.h> +#include <endswith.h> #include <dl-cache.h> #include <dl-hwcaps.h> #include <dl-is_dso.h> @@ -661,17 +662,6 @@ struct dlib_entry struct dlib_entry *next; }; -/* Return true if the N bytes at NAME end with with the characters in - the string SUFFIX. (NAME[N + 1] does not have to be a null byte.) - Expected to be called with a string literal for SUFFIX. */ -static inline bool -endswithn (const char *name, size_t n, const char *suffix) -{ - return (n >= strlen (suffix) - && memcmp (name + n - strlen (suffix), suffix, - strlen (suffix)) == 0); -} - /* Skip some temporary DSO files. These files may be partially written and lead to ldconfig crashes when examined. */ static bool diff --git a/elf/readlib.c b/elf/readlib.c index 4d67c74136..f3129c4557 100644 --- a/elf/readlib.c +++ b/elf/readlib.c @@ -33,6 +33,7 @@ #include <gnu/lib-names.h> #include <ldconfig.h> +#include <endswith.h> #define Elf32_CLASS ELFCLASS32 #define Elf64_CLASS ELFCLASS64 @@ -43,12 +44,14 @@ struct known_names int flag; }; -/* Check if string corresponds to a GDB Python file. */ +/* Check if string corresponds to a GDB extension file. */ static bool -is_gdb_python_file (const char *name) +is_gdb_extension_file (const char *name) { size_t len = strlen (name); - return len > 7 && strcmp (name + len - 7, "-gdb.py") == 0; + return (endswithn (name, len, "-gdb.gdb") + || endswithn (name, len, "-gdb.py") + || endswithn (name, len, "-gdb.scm")); } /* Returns 0 if everything is ok, != 0 in case of error. */ @@ -145,7 +148,7 @@ process_file (const char *real_file_name, const char *file_name, size_t len = MIN (statbuf.st_size, 512); if (memmem (file_contents, len, "GROUP", 5) == NULL && memmem (file_contents, len, "GNU ld script", 13) == NULL - && !is_gdb_python_file (file_name)) + && !is_gdb_extension_file (file_name)) error (0, 0, _("%s is not an ELF file - it has the wrong magic bytes at the start.\n"), file_name); ret = 1; diff --git a/elf/tst-rtld-does-not-exist.sh b/elf/tst-rtld-does-not-exist.sh index a4a781ccfd..f4a9e38e5d 100644 --- a/elf/tst-rtld-does-not-exist.sh +++ b/elf/tst-rtld-does-not-exist.sh @@ -19,7 +19,9 @@ export LC_ALL=C -rtld="$1" +# --inhibit-cache to suppress "No such file or directory" message when +# /etc/ld.so.cache does not exist. +rtld="$1 --inhibit-cache" tmp_out="$(mktemp)" $rtld program-does-not-exist 2>"$tmp_out" diff --git a/elf/tst-tunables-enable_secure-env.c b/elf/tst-tunables-enable_secure-env.c index 01f121efc3..937259f218 100644 --- a/elf/tst-tunables-enable_secure-env.c +++ b/elf/tst-tunables-enable_secure-env.c @@ -46,7 +46,7 @@ check_auxv (unsigned long type, char *argv) { char *endptr; errno = 0; - unsigned long int varg = strtol (argv, &endptr, 10); + unsigned long int varg = strtoul (argv, &endptr, 10); TEST_VERIFY_EXIT (errno == 0); TEST_VERIFY_EXIT (*endptr == '\0'); errno = 0; |