NetBSD Problem Report #53319

From tsutsui@ceres.dti.ne.jp  Sun May 27 09:22:51 2018
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 58FC77A169
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 27 May 2018 09:22:51 +0000 (UTC)
Message-Id: <201805270549.w4R5n6sF015091@ceres.dti.ne.jp>
Date: Sun, 27 May 2018 14:49:07 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: text relocations fixes for multimedia/mplayer and others
X-Send-Pr-Version: 3.95

>Number:         53319
>Category:       pkg
>Synopsis:       text relocations fixes for multimedia/mplayer and others
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 27 09:25:00 +0000 2018
>Closed-Date:    Sun May 27 15:39:27 +0000 2018
>Last-Modified:  Tue Aug 14 16:15:01 +0000 2018
>Originator:     Izumi Tsutsui
>Release:        NetBSD 8.0_RC1 + pkgsrc-2018Q1
>Organization:
>Environment:
System: NetBSD mirage 8.0_RC1 NetBSD 8.0_RC1 (GENERIC.201804191727Z) i386
Architecture: i386
Machine: i386
>Description:
Misc pkgsrc/multimedia packages including mplayer and ffpeg3
don't work on NetBSD/i386 8.0_RC1 because they include text relocations
and NetBSD 8.0_RC1 ld.elf_so rejects such binaries.

>How-To-Repeat:
# pkg_add mplayer
# mplayer
# mplayer
mplayer: text relocations
mplayer: Cannot write-enable text segment: Permission denied
# 
>Fix:

The text relocations are caused by two problems:
1) ancient x86 asm code does not support PIC
   (and no resources to rewrite it)
    https://trac.ffmpeg.org/ticket/4928
2) some pic options are not specified properly
   (assuming implicit text reloc)

The attached patch (against pkgsrc-2018Q1, not pkgsrc HEAD)
works arount these issue and make mplayer and other packages
that require ffpmeg3 work on NetBSD/i386 8.0_RC1.

The same files is also available on Github gist:
 https://gist.github.com/tsutsui/2ef7a25df11dbfd1414f03036d2ede34

Changes summary:

* multimedia/ffmpeg3
 * specify "CONFIGURE_ARGS+= --disable-asm" on NetBSD/i386 as other systems
 * explicitly specify pic in configure
 * bump PKGREVISION

* multimedia/libdv
 * specify "CONFIGURE_ARGS+= --disable-asm" on NetBSD/i386 8.x as
   other systems
 * bump PKGREVISION

* multimedia/mencoder, multimedia/mplayer-share, multimedia/mplayer
 * specify "CONFIGURE_ARGS+= --disable-sse4" to disable asm code that
   causes text relocations
 * specify -fpic in configure for i386 to enable __PIC__ blocks in
   some sources
 * use -march instead of -mcpu for newer gcc versions too
 * explicitly pull pkgsrc/multimedia/libass/buildlink3.mk
   (to avoid internal one or disabled by autodetect)
 * bump PKGREVISIONs

* multimedia/x264-devel
 * specify "CONFIGURE_ARGS+= --disable-asm" on NetBSD/i386 8.x
 * bump PKGREVISIONs

* multimedia/xvidcore
 * specify "CONFIGURE_ARGS+= --disable-assembly" on NetBSD/i386 8.x as other
   systems
 * bump PKGREVISIONs

Disabling asm might cause performance issue, but it's still better than
non-functional binaries due to ld.elf_so warnings.
(and it's already done for some other x86 systems)

---

Index: ffmpeg3/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/ffmpeg3/Makefile,v
retrieving revision 1.31
diff -u -p -r1.31 Makefile
--- ffmpeg3/Makefile	12 Mar 2018 11:15:40 -0000	1.31
+++ ffmpeg3/Makefile	27 May 2018 04:09:18 -0000
@@ -1,7 +1,7 @@
 # $NetBSD: Makefile,v 1.31 2018/03/12 11:15:40 wiz Exp $

 PKGNAME=	${DISTNAME:S/ffmpeg/ffmpeg3/}
-PKGREVISION=	4
+PKGREVISION=	5
 MAINTAINER=	pkgsrc-users@NetBSD.org
 HOMEPAGE=	http://ffmpeg.mplayerhq.hu/
 COMMENT=	Decoding, encoding and streaming software (v3.x)
@@ -41,10 +41,11 @@ post-install:

 .include "../../mk/compiler.mk"

-# disable asm on i386 for non-gcc and gcc < 4.2
+# disable asm on i386 for non-gcc and gcc < 4.2, or to avoid text relocations
 .if ${MACHINE_ARCH} == "i386"
 .  if !empty(MACHINE_PLATFORM:MDarwin-*-i386) \
    || !empty(MACHINE_PLATFORM:MSunOS-*-i386) \
+   || !empty(MACHINE_PLATFORM:MNetBSD-*-i386) \
    || !empty(CC_VERSION:Mgcc-[123]*) \
    || !empty(CC_VERSION:Mgcc-4.[01].*) \
    || empty(CC_VERSION:Mgcc*)
Index: ffmpeg3/distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/ffmpeg3/distinfo,v
retrieving revision 1.26
diff -u -p -r1.26 distinfo
--- ffmpeg3/distinfo	26 Feb 2018 07:40:28 -0000	1.26
+++ ffmpeg3/distinfo	27 May 2018 04:09:18 -0000
@@ -5,7 +5,7 @@ RMD160 (ffmpeg-3.4.2.tar.xz) = 97751ae03
 SHA512 (ffmpeg-3.4.2.tar.xz) = 9fb6df5ddde8af51b929180192d29210695deeef61211fb8a69206bdeabba729cd47e346e4dcf6f27c3416ed77383d30b51933e75fc515466404f85d105bb301
 Size (ffmpeg-3.4.2.tar.xz) = 8478376 bytes
 SHA1 (patch-Makefile) = 0c35f53878b0420aeea49d8ccb249279e705eb40
-SHA1 (patch-configure) = ed50009ff973844427af7b5720af6493ebfce298
+SHA1 (patch-configure) = a30c25267dec3642a010d7cb66fc98e8c5c0bdea
 SHA1 (patch-doc_Makefile) = 50ee7aaf74f8a5c439b11f141b5408322659543a
 SHA1 (patch-libavformat_sctp.c) = 22bad9c7dc152aec3c60e0009899af241f495535
 SHA1 (patch-libavutil_common.h) = d0f1093bc82567807b39dde990ee347f90a082c9
Index: ffmpeg3/patches/patch-configure
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/ffmpeg3/patches/patch-configure,v
retrieving revision 1.5
diff -u -p -r1.5 patch-configure
--- ffmpeg3/patches/patch-configure	18 Oct 2017 20:25:41 -0000	1.5
+++ ffmpeg3/patches/patch-configure	27 May 2018 04:09:19 -0000
@@ -1,22 +1,18 @@
 $NetBSD: patch-configure,v 1.5 2017/10/18 20:25:41 adam Exp $

-Enable PIC on non-i386 NetBSD.
+Enable PIC on NetBSD, even on i386 to avoid text relocations.

---- configure.orig	2017-10-15 15:59:36.000000000 +0000
+--- configure.orig	2018-02-12 00:29:18.000000000 +0000
 +++ configure
-@@ -4939,6 +4939,11 @@ case $target_os in
+@@ -4940,6 +4940,7 @@ case $target_os in
          ;;
      netbsd)
          disable symver
-+        # NetBSD/macppc *really* needs PIC enabled.  ffmpeg has repeatedly
-+        # broken time and time again because PIC support has been removed
-+        # from architectures that need it.  So, if you touch this, please
-+        # be careful and make sure that your changes work.
-+        test "${subarch}" != "x86_32" && enable pic
++        enable pic
          oss_indev_extralibs="-lossaudio"
          oss_outdev_extralibs="-lossaudio"
          enabled gcc || check_ldflags -Wl,-zmuldefs
-@@ -5359,10 +5364,13 @@ check_cc <<EOF && enable attribute_may_a
+@@ -5360,10 +5361,13 @@ check_cc <<EOF && enable attribute_may_a
  union { int x; } __attribute__((may_alias)) x;
  EOF

Index: libdv/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/libdv/Makefile,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile
--- libdv/Makefile	22 Apr 2011 13:44:17 -0000	1.15
+++ libdv/Makefile	27 May 2018 04:09:19 -0000
@@ -2,7 +2,7 @@

 .include "Makefile.common"

-PKGREVISION=	1
+PKGREVISION=	2

 CONFIGURE_ARGS+=	--disable-gtk

Index: libdv/Makefile.common
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/libdv/Makefile.common,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile.common
--- libdv/Makefile.common	3 Dec 2013 21:46:46 -0000	1.15
+++ libdv/Makefile.common	27 May 2018 04:09:19 -0000
@@ -24,7 +24,9 @@ PTHREAD_AUTO_VARS=	yes
 .include "../../mk/bsd.prefs.mk"

 .if (${OPSYS} == "Darwin") || empty(MACHINE_PLATFORM:M*-*-i386) || \
-    (${OPSYS} == "Interix") || (${OPSYS} == "SunOS") || (${OPSYS} == "MirBSD")
+    (${OPSYS} == "Interix") || (${OPSYS} == "SunOS") || \
+    (${OPSYS} == "MirBSD") || \
+    !empty(MACHINE_PLATFORM:MNetBSD-[89].*-i386)
 CONFIGURE_ARGS+=	--disable-asm
 .endif

Index: mencoder/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mencoder/Makefile,v
retrieving revision 1.67
diff -u -p -r1.67 Makefile
--- mencoder/Makefile	25 Feb 2016 15:49:44 -0000	1.67
+++ mencoder/Makefile	27 May 2018 04:09:19 -0000
@@ -1,6 +1,7 @@
 # $NetBSD: Makefile,v 1.67 2016/02/25 15:49:44 jperkin Exp $

 PKGNAME=	mencoder-${MPLAYER_VERSION}
+PKGREVISION=	1

 COMMENT=	Simple movie encoder for MPlayer-playable movies

Index: mplayer/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mplayer/Makefile,v
retrieving revision 1.100
diff -u -p -r1.100 Makefile
--- mplayer/Makefile	7 Feb 2016 13:34:34 -0000	1.100
+++ mplayer/Makefile	27 May 2018 04:09:19 -0000
@@ -1,6 +1,7 @@
 # $NetBSD: Makefile,v 1.100 2016/02/07 13:34:34 leot Exp $

 PKGNAME=	mplayer-${MPLAYER_VERSION}
+PKGREVISION=	1

 COMMENT=	Fast, cross-platform movie player

Index: mplayer-share/Makefile.cflags
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mplayer-share/Makefile.cflags,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile.cflags
--- mplayer-share/Makefile.cflags	7 Feb 2016 13:34:33 -0000	1.8
+++ mplayer-share/Makefile.cflags	27 May 2018 04:09:19 -0000
@@ -13,7 +13,7 @@

 .    include "../../mk/compiler.mk"

-.    if !empty(CC_VERSION:Mgcc-4*)
+.    if !empty(CC_VERSION:Mgcc-[4567]*)
 CFLAGS+=	-O3 -ffast-math -fomit-frame-pointer -mtune=pentiumpro
 .    else
 CFLAGS+=	-O3 -ffast-math -fomit-frame-pointer -mcpu=pentiumpro
Index: mplayer-share/Makefile.common
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mplayer-share/Makefile.common,v
retrieving revision 1.58
diff -u -p -r1.58 Makefile.common
--- mplayer-share/Makefile.common	5 Mar 2016 09:03:02 -0000	1.58
+++ mplayer-share/Makefile.common	27 May 2018 04:09:19 -0000
@@ -50,6 +50,12 @@ CONFIGURE_ENV+=		TMPDIR=${WRKDIR}

 .include "../../mk/bsd.prefs.mk"

+# avoid text relocations caused by asm ops in #if HAVE_SSE4_INTERNAL block
+# in libmpcodecs/vf_ass.c
+.if !empty(MACHINE_PLATFORM:MNetBSD-[89].*-i386)
+CONFIGURE_ARGS+=	--disable-sse4
+.endif
+
 # The configure script misdetects endianness on mipseb
 .if ${OPSYS} == "NetBSD" && ${MACHINE_ARCH} == "mipseb"
 CONFIGURE_ARGS+=	--enable-big-endian
Index: mplayer-share/Makefile.depends
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mplayer-share/Makefile.depends,v
retrieving revision 1.21
diff -u -p -r1.21 Makefile.depends
--- mplayer-share/Makefile.depends	5 Mar 2016 09:03:02 -0000	1.21
+++ mplayer-share/Makefile.depends	27 May 2018 04:09:19 -0000
@@ -7,4 +7,5 @@ DEPENDS+=	mplayer-share>=${MPLAYER_VERSI
 .include "../../fonts/fontconfig/buildlink3.mk"
 .include "../../graphics/freetype2/buildlink3.mk"
 .include "../../multimedia/ffmpeg3/buildlink3.mk"
+.include "../../multimedia/libass/buildlink3.mk"
 .include "../../x11/libX11/buildlink3.mk"
Index: mplayer-share/distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mplayer-share/distinfo,v
retrieving revision 1.92
diff -u -p -r1.92 distinfo
--- mplayer-share/distinfo	23 Oct 2017 10:38:22 -0000	1.92
+++ mplayer-share/distinfo	27 May 2018 04:09:19 -0000
@@ -5,7 +5,7 @@ RMD160 (mplayer/MPlayer-1.3.0.tar.xz) = 
 SHA512 (mplayer/MPlayer-1.3.0.tar.xz) = 10007e471a941f8a3dabf6149e6e44fc1a364a9ccb5cd08c670fc22560e5053a15f3249e9d3e18cdda06b6b7e77e537026b5d33dc356e928c63747d6ed73dbae
 Size (mplayer/MPlayer-1.3.0.tar.xz) = 13278984 bytes
 SHA1 (patch-Makefile) = be30a8e90383d6af5902380587b5075fd9c73b83
-SHA1 (patch-aa) = b1492302b7d4e41f362453b6316b17df1300827c
+SHA1 (patch-aa) = bd9b8a10923a7aa8ace18cb848727044e72d937d
 SHA1 (patch-ae) = 286f5ac075ea4123a1a6276f97e02a4dda9b3e67
 SHA1 (patch-an) = 330c427e30b686165fda15a85b730a3f53e0d217
 SHA1 (patch-gui_interface.c) = 04c347b6cb0a54132e6b089142c8ed282f583a1c
Index: mplayer-share/patches/patch-aa
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mplayer-share/patches/patch-aa,v
retrieving revision 1.34
diff -u -p -r1.34 patch-aa
--- mplayer-share/patches/patch-aa	7 Feb 2016 13:34:33 -0000	1.34
+++ mplayer-share/patches/patch-aa	27 May 2018 04:09:19 -0000
@@ -8,8 +8,9 @@ o Fix a bug which broke the detection of
 o Add necessary libs for aalib support even if the aa option is turned on with
   --enable-aa.
 o Add support for dvb capture on NetBSD.
+o Explicitly enable PIE to avoid text relocations on NetBSD/i386 8.x

---- configure.orig	2016-01-08 12:39:01.000000000 +0000
+--- configure.orig	2016-02-13 21:05:42.000000000 +0000
 +++ configure
 @@ -1640,7 +1640,7 @@ else
        cc_name=$cc_name_tmp
@@ -55,7 +56,7 @@ o Add support for dvb capture on NetBSD.
      arch='sh4'
      iproc='sh4'
      ;;
-@@ -2783,23 +2789,23 @@ fi # if darwin && test "$cc_vendor" = "g
+@@ -2806,23 +2812,23 @@ fi # if darwin && test "$cc_vendor" = "g
  _install_strip="-s"
  if test -z "$CFLAGS" || test "$_profile" != "" || test "$_debug" != ""; then
    if test "$cc_vendor" = "intel" ; then
@@ -85,7 +86,7 @@ o Add support for dvb capture on NetBSD.
      WARNFLAGS="-W -Wall $WARNFLAGS"
      _install_strip=
    fi
-@@ -2807,8 +2813,8 @@ else
+@@ -2830,8 +2836,8 @@ else
    warn_cflags=yes
  fi

@@ -96,7 +97,21 @@ o Add support for dvb capture on NetBSD.

  # On glibc, add some more CPPFLAGS for enabling required functionality.
  cpp_condition_check features.h "defined __GLIBC__" &&
-@@ -4591,7 +4597,11 @@ if test "$_x11" = auto && test "$_x11_he
+@@ -2878,10 +2884,11 @@ if test $relocatable = "auto" ; then
+   elif win32 && ! wine ; then
+     relocatable=no
+     res_comment="unnecessary and broken on win32"
+-  elif x86_32 && cflag_check -pie ; then
++  elif x86_32 && cflag_check -fpic -fpie ; then
+     extra_ldflags="$extra_ldflags -pie"
++    extra_cflags="$extra_cflags -fpic -fpie"
+     relocatable=yes
+-    res_comment="non-PIC"
++    res_comment="fast PIC"
+   elif x86_64 && cflag_check -fpie -pie ; then
+     extra_ldflags="$extra_ldflags -fpie -pie"
+     extra_cflags="$extra_cflags -fpie"
+@@ -4615,7 +4622,11 @@ if test "$_x11" = auto && test "$_x11_he
             -L/usr/X11/lib -L/usr/lib32 -L/usr/openwin/lib -L/usr/local/lib64 -L/usr/X11R6/lib64 \
             -L/usr/lib ; do
      if netbsd; then
@@ -109,7 +124,7 @@ o Add support for dvb capture on NetBSD.
      else
        ld_tmp="$I -lXext -lX11 $ld_pthread"
      fi
-@@ -4994,6 +5004,8 @@ if test "$_aa" = yes ; then
+@@ -5018,6 +5029,8 @@ if test "$_aa" = yes ; then
    def_aa='#define CONFIG_AA 1'
    if cygwin ; then
      libs_mplayer="$libs_mplayer $(aalib-config --libs | cut -d " " -f 2,5,6)"
@@ -118,7 +133,7 @@ o Add support for dvb capture on NetBSD.
    fi
    vomodules="aa $vomodules"
  else
-@@ -5081,7 +5093,6 @@ EOF
+@@ -5105,7 +5118,6 @@ EOF
        extra_cflags="$extra_cflags $inc_tmp" && break
    done
  fi
@@ -126,7 +141,7 @@ o Add support for dvb capture on NetBSD.
  if test "$_dvb" = yes ; then
    _dvbin=yes
    inputmodules="dvb $inputmodules"
-@@ -5090,14 +5101,29 @@ if test "$_dvb" = yes ; then
+@@ -5114,14 +5126,29 @@ if test "$_dvb" = yes ; then
    aomodules="mpegpes(dvb) $aomodules"
    vomodules="mpegpes(dvb) $vomodules"
  else
Index: x264-devel/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/x264-devel/Makefile,v
retrieving revision 1.65
diff -u -p -r1.65 Makefile
--- x264-devel/Makefile	25 Feb 2018 21:57:43 -0000	1.65
+++ x264-devel/Makefile	27 May 2018 04:09:19 -0000
@@ -2,6 +2,7 @@

 DISTNAME=	x264-snapshot-20180224-2245
 PKGNAME=	${DISTNAME:S/-snapshot-/-devel-/:S/-2245$//}
+PKGREVISION=	1
 CATEGORIES=	multimedia
 MASTER_SITES=	ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
 EXTRACT_SUFX=	.tar.bz2
@@ -25,6 +26,10 @@ CONFIGURE_ARGS+=	--enable-shared
 CONFIGURE_ARGS+=	--enable-static
 CONFIGURE_ARGS+=	--enable-pic
 CONFIGURE_ARGS+=	--prefix=${PREFIX}
+.if !empty(MACHINE_PLATFORM:MNetBSD-[89].*-i386)
+# avoid text relocations caused by non-pie x86 asm
+CONFIGURE_ARGS+=	--disable-asm
+.endif
 .if ${OPSYS} == "Darwin"
 USE_TOOLS+=		perl
 .else
Index: xvidcore/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/xvidcore/Makefile,v
retrieving revision 1.45
diff -u -p -r1.45 Makefile
--- xvidcore/Makefile	25 Feb 2016 15:49:44 -0000	1.45
+++ xvidcore/Makefile	27 May 2018 04:09:19 -0000
@@ -1,6 +1,7 @@
 # $NetBSD: Makefile,v 1.45 2016/02/25 15:49:44 jperkin Exp $

 DISTNAME=	xvidcore-1.3.3
+PKGREVISION=	1
 CATEGORIES=	multimedia
 MASTER_SITES=	http://downloads.xvid.org/downloads/
 EXTRACT_SUFX=	.tar.bz2
@@ -20,7 +21,8 @@ USE_TOOLS+=	gmake
 # big patch available from Gentoo, if someone is interested:
 # http://bugs.gentoo.org/show_bug.cgi?id=90287
 .if ${OPSYS} == "SunOS" || ${MACHINE_ARCH} == "x86_64" || \
-    !empty(MACHINE_PLATFORM:MDarwin-*-i386)
+    !empty(MACHINE_PLATFORM:MDarwin-*-i386) || \
+    !empty(MACHINE_PLATFORM:MNetBSD-[89].*-i386)
 CONFIGURE_ARGS+=	--disable-assembly
 .elif ${MACHINE_ARCH} == "i386"
 BUILD_DEPENDS+=		nasm>=0.98.39nb3:../../devel/nasm

>Release-Note:

>Audit-Trail:
From: Thomas Klausner <wiz@NetBSD.org>
To: NetBSD bugtracking <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer and
 others
Date: Sun, 27 May 2018 11:55:08 +0200

 These are fine to commit, except for this chunk:

 On Sun, May 27, 2018 at 09:25:00AM +0000, Izumi Tsutsui wrote:
 > Index: mplayer-share/Makefile.depends
 > ===================================================================
 > RCS file: /cvsroot/pkgsrc/multimedia/mplayer-share/Makefile.depends,v
 > retrieving revision 1.21
 > diff -u -p -r1.21 Makefile.depends
 > --- mplayer-share/Makefile.depends	5 Mar 2016 09:03:02 -0000	1.21
 > +++ mplayer-share/Makefile.depends	27 May 2018 04:09:19 -0000
 > @@ -7,4 +7,5 @@ DEPENDS+=	mplayer-share>=${MPLAYER_VERSI
 >  .include "../../fonts/fontconfig/buildlink3.mk"
 >  .include "../../graphics/freetype2/buildlink3.mk"
 >  .include "../../multimedia/ffmpeg3/buildlink3.mk"
 > +.include "../../multimedia/libass/buildlink3.mk"
 >  .include "../../x11/libX11/buildlink3.mk"

 That should be a separate commit, or perhaps an additional
 (default-on?) option.

 Please go ahead!

 Thanks,
  Thomas

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: wiz@NetBSD.org, tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer andothers
Date: Sun, 27 May 2018 20:43:38 +0900

 wiz@ wrote:

 >  These are fine to commit, except for this chunk:
  :
 >  > --- mplayer-share/Makefile.depends	5 Mar 2016 09:03:02 -0000	1.21
 >  > +++ mplayer-share/Makefile.depends	27 May 2018 04:09:19 -0000
 >  > @@ -7,4 +7,5 @@ DEPENDS+=	mplayer-share>=${MPLAYER_VERSI
 >  >  .include "../../fonts/fontconfig/buildlink3.mk"
 >  >  .include "../../graphics/freetype2/buildlink3.mk"
 >  >  .include "../../multimedia/ffmpeg3/buildlink3.mk"
 >  > +.include "../../multimedia/libass/buildlink3.mk"
 >  >  .include "../../x11/libX11/buildlink3.mk"
 >  
 >  That should be a separate commit, or perhaps an additional
 >  (default-on?) option.

 The problematic source which has non-PIE asm inside HAVE_SSE4_INTERNAL
 is MPlayer-1.3.0/libmpcodecs/vf_ass.c. It is complied only if the ASS
 is enabled by the configure.

 mplayer's configure has the following options:
 >  --enable-ass-internal  enable internal SSA/ASS subtitle support [autodetect]
 >  --disable-ass          disable SSA/ASS subtitle support [autodetect]
 so ASS support is "autodetect"-ed.

 It looks "ass-internal" is selected by default if the system has
 freetype 2.2.1 or newer (and pkgsrc/multimedia/libass/buildlink3.mk
 is not specified), according to the configure script.

 mplayer-share/Makefile.depends also includes
 graphics/freetype2/buildlink3.mk and it requires 2.4.11:
 > BUILDLINK_ABI_DEPENDS.freetype2+=       freetype2>=2.4.11
 so I think ASS support is enabled (by autodetect) in usual cases.

 I have not checked if mplayer's internal libass sources have
 any other non-PIE code (there is no obvious "asm" keyword though),
 but pkgsrc/multimedia/libass/Makefile already has the following line
 > CONFIGURE_ARGS+=	--disable-asm
 so it's safer to use it explicitly.

 Anyway, I won't bother to add a new option for mplayer's libass
 because there was no explict way to disable it in the past
 (and there are so many other "autodetect" options).

 I'll commit the mplayer-share's libass change (and each
 multimedia package) separately, but ride on PKGREVISION bump
 of the text reloc changes for mplayer and mencoder.

 Thanks,
 ---
 Izumi Tsutsui

From: Thomas Klausner <wiz@NetBSD.org>
To: NetBSD bugtracking <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer
 andothers
Date: Sun, 27 May 2018 14:18:28 +0200

 On Sun, May 27, 2018 at 08:43:38PM +0900, Izumi Tsutsui wrote:
 > I'll commit the mplayer-share's libass change (and each
 > multimedia package) separately, but ride on PKGREVISION bump
 > of the text reloc changes for mplayer and mencoder.

 Thanks for the explanation. It sounds good to me to include the libass
 change.
  Thomas

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: wiz@NetBSD.org
Cc: gnats-bugs@NetBSD.org, tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayerandothers
Date: Sun, 27 May 2018 21:35:41 +0900

 wiz@ wrote:

 >  Thanks for the explanation. It sounds good to me to include the libass
 >  change.

 Sure.  Thank you for your prompt review.

 ---
 Izumi Tsutsui

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer and others
Date: Sun, 27 May 2018 23:59:28 +0900

 Updated diff for HEAD to be committed:
  https://gist.github.com/tsutsui/ccd1a873116952efa96c2fca362b89c3

 * adjust ffmpeg3 PKGREVISION for HEAD
 * gmplayer is also affected so bump PKGREVISION too
 * gmplayer has own distinfo (not mplayer-share/distinfo)
 * x264-devel/Makefile has been updated for SunOS to have --disable-asm
   so merge definitions for NetBSD/i386 8.x

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53319 CVS commit: pkgsrc/multimedia/libdv
Date: Sun, 27 May 2018 15:21:09 +0000

 Module Name:	pkgsrc
 Committed By:	tsutsui
 Date:		Sun May 27 15:21:09 UTC 2018

 Modified Files:
 	pkgsrc/multimedia/libdv: Makefile Makefile.common

 Log Message:
 libdv: disable asm to avoid text relocations on NetBSD/i386 8.0.

 Bump PKGREVISION. Ok'ed by wiz@ in PR pkg/53319.


 To generate a diff of this commit:
 cvs rdiff -u -r1.15 -r1.16 pkgsrc/multimedia/libdv/Makefile \
     pkgsrc/multimedia/libdv/Makefile.common

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53319 CVS commit: pkgsrc/multimedia/x264-devel
Date: Sun, 27 May 2018 15:21:56 +0000

 Module Name:	pkgsrc
 Committed By:	tsutsui
 Date:		Sun May 27 15:21:56 UTC 2018

 Modified Files:
 	pkgsrc/multimedia/x264-devel: Makefile

 Log Message:
 x264-devel: disable asm to avoid text relocations on NetBSD/i386 8.0.

 Bump PKGREVISION.  Ok'ed by wiz@ in PR pkg/53319.


 To generate a diff of this commit:
 cvs rdiff -u -r1.66 -r1.67 pkgsrc/multimedia/x264-devel/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53319 CVS commit: pkgsrc/multimedia/xvidcore
Date: Sun, 27 May 2018 15:22:55 +0000

 Module Name:	pkgsrc
 Committed By:	tsutsui
 Date:		Sun May 27 15:22:55 UTC 2018

 Modified Files:
 	pkgsrc/multimedia/xvidcore: Makefile

 Log Message:
 xvidcore: disable asm to avoid text relocations on NetBSD/i386 8.0.

 Bump PKGREVISION.  Ok'ed by wiz@ in PR pkg/53319.


 To generate a diff of this commit:
 cvs rdiff -u -r1.45 -r1.46 pkgsrc/multimedia/xvidcore/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53319 CVS commit: pkgsrc/multimedia/ffmpeg3
Date: Sun, 27 May 2018 15:24:32 +0000

 Module Name:	pkgsrc
 Committed By:	tsutsui
 Date:		Sun May 27 15:24:32 UTC 2018

 Modified Files:
 	pkgsrc/multimedia/ffmpeg3: Makefile distinfo
 	pkgsrc/multimedia/ffmpeg3/patches: patch-configure

 Log Message:
 ffmpeg3: avoid text relocations on NetBSD/i386.

 * explicitly specify --disable-asm on NetBSD/i386
 * explicitly enable pic even for NetBSD/i386 as other architecture

 Bump PKGREVISION.  Ok'ed by wiz@ in PR pkg/53319.


 To generate a diff of this commit:
 cvs rdiff -u -r1.32 -r1.33 pkgsrc/multimedia/ffmpeg3/Makefile
 cvs rdiff -u -r1.26 -r1.27 pkgsrc/multimedia/ffmpeg3/distinfo
 cvs rdiff -u -r1.5 -r1.6 pkgsrc/multimedia/ffmpeg3/patches/patch-configure

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53319 CVS commit: pkgsrc/multimedia
Date: Sun, 27 May 2018 15:27:14 +0000

 Module Name:	pkgsrc
 Committed By:	tsutsui
 Date:		Sun May 27 15:27:14 UTC 2018

 Modified Files:
 	pkgsrc/multimedia/gmplayer: Makefile distinfo
 	pkgsrc/multimedia/mencoder: Makefile
 	pkgsrc/multimedia/mplayer: Makefile
 	pkgsrc/multimedia/mplayer-share: Makefile.cflags Makefile.common
 	    Makefile.depends distinfo
 	pkgsrc/multimedia/mplayer-share/patches: patch-aa

 Log Message:
 mencoder, mplayer, gmplayer: avoid text relocations on NetBSD/i386 8.0.

 * specify --disable-sse4 to avoid non-PIE asm ops in libmpcodecs/vf_ass.c
   that cause text relocations on NetBSD/i386
 * explicitly pull pkgsrc/multimedia/libass to avoid internal libass
   (which seems usually enabled by configure's autodetect)
 * specify -fpic in configure for NetBSD/i386 to enable __PIC__ blocks
   in some sources
 * while here, use -mtune rather than -mcpu for not only gcc4 but
   also 5.x and later

 Bump PKGREVISIONs.  Ok'ed by wiz@ in PR pkg/53319.


 To generate a diff of this commit:
 cvs rdiff -u -r1.137 -r1.138 pkgsrc/multimedia/gmplayer/Makefile
 cvs rdiff -u -r1.99 -r1.100 pkgsrc/multimedia/gmplayer/distinfo
 cvs rdiff -u -r1.67 -r1.68 pkgsrc/multimedia/mencoder/Makefile
 cvs rdiff -u -r1.100 -r1.101 pkgsrc/multimedia/mplayer/Makefile
 cvs rdiff -u -r1.8 -r1.9 pkgsrc/multimedia/mplayer-share/Makefile.cflags
 cvs rdiff -u -r1.60 -r1.61 pkgsrc/multimedia/mplayer-share/Makefile.common
 cvs rdiff -u -r1.21 -r1.22 pkgsrc/multimedia/mplayer-share/Makefile.depends
 cvs rdiff -u -r1.93 -r1.94 pkgsrc/multimedia/mplayer-share/distinfo
 cvs rdiff -u -r1.34 -r1.35 pkgsrc/multimedia/mplayer-share/patches/patch-aa

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 27 May 2018 15:39:27 +0000
State-Changed-Why:
Committed.


From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/53319 (text relocations fixes for multimedia/mplayer and
 others)
Date: Sun, 27 May 2018 15:00:07 -0500 (CDT)

 On Sun, 27 May 2018 15:39:27 +0000 (UTC), <tsutsui@NetBSD.org> wrote:

 > State-Changed-From-To: open->closed
 > State-Changed-By: tsutsui%NetBSD.org@localhost
 > State-Changed-When: Sun, 27 May 2018 15:39:27 +0000
 > State-Changed-Why:
 > Committed.

 Please extend these changes to all ffmpeg* versions in pkgsrc.  They all
 suffer the same issues and some packages depend explicitly on ffmpeg (1),
 ffmpeg2 or ffmpeg010.

 Thanks.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: "John D Baker" <jdbaker@MYLINUXISP.COM>
To: <gnats-bugs@NetBSD.org>
Cc: <jdbaker@mylinuxisp.com>
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer and others
Date: Sun, 27 May 2018 14:46:10 -0700

 Apologies for the poor formatting.  I'm having to use a web-based
 email system as my ISP is currently refusing to relay email to
 "gnats-bugs@NetBSD.org" or any of the mailing lists, claiming
 "no valid recipients".

 On Sun, 27 May 2018 15:39:27 +0000 (UTC), <tsutsui@NetBSD.org> wrote:

 > State-Changed-From-To: open->closed
 > State-Changed-By: tsutsui%NetBSD.org@localhost
 > State-Changed-When: Sun, 27 May 2018 15:39:27 +0000
 > State-Changed-Why:
 > Committed.

 Please extend these changes to all ffmpeg* versions in pkgsrc.  They all
 suffer the same issues and some packages depend explicitly on ffmpeg (1),
 ffmpeg2 or ffmpeg010.

 Thanks.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: jdbaker@mylinuxisp.com
Cc: gnats-bugs@NetBSD.org, tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/53319 (text relocations fixes for multimedia/mplayer andothers)
Date: Mon, 28 May 2018 23:56:02 +0900

 >  Please extend these changes to all ffmpeg* versions in pkgsrc.

 Please file independent PRs for the leaf packages that actually
 require the old version ffmpegs so that existing users will be
 motivated and take a look.  It's a bit pain to check and test obsolete
 versions without demand. (no ffmpeg2 or prior on my main machine)

 I filed on this PR because I actually want to use mplayer and
 PC6001VX on NetBSD/i386 8.0. (the latter has ffmpeg4 support too)

 Thanks,

 ---
 Izumi Tsutsui

From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Thu, 21 Jun 2018 20:06:12 +0200

 > Misc pkgsrc/multimedia packages including mplayer and ffpeg3
 > don't work on NetBSD/i386 8.0_RC1 because they include text relocations
 > and NetBSD 8.0_RC1 ld.elf_so rejects such binaries.

 My machine:
 NetBSD sheep 8.99.14 NetBSD 8.99.14 (SHEEPKMS) #0: Tue Mar 20 20:41:33 CET 2018  onno@sheep:/usr/src/sys/arch/i386/compile/SHEEPKMS i386

 $ ffmpeg3 -i *mkv                                                              
 /usr/pkg/lib/ffmpeg3/libavdevice.so.57: text relocations
 /usr/pkg/lib/ffmpeg3/libavfilter.so.6: text relocations
 [ ... ]
 followed by some more text relocations stuff,
 followed by *all* the information regarding the mkv file

 Seems fully functional to me. Just like my current firefox
 is happily using the same ffmpeg3 libraries that are
 giving the text relocations message.

 Maybe I'm mistaken but is mplayer giving

 > mplayer: text relocations
 > mplayer: Cannot write-enable text segment: Permission denied

 as shown in this PR enough reason to completely disable asm for i386
 on all the ffmpeg* packages, which when not used in mplayer are
 fully functional (despite the text relocations messages) with
 optimized 32-bit asm ?

 Regards,

 Onno

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: o.vd.linden@quicknet.nl, tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Fri, 22 Jun 2018 23:07:11 +0900

 >  My machine:
 >  NetBSD sheep 8.99.14 NetBSD 8.99.14 (SHEEPKMS) #0: Tue Mar 20 20:41:33 CET 2018  onno@sheep:/usr/src/sys/arch/i386/compile/SHEEPKMS i386
 >  
 >  $ ffmpeg3 -i *mkv                                                              
 >  /usr/pkg/lib/ffmpeg3/libavdevice.so.57: text relocations
 >  /usr/pkg/lib/ffmpeg3/libavfilter.so.6: text relocations
 >  [ ... ]
 >  followed by some more text relocations stuff,
 >  followed by *all* the information regarding the mkv file
 >  
 >  Seems fully functional to me.

 At least pkgsrc/emulators/PC6001VX + ffmpeg3-3.4.2nb4.tgz
 (which included asm) didn't start by the following error:

 ---
 % PC6001VX
 /usr/pkg/lib/ffmpeg3/libavformat.so.57: text relocations
 /usr/pkg/lib/ffmpeg3/libavformat.so.57: Cannot write-enable text segment: Permission denied
 % 
 ---
 Izumi Tsutsui

From: maya@netbsd.org
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Fri, 22 Jun 2018 20:17:45 +0000

 On Fri, Jun 22, 2018 at 02:10:01PM +0000, Izumi Tsutsui wrote:
 > The following reply was made to PR pkg/53319; it has been noted by GNATS.
 > 
 > From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
 > To: gnats-bugs@NetBSD.org
 > Cc: o.vd.linden@quicknet.nl, tsutsui@ceres.dti.ne.jp
 > Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
 > Date: Fri, 22 Jun 2018 23:07:11 +0900
 > 
 >  >  My machine:
 >  >  NetBSD sheep 8.99.14 NetBSD 8.99.14 (SHEEPKMS) #0: Tue Mar 20 20:41:33 CET 2018  onno@sheep:/usr/src/sys/arch/i386/compile/SHEEPKMS i386
 >  >  
 >  >  $ ffmpeg3 -i *mkv                                                              
 >  >  /usr/pkg/lib/ffmpeg3/libavdevice.so.57: text relocations
 >  >  /usr/pkg/lib/ffmpeg3/libavfilter.so.6: text relocations
 >  >  [ ... ]
 >  >  followed by some more text relocations stuff,
 >  >  followed by *all* the information regarding the mkv file
 >  >  
 >  >  Seems fully functional to me.
 >  
 >  At least pkgsrc/emulators/PC6001VX + ffmpeg3-3.4.2nb4.tgz
 >  (which included asm) didn't start by the following error:
 >  
 >  ---
 >  % PC6001VX
 >  /usr/pkg/lib/ffmpeg3/libavformat.so.57: text relocations
 >  /usr/pkg/lib/ffmpeg3/libavformat.so.57: Cannot write-enable text segment: Permission denied
 >  % 
 >  ---
 >  Izumi Tsutsui
 >  

 If someone wants to fix it, note that ld can warn about it with
 --warn-shared-textrel

From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Sat, 23 Jun 2018 20:04:45 +0200

 On Fri, Jun 22, 2018 at 11:07:11PM +0900, Izumi Tsutsui wrote:

 > ---
 > % PC6001VX
 > /usr/pkg/lib/ffmpeg3/libavformat.so.57: text relocations
 > /usr/pkg/lib/ffmpeg3/libavformat.so.57: Cannot write-enable text segment: Permission denied
 > % 
 > ---
 > Izumi Tsutsui

 Compiled mplayer 1.3.0 from pkgsrc on my i386 machine,
 needed to compile libmpcodecs/vf_filmdint.c without -fpie and -fpic
 to fix

 libmpcodecs/vf_filmdint.c: In function 'put_image':
 libmpcodecs/vf_filmdint.c:393:9: error: 'asm' operand has impossible constraints
          __asm__ volatile(                                                     \
          ^
 libmpcodecs/vf_filmdint.c:495:5: note: in expansion of macro 'BLOCK_METRICS_TEMPLATE'
      BLOCK_METRICS_TEMPLATE();

 and installed it and .........
 $ mplayer
 mplayer: text relocations
 /usr/pkg/lib/ffmpeg3/libswscale.so.4: text relocations
 /usr/pkg/lib/ffmpeg3/libswresample.so.2: text relocations
 /usr/pkg/lib/ffmpeg3/libavformat.so.57: text relocations
 /usr/pkg/lib/ffmpeg3/libavcodec.so.57: text relocations
 /usr/pkg/lib/ffmpeg3/libavutil.so.55: text relocations
 /usr/pkg/lib/ffmpeg3/libpostproc.so.54: text relocations
 /usr/pkg/lib/libx264.so.155: text relocations
 /usr/pkg/lib/libxvidcore.so.4: text relocations
 MPlayer 1.3.0-6.4.0 (C) 2000-2016 MPlayer Team
 224 audio & 451 video codecs
 Usage:   mplayer [options] [url|path/]filename

 No "Cannot write-enable text segment" and so far so good.

 Onno

From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Fri, 29 Jun 2018 15:57:19 -0500 (CDT)

 On my i386-8.0_RC2 system, mplayer built from recent pkgsrc-HEAD (in the
 freeze before pkgsrc-2018Q2) fails to run as follows:

   $ mplayer
   mplayer: text relocations
   mplayer: Cannot write-enable text segment: Permission denied

 Running mplayer through 'ktruss' ends with:

 [...]
   1541      1 mplayer  open("/usr/local/lib/libcrypt.so.1", 0, 0xbfb613cc) Err#2 ENOENT
   1541      1 mplayer  open("/lib/libcrypt.so.1", 0, 0xbfb613cc) = 3
   1541      1 mplayer  __fstat50(0x3, 0xbfb613cc)  = 0
   1541      1 mplayer  mmap(0, 0x1000, 0x1, 0x1, 0x3, 0, 0, 0) = 0xaade5000
   1541      1 mplayer  munmap(0xaade5000, 0x1000)  = 0
   1541      1 mplayer  mmap(0, 0xb000, 0x5, 0x2, 0x3, 0, 0, 0) = 0xaaddb000
   1541      1 mplayer  mmap(0xaade1000, 0x2000, 0x3, 0x12, 0x3, 0, 0x5000, 0) = 0xaade1000
   1541      1 mplayer  mmap(0xaade3000, 0x3000, 0x3, 0x1012, 0xffffffff, 0, 0, 0) = 0xaade3000
   1541      1 mplayer  close(0x3)                  = 0
   1541      1 mplayer  write(0x2, 0xbfb619ec, 0x19) = 25
        "mplayer: text relocations"
   1541      1 mplayer  write(0x2, 0xbac88872, 0x1) = 1
        "\n"
   1541      1 mplayer  mprotect(0x26000, 0x2c9000, 0x3) Err#13 EACCES
   1541      1 mplayer  write(0x2, 0xbfb61a00, 0x3c) = 60
        "mplayer: Cannot write-enable text segment: Permission denied"
   1541      1 mplayer  write(0x2, 0xbac88872, 0x1) = 1
        "\n"
   1541      1 mplayer  exit(0x1)

 which seems to indicate an issue with "/lib/libcrypt.so.1", or that
 something wants to mmap it writable...

 Even built with the "debug" option, running mplayer under 'gdb' is
 not particularly informative:

 [...]
 Reading symbols from mplayer...done.
 (gdb) run
 Starting program: /usr/pkg/bin/mplayer 
 /usr/pkg/bin/mplayer: text relocations

 Program received signal SIGSEGV, Segmentation fault.
 _rtld_relocate_plt_lazy (obj=obj@entry=0xb48d7000)
     at /x/netbsd-8/src/libexec/ld.elf_so/arch/i386/mdreloc.c:210
 210			*where += (Elf_Addr)obj->relocbase;
 (gdb) bt
 #0  _rtld_relocate_plt_lazy (obj=obj@entry=0xb48d7000)
     at /x/netbsd-8/src/libexec/ld.elf_so/arch/i386/mdreloc.c:210
 #1  0xbb24c515 in _rtld_relocate_objects (first=0xb48d7000, 
     bind_now=bind_now@entry=false)
     at /x/netbsd-8/src/libexec/ld.elf_so/reloc.c:213
 #2  0xbb24ae89 in _rtld (sp=<optimized out>, relocbase=3139731456)
     at /x/netbsd-8/src/libexec/ld.elf_so/rtld.c:694
 #3  0xbb2484aa in .rtld_start () from /usr/libexec/ld.elf_so
 (gdb) list
 205			Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
 206	
 207			assert(ELF_R_TYPE(rel->r_info) == R_TYPE(JMP_SLOT));
 208	
 209			/* Just relocate the GOT slots pointing into the PLT */
 210			*where += (Elf_Addr)obj->relocbase;
 211			rdbg(("fixup !main in %s --> %p", obj->path, (void *)*where));
 212		}
 213	
 214		return 0;
 (gdb) continue
 Continuing.

 Program terminated with signal SIGSEGV, Segmentation fault.
 The program no longer exists.
 (gdb) quit


 As some have noted, other ffmpeg3 users work OK on i386 (notably firefox).

 The previous addendum to this PR indicated a problem and a solution, but
 that scenario does not seem to exist in my case.

 Any clues?  'mplayer' is the last show-stopper keeping me from using
 netbsd-8 on my i386 systems.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Fri, 29 Jun 2018 16:54:54 -0500 (CDT)

 On Fri, 29 Jun 2018, John D. Baker wrote:

 >   1541      1 mplayer  write(0x2, 0xbfb619ec, 0x19) = 25
 >        "mplayer: text relocations"
 >   1541      1 mplayer  write(0x2, 0xbac88872, 0x1) = 1
 >        "\n"
 >   1541      1 mplayer  mprotect(0x26000, 0x2c9000, 0x3) Err#13 EACCES
 >   1541      1 mplayer  write(0x2, 0xbfb61a00, 0x3c) = 60
 >        "mplayer: Cannot write-enable text segment: Permission denied"
 >   1541      1 mplayer  write(0x2, 0xbac88872, 0x1) = 1
 >        "\n"
 >   1541      1 mplayer  exit(0x1)
 > 
 > which seems to indicate an issue with "/lib/libcrypt.so.1", or that
 > something wants to mmap it writable...

 Nothing to do with libcrypt.so.1.  It would help if I'd read the manual
 pages for the system calls involved.

 So, mprotect() is being called with prot=3 (-wx) for a region of memory
 at 0x26000.

 Looking earlier in the 'ktruss' output shows several instances of "26000".
 Two are the requsted length for mmap()ing "/usr/lib/libexpat.so.2" and
 "/usr/X11R7/lib/libxcb.so.2", respectively.  Another is a byte offset
 into "/usr/lib/liblzma.so.2" to be mmap()ed.  The rest are tails of
 longer addresses either requested of or returned by mmap().

 Not sure what it's doing, then.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: jdbaker@mylinuxisp.com, gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Sat, 30 Jun 2018 07:20:46 +0900

 Could you please file a new PR for your problem?
 I think it's an independent problem.

 Thanks,
 ---
 Izumi Tsutsui

From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Mon, 13 Aug 2018 18:22:12 +0200

 Compiled and installed PC6001VX and its dependencies:
 pkg_info -s PC6001VX
 Information for PC6001VX-2.33.0nb2:

 Size of this package in bytes: 3028698

 $ PC6001VX                                                                     
 /usr/pkg/lib/ffmpeg3/libavformat.so.57: text relocations
 /usr/pkg/lib/ffmpeg3/libavcodec.so.57: text relocations
 /usr/pkg/lib/ffmpeg3/libswscale.so.4: text relocations
 /usr/pkg/lib/ffmpeg3/libswresample.so.2: text relocations
 /usr/pkg/lib/ffmpeg3/libavutil.so.55: text relocations
 /usr/pkg/lib/libxvidcore.so.4: text relocations
 /usr/pkg/lib/libx264.so.155: text relocations
 QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-onno'
 QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-onno'
 LANG =  "C"


 and an error window saying that the ROM files are not found.

 no "Cannot write-enable text segment: Permission denied" whatsoever on 
 NetBSD sheep 8.99.24 NetBSD 8.99.24 (SHEEPKMS) #4: Sat Aug 11 11:29:18 CEST 2018  onno@sheep:/usr/src/sys/arch/i386/compile/SHEEPKMS i386

 just like ffmpeg, mplayer and firefox as demonstrated earlier in this PR.

 I have my doubts about disabling asm completely for i386 as a fix
 for the "Cannot write-enable text segment: Permission denied" error.

 pkg/53414 mentions paxctl related configuration.
 I build my asm optimized ffmpeg3 on Mar 19 2018. It could be
 that after that date some default changed causing the error
 messages running newly build binaries.

 Onno

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: o.vd.linden@quicknet.nl, tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Tue, 14 Aug 2018 03:52:09 +0900

 >  just like ffmpeg, mplayer and firefox as demonstrated earlier in this PR.
 >  
 >  I have my doubts about disabling asm completely for i386 as a fix
 >  for the "Cannot write-enable text segment: Permission denied" error.

 I cannot reproduce your problem on my NetBSD/i386 8.0 + pkgsrc-2018Q2
 environment (for my own liveimage):

 ---
 # uname -a
 NetBSD teokure 8.0 NetBSD 8.0 (GENERIC) #0: Tue Jul 17 14:59:51 UTC 2018  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/i386/compile/GENERIC i386
 # pkg_info
 # PKG_PATH=http://teokurebsd.org/netbsd/packages/i386/8.0_2018Q2/All pkg_add PC6001VX mplayer
 libffi-3.2.1nb4: registering info file /usr/pkg/info/libffi.info
 No schema files found: doing nothing.

  :

 pulseaudio-11.1nb5: copying /usr/pkg/share/examples/pulseaudio/pulseaudio-system.conf to /usr/pkg/etc/dbus-1/system.d/pulseaudio-system.conf
 pulseaudio-11.1nb5: copying /usr/pkg/share/examples/pulseaudio/client.conf to /usr/pkg/etc/pulse/client.conf
 pulseaudio-11.1nb5: copying /usr/pkg/share/examples/pulseaudio/daemon.conf to /usr/pkg/etc/pulse/daemon.conf
 pulseaudio-11.1nb5: copying /usr/pkg/share/examples/pulseaudio/default.pa to /usr/pkg/etc/pulse/default.pa
 pulseaudio-11.1nb5: copying /usr/pkg/share/examples/pulseaudio/system.pa to /usr/pkg/etc/pulse/system.pa
 libvdpau-1.1.1nb2: copying /usr/pkg/share/examples/libvdpau/vdpau_wrapper.cfg to /usr/pkg/etc/vdpau_wrapper.cfg
 ffmpeg3-3.4.2nb6: copying /usr/pkg/share/examples/ffmpeg3/ffserver.conf to /usr/pkg/etc/ffserver.conf
 ===========================================================================
 $NetBSD: MESSAGE,v 1.1.1.1 2004/01/28 14:29:01 recht Exp $

 Because of the unclear legal status of libdvdcss, it is not automatically
 installed as part of libdvdread. It is however needed to play encrypted
 DVDs. If you want to play encrypted DVDs, simply install it yourself.

 ===========================================================================
 esound-0.2.41nb3: copying /usr/pkg/share/examples/esound/esd.conf to /usr/pkg/etc/esd.conf
 nas-1.9.4: copying /usr/pkg/share/examples/nas/nasd.conf.eg to /usr/pkg/etc/nas/nasd.conf
 ===========================================================================
 The following files should be created for nas-1.9.4:

         /etc/rc.d/nasd (m=0755)
             [/usr/pkg/share/examples/rc.d/nasd]

 ===========================================================================
 ===========================================================================
 $NetBSD: MESSAGE,v 1.1 2017/10/27 01:28:53 nat Exp $

 To enable dma for use with NetBSD-8 or above.

 Set the following environment variables:
         SDL_DSP_DMA_PRECISION
         SDL_DSP_DMA_FREQ
         SDL_DSP_DMA_CHANNELS

         SDL_DSP_NOSELECT=1

 DMA parameters must match the hw virtual channel format for playback to
 work with dma.

 ===========================================================================
 # exit
 exit
 teokure-% rehash
 teokure-% mplayer
 Creating config file: /home/mikutter/.mplayer/config
 MPlayer 1.3.0-5.5.0 (C) 2000-2016 MPlayer Team
 224 audio & 451 video codecs
 Usage:   mplayer [options] [url|path/]filename

 Basic options: (complete list in the man page)
  -vo <drv>        select video output driver ('-vo help' for a list)
  -ao <drv>        select audio output driver ('-ao help' for a list)
  vcd://<trackno>  play (S)VCD (Super Video CD) track (raw device, no mount)
  dvd://<titleno>  play DVD title from device instead of plain file
  -alang/-slang    select DVD audio/subtitle language (by 2-char country code)
  -ss <position>   seek to given (seconds or hh:mm:ss) position
  -nosound         do not play sound
  -fs              fullscreen playback (or -vm, -zoom, details in the man page)
  -x <x> -y <y>    set display resolution (for use with -vm or -zoom)
  -sub <file>      specify subtitle file to use (also see -subfps, -subdelay)
  -playlist <file> specify playlist file
  -vid x -aid y    select video (x) and audio (y) stream to play
  -fps x -srate y  change video (x fps) and audio (y Hz) rate
  -pp <quality>    enable postprocessing filter (details in the man page)
  -framedrop       enable frame dropping (for slow machines)

 Basic keys: (complete list in the man page, also check input.conf)
  <-  or  ->       seek backward/forward 10 seconds
  down or up       seek backward/forward  1 minute
  pgdown or pgup   seek backward/forward 10 minutes
  < or >           step backward/forward in playlist
  p or SPACE       pause movie (press any key to continue)
  q or ESC         stop playing and quit program
  + or -           adjust audio delay by +/- 0.1 second
  o                cycle OSD mode:  none / seekbar / seekbar + timer
  * or /           increase or decrease PCM volume
  x or z           adjust subtitle delay by +/- 0.1 second
  r or t           adjust subtitle position up/down, also see -vf expand

  * * * SEE THE MAN PAGE FOR DETAILS, FURTHER (ADVANCED) OPTIONS AND KEYS * * *

 teokure-% PC6001VX
 QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-mikutter'
 QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-mikutter'

 ["ROM files not found" error window]

 ---

 Maybe -current specific?

 ---
 Izumi Tsutsui

From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Cc: gnats-bugs@netbsd.org
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Mon, 13 Aug 2018 21:36:16 +0200

 On Tue, Aug 14, 2018 at 03:52:09AM +0900, Izumi Tsutsui wrote:
 > >  just like ffmpeg, mplayer and firefox as demonstrated earlier in this PR.
 > >  
 > >  I have my doubts about disabling asm completely for i386 as a fix
 > >  for the "Cannot write-enable text segment: Permission denied" error.
 > 
 > I cannot reproduce your problem on my NetBSD/i386 8.0 + pkgsrc-2018Q2
 > environment (for my own liveimage):

 I don't have any problem at all with -current running anything that
 was build with i386 assembler enabled which on 8.0 NetBSD/i386 is causing
 "Cannot write-enable text segment: Permission denied".
 This was fixed with a non too subtle "disable asm" fix in
 the Makefile of a handful of programs in pkgsrc. I have some
 doubts wether this was the right thing to do.

 As I've demonstrated in earlier reports to this PR I was able to
 compile and run everything (PC6001VX, mplayer and ffmpeg) on -current
 that gave "Cannot write-enable text segment" with asm enabled
 in your initial PR for 8.0.

 To be sure I've just compiled ffmpeg4 with asm enabled and
 that also runs without any problem at all.

 So, the question is why I don't have any problem running these
 programs with asm *enabled* on -current ? Could be paxctl
 and FORTIFY_SOURCE related, but why am I not seeing the
 error messages you were seeing with the programs that were build
 using the i386 assemebler code ? Were the 8.0 binaries build
 with stricter options ?


 Regards,

 Onno

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: o.vd.linden@quicknet.nl
Cc: gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Tue, 14 Aug 2018 05:50:52 +0900

 > So, the question is why I don't have any problem running these
 > programs with asm *enabled* on -current ? Could be paxctl
 > and FORTIFY_SOURCE related, but why am I not seeing the
 > error messages you were seeing with the programs that were build
 > using the i386 assemebler code ? Were the 8.0 binaries build
 > with stricter options ?

 How did you enable x86 asm in ffmpeg3 from pkgsrc-2018Q2?

 mplayer doesn't start if it's enabled as the following:

 ---
 mirage# uname -a
 NetBSD mirage 8.0 NetBSD 8.0 (GENERIC) #0: Tue Jul 17 14:59:51 UTC 2018  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/i386/compile/GENERIC i386
 mirage# pkg_add -U http://teokurebsd.org/netbsd/packages/i386/8.0_2018Q2/All/ffmpeg3
 ffmpeg3-3.4.2nb6: copying /usr/pkg/share/examples/ffmpeg3/ffserver.conf to /usr/pkg/etc/ffserver.conf
 mirage# mplayer
 MPlayer 1.3.0-5.5.0 (C) 2000-2016 MPlayer Team
 224 audio & 451 video codecs
 Usage:   mplayer [options] [url|path/]filename

 Basic options: (complete list in the man page)
  -vo <drv>        select video output driver ('-vo help' for a list)
  -ao <drv>        select audio output driver ('-ao help' for a list)
  vcd://<trackno>  play (S)VCD (Super Video CD) track (raw device, no mount)
  dvd://<titleno>  play DVD title from device instead of plain file
  -alang/-slang    select DVD audio/subtitle language (by 2-char country code)
  -ss <position>   seek to given (seconds or hh:mm:ss) position
  -nosound         do not play sound
  -fs              fullscreen playback (or -vm, -zoom, details in the man page)
  -x <x> -y <y>    set display resolution (for use with -vm or -zoom)
  -sub <file>      specify subtitle file to use (also see -subfps, -subdelay)
  -playlist <file> specify playlist file
  -vid x -aid y    select video (x) and audio (y) stream to play
  -fps x -srate y  change video (x fps) and audio (y Hz) rate
  -pp <quality>    enable postprocessing filter (details in the man page)
  -framedrop       enable frame dropping (for slow machines)

 Basic keys: (complete list in the man page, also check input.conf)
  <-  or  ->       seek backward/forward 10 seconds
  down or up       seek backward/forward  1 minute
  pgdown or pgup   seek backward/forward 10 minutes
  < or >           step backward/forward in playlist
  p or SPACE       pause movie (press any key to continue)
  q or ESC         stop playing and quit program
  + or -           adjust audio delay by +/- 0.1 second
  o                cycle OSD mode:  none / seekbar / seekbar + timer
  * or /           increase or decrease PCM volume
  x or z           adjust subtitle delay by +/- 0.1 second
  r or t           adjust subtitle position up/down, also see -vf expand

  * * * SEE THE MAN PAGE FOR DETAILS, FURTHER (ADVANCED) OPTIONS AND KEYS * * *

 mirage# cd /usr/pkgsrc/multimedia/ffmpeg3/
 mirage# pwd
 /usr/pkgsrc/multimedia/ffmpeg3
 mirage# cat CVS/Tag 
 Tpkgsrc-2018Q2
 mirage# cvs diff
 ? work.i386
 cvs diff: Diffing .
 Index: Makefile
 ===================================================================
 RCS file: /cvsroot/pkgsrc/multimedia/ffmpeg3/Makefile,v
 retrieving revision 1.33
 diff -u -p -r1.33 Makefile
 --- Makefile    27 May 2018 15:24:32 -0000      1.33
 +++ Makefile    13 Aug 2018 20:29:29 -0000
 @@ -45,7 +45,7 @@ post-install:
  .if ${MACHINE_ARCH} == "i386"
  .  if !empty(MACHINE_PLATFORM:MDarwin-*-i386) \
     || !empty(MACHINE_PLATFORM:MSunOS-*-i386) \
 -   || !empty(MACHINE_PLATFORM:MNetBSD-*-i386) \
 +#   || !empty(MACHINE_PLATFORM:MNetBSD-*-i386) \
     || !empty(CC_VERSION:Mgcc-[123]*) \
     || !empty(CC_VERSION:Mgcc-4.[01].*) \
     || empty(CC_VERSION:Mgcc*)
 cvs diff: Diffing patches
 mirage# pkg_add -U work.i386/.packages/ffmpeg3-3.4.2nb6.tgz 
 ffmpeg3-3.4.2nb6: copying /usr/pkg/share/examples/ffmpeg3/ffserver.conf to /usr/pkg/etc/ffserver.conf
 mirage# mplayer 
 /usr/pkg/lib/ffmpeg3/libswscale.so.4: text relocations
 /usr/pkg/lib/ffmpeg3/libswscale.so.4: Cannot write-enable text segment: Permission denied
 mirage# pkg_add -U http://teokurebsd.org/netbsd/packages/i386/8.0_2018Q2/All/ffmpeg3
 ffmpeg3-3.4.2nb6: copying /usr/pkg/share/examples/ffmpeg3/ffserver.conf to /usr/pkg/etc/ffserver.conf
 mirage# mplayer
 MPlayer 1.3.0-5.5.0 (C) 2000-2016 MPlayer Team
 224 audio & 451 video codecs
 Usage:   mplayer [options] [url|path/]filename

 Basic options: (complete list in the man page)
  -vo <drv>        select video output driver ('-vo help' for a list)
  -ao <drv>        select audio output driver ('-ao help' for a list)
  vcd://<trackno>  play (S)VCD (Super Video CD) track (raw device, no mount)
  dvd://<titleno>  play DVD title from device instead of plain file
  -alang/-slang    select DVD audio/subtitle language (by 2-char country code)
  -ss <position>   seek to given (seconds or hh:mm:ss) position
  -nosound         do not play sound
  -fs              fullscreen playback (or -vm, -zoom, details in the man page)
  -x <x> -y <y>    set display resolution (for use with -vm or -zoom)
  -sub <file>      specify subtitle file to use (also see -subfps, -subdelay)
  -playlist <file> specify playlist file
  -vid x -aid y    select video (x) and audio (y) stream to play
  -fps x -srate y  change video (x fps) and audio (y Hz) rate
  -pp <quality>    enable postprocessing filter (details in the man page)
  -framedrop       enable frame dropping (for slow machines)

 Basic keys: (complete list in the man page, also check input.conf)
  <-  or  ->       seek backward/forward 10 seconds
  down or up       seek backward/forward  1 minute
  pgdown or pgup   seek backward/forward 10 minutes
  < or >           step backward/forward in playlist
  p or SPACE       pause movie (press any key to continue)
  q or ESC         stop playing and quit program
  + or -           adjust audio delay by +/- 0.1 second
  o                cycle OSD mode:  none / seekbar / seekbar + timer
  * or /           increase or decrease PCM volume
  x or z           adjust subtitle delay by +/- 0.1 second
  r or t           adjust subtitle position up/down, also see -vf expand

  * * * SEE THE MAN PAGE FOR DETAILS, FURTHER (ADVANCED) OPTIONS AND KEYS * * *

 mirage# 
 ---

 Anyway, there are strong complaints about text relocations:
  http://mail-index.netbsd.org/pkgsrc-bugs/2018/04/28/msg063868.html
  http://mail-index.netbsd.org/pkgsrc-bugs/2018/04/28/msg063878.html
  http://mail-index.netbsd.org/pkgsrc-bugs/2018/04/28/msg063881.html

 That was the reason why I filed this PR to disable them completely.

 ---
 Izumi Tsutsui

From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Cc: gnats-bugs@netbsd.org
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Mon, 13 Aug 2018 23:19:51 +0200

 On Tue, Aug 14, 2018 at 05:50:52AM +0900, Izumi Tsutsui wrote:
 > > So, the question is why I don't have any problem running these
 > > programs with asm *enabled* on -current ? Could be paxctl
 > > and FORTIFY_SOURCE related, but why am I not seeing the
 > > error messages you were seeing with the programs that were build
 > > using the i386 assemebler code ? Were the 8.0 binaries build
 > > with stricter options ?
 > 
 > How did you enable x86 asm in ffmpeg3 from pkgsrc-2018Q2?

 Compiled and installed ffmpeg3 on Mar 19 2018 using the
 -current pkgsrc from that timestamp with a -current system
 from that timestamp  when the noasm option wasn't
 around in the Makefile.

 > 
 > mplayer doesn't start if it's enabled as the following:

 It does for me, with -current.

 However, I noticed your mplayer is compiled with gcc 5.5.0.
 Mine is compiled with gcc 6.4.0. No idea if that's the
 reason for you getting the "Cannot write-enable text segment"
 error messages.

 > Anyway, there are strong complaints about text relocations:
 >  http://mail-index.netbsd.org/pkgsrc-bugs/2018/04/28/msg063868.html
 >  http://mail-index.netbsd.org/pkgsrc-bugs/2018/04/28/msg063878.html
 >  http://mail-index.netbsd.org/pkgsrc-bugs/2018/04/28/msg063881.html
 > 
 > That was the reason why I filed this PR to disable them completely.

 If disabling i386 assembler code fixes the
 "Cannot write-enable text segment: Permission denied" errors, fine.
 But, I have yet to see any such message and the text reloction
 messages don't bother me that much. I'd love to see a more subtle
 way to fix this.

 Question still remains why am I only getting the text relocation
 warning messages and no error message whatsoever ? Is it due
 to gcc 6.4 vs gcc 5.5 and its handling of FORTIFY_SOURCE ?

 Regards,

 Onno

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: o.vd.linden@quicknet.nl
Cc: gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Tue, 14 Aug 2018 11:03:20 +0900

 > > How did you enable x86 asm in ffmpeg3 from pkgsrc-2018Q2?
 > 
 > Compiled and installed ffmpeg3 on Mar 19 2018 using the
 > -current pkgsrc from that timestamp with a -current system
 > from that timestamp  when the noasm option wasn't
 > around in the Makefile.

 Well, it would be better to see exact reproducible procedure
 with some specific release versions/binaries and misc settings.

 > > mplayer doesn't start if it's enabled as the following:
 > 
 > It does for me, with -current.
 > 
 > However, I noticed your mplayer is compiled with gcc 5.5.0.
 > Mine is compiled with gcc 6.4.0. No idea if that's the
 > reason for you getting the "Cannot write-enable text segment"
 > error messages.

 No idea, but if it works even with "text relocations" warnings,
 I think it is a bug, or environment specific settings. (see below)

 > > Anyway, there are strong complaints about text relocations:
 > >  http://mail-index.netbsd.org/pkgsrc-bugs/2018/04/28/msg063868.html
 > >  http://mail-index.netbsd.org/pkgsrc-bugs/2018/04/28/msg063878.html
 > >  http://mail-index.netbsd.org/pkgsrc-bugs/2018/04/28/msg063881.html
 > > 
 > > That was the reason why I filed this PR to disable them completely.
 > 
 > If disabling i386 assembler code fixes the
 > "Cannot write-enable text segment: Permission denied" errors, fine.
 > But, I have yet to see any such message and the text reloction
 > messages don't bother me that much. I'd love to see a more subtle
 > way to fix this.

 Do you still get text relocations warnings with pkgsrc-2018Q2 binaries?

 Or do you just think the old version (around Mar 19?) of ffmpeg3
 is fine because it doesn't cause errors but only warnings?

 > Question still remains why am I only getting the text relocation
 > warning messages and no error message whatsoever ? Is it due
 > to gcc 6.4 vs gcc 5.5 and its handling of FORTIFY_SOURCE ?

 The "text relocations" warned by ld.elf_so are actually deprecated,
 as mentioned in this message:
  http://mail-index.netbsd.org/pkgsrc-bugs/2018/04/28/msg063878.html

 It looks the relocations require a write permission during
 dynamic linking by ld.elf_so:
  https://nxr.netbsd.org/xref/src/libexec/ld.elf_so/reloc.c?a=true&r=1.112#188
 I guess the result of the mprotect(2) depends on sysctl(3) settings:
 > security.pax.mprotect.enabled = 1
 > security.pax.mprotect.global = 1

 Maybe you omitted "options PAX_MPROTECT=1" from conf/GENERIC
  https://nxr.netbsd.org/xref/src/sys/arch/i386/conf/GENERIC?r=1.1188#1536
 in your own kernel config?

 ---
 mirage# pkg_add -U work.i386/.packages/ffmpeg3-3.4.2nb6.tgz
 ffmpeg3-3.4.2nb6: copying /usr/pkg/share/examples/ffmpeg3/ffserver.conf to /usr/pkg/etc/ffserver.conf
 mirage# mplayer
 /usr/pkg/lib/ffmpeg3/libswscale.so.4: text relocations
 /usr/pkg/lib/ffmpeg3/libswscale.so.4: Cannot write-enable text segment: Permission denied
 mirage# sysctl -w security.pax.mprotect.enabled=0
 security.pax.mprotect.enabled: 1 -> 0
 mirage# mplayer
 /usr/pkg/lib/ffmpeg3/libswscale.so.4: text relocations
 /usr/pkg/lib/ffmpeg3/libswresample.so.2: text relocations
 /usr/pkg/lib/ffmpeg3/libavcodec.so.57: text relocations
 /usr/pkg/lib/ffmpeg3/libavutil.so.55: text relocations
 /usr/pkg/lib/ffmpeg3/libpostproc.so.54: text relocations
 MPlayer 1.3.0-5.5.0 (C) 2000-2016 MPlayer Team
 224 audio & 451 video codecs
 Usage:   mplayer [options] [url|path/]filename

 Basic options: (complete list in the man page)
  -vo <drv>        select video output driver ('-vo help' for a list)
  -ao <drv>        select audio output driver ('-ao help' for a list)
  vcd://<trackno>  play (S)VCD (Super Video CD) track (raw device, no mount)
  dvd://<titleno>  play DVD title from device instead of plain file
  -alang/-slang    select DVD audio/subtitle language (by 2-char country code)
  -ss <position>   seek to given (seconds or hh:mm:ss) position
  -nosound         do not play sound
  -fs              fullscreen playback (or -vm, -zoom, details in the man page)
  -x <x> -y <y>    set display resolution (for use with -vm or -zoom)
  -sub <file>      specify subtitle file to use (also see -subfps, -subdelay)
  -playlist <file> specify playlist file
  -vid x -aid y    select video (x) and audio (y) stream to play
  -fps x -srate y  change video (x fps) and audio (y Hz) rate
  -pp <quality>    enable postprocessing filter (details in the man page)
  -framedrop       enable frame dropping (for slow machines)

 Basic keys: (complete list in the man page, also check input.conf)
  <-  or  ->       seek backward/forward 10 seconds
  down or up       seek backward/forward  1 minute
  pgdown or pgup   seek backward/forward 10 minutes
  < or >           step backward/forward in playlist
  p or SPACE       pause movie (press any key to continue)
  q or ESC         stop playing and quit program
  + or -           adjust audio delay by +/- 0.1 second
  o                cycle OSD mode:  none / seekbar / seekbar + timer
  * or /           increase or decrease PCM volume
  x or z           adjust subtitle delay by +/- 0.1 second
  r or t           adjust subtitle position up/down, also see -vf expand

  * * * SEE THE MAN PAGE FOR DETAILS, FURTHER (ADVANCED) OPTIONS AND KEYS * * *

 mirage# 
 ---

 Even if the binaries work with warnings by disabiling security stuff,
 it will never be accepted by other developers.

 To solve the text relocations, you have to rewrite all ancient asm code
 to support PIE, as done is this xvid patch:
  https://bugs.gentoo.org/90287

 Thanks,
 ---
 Izumi Tsutsui

From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Cc: gnats-bugs@netbsd.org
Subject: Re: pkg/53319: text relocations fixes for multimedia/mplayer others
Date: Tue, 14 Aug 2018 18:14:34 +0200

 On Tue, Aug 14, 2018 at 11:03:20AM +0900, Izumi Tsutsui wrote:
 > It looks the relocations require a write permission during
 > dynamic linking by ld.elf_so:
 >  https://nxr.netbsd.org/xref/src/libexec/ld.elf_so/reloc.c?a=true&r=1.112#188
 > I guess the result of the mprotect(2) depends on sysctl(3) settings:
 > > security.pax.mprotect.enabled = 1
 > > security.pax.mprotect.global = 1
 > 
 > Maybe you omitted "options PAX_MPROTECT=1" from conf/GENERIC
 >  https://nxr.netbsd.org/xref/src/sys/arch/i386/conf/GENERIC?r=1.1188#1536
 > in your own kernel config?

 Now that I've compiled and installed a kernel using a config file
 that has the last 20 lines from GENERIC containing among others
 all the PAX related options I'm finally seeing
 the "Cannot write-enable text segement: Permission denied" error.
 Many thanks for figuring that one out for me.
 How on earth did I miss it :-(

 So the question I'm asking is if it's possible to handle the
 i386 assembler option for the concerned packages somewhat
 more subtle than just noasm. Yes, the default should still
 be noasm but with an option to override it. Based on that
 option paxctl +m should be run on the created binary.

 There could be one x86asm supported option for ffmpeg that's
 used to not set noasm in ffmpeg*/Makefile in the i386 case
 and a check in for example PC6001VX/Makefile if ffmpeg has
 not been compiled with noasm (ffmpeg -h 2>&1 | grep noasm)
 to run paxctl +m the PC6001VX binary.

 Regards,

 Onno

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.