|
|
e354a5 |
commit 50a2d83c08a94a10f88a1fedeb7a6e3667a6b732
|
|
|
e354a5 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
e354a5 |
Date: Fri Apr 24 22:13:03 2020 +0200
|
|
|
e354a5 |
|
|
|
e354a5 |
elf: Introduce <elf_machine_sym_no_match.h>
|
|
|
e354a5 |
|
|
|
e354a5 |
MIPS needs to ignore certain existing symbols during symbol lookup.
|
|
|
e354a5 |
The old scheme uses the ELF_MACHINE_SYM_NO_MATCH macro, with an
|
|
|
e354a5 |
inline function, within its own header, with a sysdeps override for
|
|
|
e354a5 |
MIPS. This allows re-use of the function from another file (without
|
|
|
e354a5 |
having to include <dl-machine.h> or providing the default definition
|
|
|
e354a5 |
for ELF_MACHINE_SYM_NO_MATCH).
|
|
|
e354a5 |
|
|
|
e354a5 |
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
e354a5 |
|
|
|
e354a5 |
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
|
|
|
e354a5 |
index e4c479de9a1fd6ec..47acd134600b44b5 100644
|
|
|
e354a5 |
--- a/elf/dl-lookup.c
|
|
|
e354a5 |
+++ b/elf/dl-lookup.c
|
|
|
e354a5 |
@@ -28,18 +28,12 @@
|
|
|
e354a5 |
#include <libc-lock.h>
|
|
|
e354a5 |
#include <tls.h>
|
|
|
e354a5 |
#include <atomic.h>
|
|
|
e354a5 |
+#include <elf_machine_sym_no_match.h>
|
|
|
e354a5 |
|
|
|
e354a5 |
#include <assert.h>
|
|
|
e354a5 |
|
|
|
e354a5 |
-/* Return nonzero if check_match should consider SYM to fail to match a
|
|
|
e354a5 |
- symbol reference for some machine-specific reason. */
|
|
|
e354a5 |
-#ifndef ELF_MACHINE_SYM_NO_MATCH
|
|
|
e354a5 |
-# define ELF_MACHINE_SYM_NO_MATCH(sym) 0
|
|
|
e354a5 |
-#endif
|
|
|
e354a5 |
-
|
|
|
e354a5 |
#define VERSTAG(tag) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (tag))
|
|
|
e354a5 |
|
|
|
e354a5 |
-
|
|
|
e354a5 |
struct sym_val
|
|
|
e354a5 |
{
|
|
|
e354a5 |
const ElfW(Sym) *s;
|
|
|
e354a5 |
@@ -78,7 +72,7 @@ check_match (const char *const undef_name,
|
|
|
e354a5 |
if (__glibc_unlikely ((sym->st_value == 0 /* No value. */
|
|
|
e354a5 |
&& sym->st_shndx != SHN_ABS
|
|
|
e354a5 |
&& stt != STT_TLS)
|
|
|
e354a5 |
- || ELF_MACHINE_SYM_NO_MATCH (sym)
|
|
|
e354a5 |
+ || elf_machine_sym_no_match (sym)
|
|
|
e354a5 |
|| (type_class & (sym->st_shndx == SHN_UNDEF))))
|
|
|
e354a5 |
return NULL;
|
|
|
e354a5 |
|
|
|
e354a5 |
diff --git a/sysdeps/generic/elf_machine_sym_no_match.h b/sysdeps/generic/elf_machine_sym_no_match.h
|
|
|
e354a5 |
new file mode 100644
|
|
|
e354a5 |
index 0000000000000000..27155de4c0358460
|
|
|
e354a5 |
--- /dev/null
|
|
|
e354a5 |
+++ b/sysdeps/generic/elf_machine_sym_no_match.h
|
|
|
e354a5 |
@@ -0,0 +1,34 @@
|
|
|
e354a5 |
+/* Function to ignore certain symbol matches for machine-specific reasons.
|
|
|
e354a5 |
+ Copyright (C) 2020 Free Software Foundation, Inc.
|
|
|
e354a5 |
+ This file is part of the GNU C Library.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
e354a5 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
e354a5 |
+ License as published by the Free Software Foundation; either
|
|
|
e354a5 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
e354a5 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e354a5 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
e354a5 |
+ Lesser General Public License for more details.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
e354a5 |
+ License along with the GNU C Library; if not, see
|
|
|
e354a5 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+#ifndef _ELF_MACHINE_SYM_NO_MATCH_H
|
|
|
e354a5 |
+#define _ELF_MACHINE_SYM_NO_MATCH_H
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+#include <link.h>
|
|
|
e354a5 |
+#include <stdbool.h>
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+/* This can be customized to ignore certain symbols during lookup in
|
|
|
e354a5 |
+ case there are machine-specific rules to disregard some
|
|
|
e354a5 |
+ symbols. */
|
|
|
e354a5 |
+static inline bool
|
|
|
e354a5 |
+elf_machine_sym_no_match (const ElfW(Sym) *sym)
|
|
|
e354a5 |
+{
|
|
|
e354a5 |
+ return false;
|
|
|
e354a5 |
+}
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+#endif /* _ELF_MACHINE_SYM_NO_MATCH_H */
|
|
|
e354a5 |
diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
|
|
|
e354a5 |
index 91fc640388a735c7..b41e10647d81843b 100644
|
|
|
e354a5 |
--- a/sysdeps/mips/dl-machine.h
|
|
|
e354a5 |
+++ b/sysdeps/mips/dl-machine.h
|
|
|
e354a5 |
@@ -467,21 +467,6 @@ elf_machine_plt_value (struct link_map *map, const ElfW(Rel) *reloc,
|
|
|
e354a5 |
return value;
|
|
|
e354a5 |
}
|
|
|
e354a5 |
|
|
|
e354a5 |
-/* The semantics of zero/non-zero values of undefined symbols differs
|
|
|
e354a5 |
- depending on whether the non-PIC ABI is in use. Under the non-PIC
|
|
|
e354a5 |
- ABI, a non-zero value indicates that there is an address reference
|
|
|
e354a5 |
- to the symbol and thus it must always be resolved (except when
|
|
|
e354a5 |
- resolving a jump slot relocation) to the PLT entry whose address is
|
|
|
e354a5 |
- provided as the symbol's value; a zero value indicates that this
|
|
|
e354a5 |
- canonical-address behaviour is not required. Yet under the classic
|
|
|
e354a5 |
- MIPS psABI, a zero value indicates that there is an address
|
|
|
e354a5 |
- reference to the function and the dynamic linker must resolve the
|
|
|
e354a5 |
- symbol immediately upon loading. To avoid conflict, symbols for
|
|
|
e354a5 |
- which the dynamic linker must assume the non-PIC ABI semantics are
|
|
|
e354a5 |
- marked with the STO_MIPS_PLT flag. */
|
|
|
e354a5 |
-#define ELF_MACHINE_SYM_NO_MATCH(sym) \
|
|
|
e354a5 |
- ((sym)->st_shndx == SHN_UNDEF && !((sym)->st_other & STO_MIPS_PLT))
|
|
|
e354a5 |
-
|
|
|
e354a5 |
#endif /* !dl_machine_h */
|
|
|
e354a5 |
|
|
|
e354a5 |
#ifdef RESOLVE_MAP
|
|
|
e354a5 |
diff --git a/sysdeps/mips/elf_machine_sym_no_match.h b/sysdeps/mips/elf_machine_sym_no_match.h
|
|
|
e354a5 |
new file mode 100644
|
|
|
e354a5 |
index 0000000000000000..9d09e5fa2db1ff6c
|
|
|
e354a5 |
--- /dev/null
|
|
|
e354a5 |
+++ b/sysdeps/mips/elf_machine_sym_no_match.h
|
|
|
e354a5 |
@@ -0,0 +1,43 @@
|
|
|
e354a5 |
+/* MIPS-specific handling of undefined symbols.
|
|
|
e354a5 |
+ Copyright (C) 2008-2020 Free Software Foundation, Inc.
|
|
|
e354a5 |
+ This file is part of the GNU C Library.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
e354a5 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
e354a5 |
+ License as published by the Free Software Foundation; either
|
|
|
e354a5 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
e354a5 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e354a5 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
e354a5 |
+ Lesser General Public License for more details.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
e354a5 |
+ License along with the GNU C Library; if not, see
|
|
|
e354a5 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+#ifndef _ELF_MACHINE_SYM_NO_MATCH_H
|
|
|
e354a5 |
+#define _ELF_MACHINE_SYM_NO_MATCH_H
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+#include <link.h>
|
|
|
e354a5 |
+#include <stdbool.h>
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+/* The semantics of zero/non-zero values of undefined symbols differs
|
|
|
e354a5 |
+ depending on whether the non-PIC ABI is in use. Under the non-PIC
|
|
|
e354a5 |
+ ABI, a non-zero value indicates that there is an address reference
|
|
|
e354a5 |
+ to the symbol and thus it must always be resolved (except when
|
|
|
e354a5 |
+ resolving a jump slot relocation) to the PLT entry whose address is
|
|
|
e354a5 |
+ provided as the symbol's value; a zero value indicates that this
|
|
|
e354a5 |
+ canonical-address behaviour is not required. Yet under the classic
|
|
|
e354a5 |
+ MIPS psABI, a zero value indicates that there is an address
|
|
|
e354a5 |
+ reference to the function and the dynamic linker must resolve the
|
|
|
e354a5 |
+ symbol immediately upon loading. To avoid conflict, symbols for
|
|
|
e354a5 |
+ which the dynamic linker must assume the non-PIC ABI semantics are
|
|
|
e354a5 |
+ marked with the STO_MIPS_PLT flag. */
|
|
|
e354a5 |
+static inline bool
|
|
|
e354a5 |
+elf_machine_sym_no_match (const ElfW(Sym) *sym)
|
|
|
e354a5 |
+{
|
|
|
e354a5 |
+ return sym->st_shndx == SHN_UNDEF && !(sym->st_other & STO_MIPS_PLT);
|
|
|
e354a5 |
+}
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+#endif /* _ELF_MACHINE_SYM_NO_MATCH_H */
|