pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/53319: text relocations fixes for multimedia/mplayer and others



>Number:         53319
>Category:       pkg
>Synopsis:       text relocations fixes for multimedia/mplayer and others
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 27 09:25:00 +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@localhost
 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



Home | Main Index | Thread Index | Old Index