Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Aug 2020 13:40:35 +0000 (UTC)
From:      Leandro Lupori <luporl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r364675 - head/sys/powerpc/powerpc
Message-ID:  <202008241340.07ODeaBG068401@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: luporl
Date: Mon Aug 24 13:40:35 2020
New Revision: 364675
URL: https://svnweb.freebsd.org/changeset/base/364675

Log:
  [PowerPC] Make new auxv format default
  
  Assume ELF images without OSREL use the new auxv format.
  
  This is specially important for rtld, that is not tagged. Using
  direct exec mode with new (ELFv2) binaries that expect the new auxv
  format would result in crashes otherwise.
  
  Unfortunately, this may break direct exec'ing old binaries,
  but it seems better to correctly support new binaries by default,
  considering the transition to ELFv2 happened quite some time
  ago. If needed, a sysctl may be added to allow old auxv format to
  be used when OSREL is not found.
  
  Reviewed by:	bdragon
  Sponsored by:	Eldorado Research Institute (eldorado.org.br)
  Differential Revision:	https://reviews.freebsd.org/D25651

Modified:
  head/sys/powerpc/powerpc/elf_common.c

Modified: head/sys/powerpc/powerpc/elf_common.c
==============================================================================
--- head/sys/powerpc/powerpc/elf_common.c	Mon Aug 24 13:19:16 2020	(r364674)
+++ head/sys/powerpc/powerpc/elf_common.c	Mon Aug 24 13:40:35 2020	(r364675)
@@ -36,7 +36,22 @@ __elfN(powerpc_copyout_auxargs)(struct image_params *i
 	Elf_Auxinfo *argarray, *pos;
 	int error;
 
-	if (imgp->proc->p_osrel >= P_OSREL_POWERPC_NEW_AUX_ARGS)
+	/*
+	 * XXX If we can't find image's OSREL, assume it uses the new auxv
+	 * format.
+	 *
+	 * This is specially important for rtld, that is not tagged. Using
+	 * direct exec mode with new (ELFv2) binaries that expect the new auxv
+	 * format would result in crashes otherwise.
+	 *
+	 * Unfortunately, this may break direct exec'ing old binaries,
+	 * but it seems better to correctly support new binaries by default,
+	 * considering the transition to ELFv2 happened quite some time
+	 * ago. If needed, a sysctl may be added to allow old auxv format to
+	 * be used when OSREL is not found.
+	 */
+	if (imgp->proc->p_osrel >= P_OSREL_POWERPC_NEW_AUX_ARGS ||
+	    imgp->proc->p_osrel == 0)
 		return (__elfN(freebsd_copyout_auxargs)(imgp, base));
 
 	args = (Elf_Auxargs *)imgp->auxargs;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008241340.07ODeaBG068401>