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