public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] x86: Check IFUNC definition in unrelocated executable [BZ #20019]
@ 2020-12-28 14:11 H.J. Lu
  2021-01-04 18:47 ` Carlos O'Donell
  0 siblings, 1 reply; 14+ messages in thread
From: H.J. Lu @ 2020-12-28 14:11 UTC (permalink / raw)
  To: libc-alpha

Calling an IFUNC function defined in unrelocated executable may also
lead to segfault.  Issue an error message when calling IFUNC function
defined in the unrelocated executable from a shared library.
---
 sysdeps/i386/dl-machine.h   | 15 ++++++++++-----
 sysdeps/x86_64/dl-machine.h | 15 ++++++++++-----
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index fea9e579ec..dedda484ba 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -337,16 +337,21 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
 	{
 # ifndef RTLD_BOOTSTRAP
 	  if (sym_map != map
-	      && sym_map->l_type != lt_executable
 	      && !sym_map->l_relocated)
 	    {
 	      const char *strtab
 		= (const char *) D_PTR (map, l_info[DT_STRTAB]);
-	      _dl_error_printf ("\
+	      if (sym_map->l_type == lt_executable)
+		_dl_error_printf ("\
+%s: IFUNC symbol `%s' referenced in `%s' is defined in executable\n",
+				  RTLD_PROGNAME, strtab + refsym->st_name,
+				  map->l_name);
+	      else
+		_dl_error_printf ("\
 %s: Relink `%s' with `%s' for IFUNC symbol `%s'\n",
-				RTLD_PROGNAME, map->l_name,
-				sym_map->l_name,
-				strtab + refsym->st_name);
+				  RTLD_PROGNAME, map->l_name,
+				  sym_map->l_name,
+				  strtab + refsym->st_name);
 	    }
 # endif
 	  value = ((Elf32_Addr (*) (void)) value) ();
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index bb93c7c6ab..fc847f4bc2 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -314,16 +314,21 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
 	{
 # ifndef RTLD_BOOTSTRAP
 	  if (sym_map != map
-	      && sym_map->l_type != lt_executable
 	      && !sym_map->l_relocated)
 	    {
 	      const char *strtab
 		= (const char *) D_PTR (map, l_info[DT_STRTAB]);
-	      _dl_error_printf ("\
+	      if (sym_map->l_type == lt_executable)
+		_dl_error_printf ("\
+%s: IFUNC symbol `%s' referenced in `%s' is defined in executable\n",
+				  RTLD_PROGNAME, strtab + refsym->st_name,
+				  map->l_name);
+	      else
+		_dl_error_printf ("\
 %s: Relink `%s' with `%s' for IFUNC symbol `%s'\n",
-				RTLD_PROGNAME, map->l_name,
-				sym_map->l_name,
-				strtab + refsym->st_name);
+				  RTLD_PROGNAME, map->l_name,
+				  sym_map->l_name,
+				  strtab + refsym->st_name);
 	    }
 # endif
 	  value = ((ElfW(Addr) (*) (void)) value) ();
-- 
2.29.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-01-14 13:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 14:11 [PATCH] x86: Check IFUNC definition in unrelocated executable [BZ #20019] H.J. Lu
2021-01-04 18:47 ` Carlos O'Donell
2021-01-04 19:34   ` V2 " H.J. Lu
2021-01-04 19:50     ` Carlos O'Donell
2021-01-04 19:59       ` H.J. Lu
2021-01-04 22:57         ` H.J. Lu
2021-01-05 13:03           ` Carlos O'Donell
2021-01-05 15:14             ` H.J. Lu
2021-01-04 20:44       ` H.J. Lu
2021-01-04 21:20         ` Carlos O'Donell
2021-01-04 22:38           ` [PATCH] ifuncmain6pie: Remove the circular IFUNC dependency " H.J. Lu
2021-01-13 19:43             ` Adhemerval Zanella
2021-01-13 19:48               ` H.J. Lu
2021-01-14 13:10                 ` Adhemerval Zanella

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).