public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sergei Trofimovich" <slyfox@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: games-emulation/zsnes/, games-emulation/zsnes/files/
Date: Tue, 11 May 2021 22:57:25 +0000 (UTC)	[thread overview]
Message-ID: <1620773843.8b2eebf5117453efbe1e62e6314ad58614c0d587.slyfox@gentoo> (raw)

commit:     8b2eebf5117453efbe1e62e6314ad58614c0d587
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Tue May 11 22:54:44 2021 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Tue May 11 22:57:23 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8b2eebf5

games-emulation/zsnes: fix more ao and stack alignment crashes

Package-Manager: Portage-3.0.18, Repoman-3.0.3
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 .../zsnes/files/zsnes-1.51-ao-crash.patch          |  30 +++++
 .../zsnes/files/zsnes-1.51-stack-align-v3.patch    |  40 +++++++
 games-emulation/zsnes/zsnes-1.51-r10.ebuild        | 128 +++++++++++++++++++++
 3 files changed, 198 insertions(+)

diff --git a/games-emulation/zsnes/files/zsnes-1.51-ao-crash.patch b/games-emulation/zsnes/files/zsnes-1.51-ao-crash.patch
new file mode 100644
index 00000000000..6ce142d9c27
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-ao-crash.patch
@@ -0,0 +1,30 @@
+Fix frash in uninitialized driver_format.matrix.
+
+Thread 1 "zsnes" received signal SIGSEGV, Segmentation fault.
+__strlen_sse2_bsf () at ../sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S:50
+50      ../sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S: Нет такого файла или каталога.
+(gdb) bt
+#0  __strlen_sse2_bsf () at ../sysdeps/i386/i686/multiarch/strlen-sse2-bsf.S:50
+#1  0xf7e3c491 in _sanitize_matrix (maxchannels=2, matrix=0x1c00200 <error: Cannot access memory at address 0x1c00200>, device=device@entry=0x57057100)
+    at ../../libao-1.2.2/src/audio_out.c:634
+#2  0xf7e3e9bc in _open_device (driver_id=<optimized out>, format=format@entry=0xffffc638, options=options@entry=0x0, file=0x0) at ../../libao-1.2.2/src/audio_out.c:991
+#3  0xf7e3f579 in ao_open_live (driver_id=<optimized out>, format=0xffffc638, options=0x0) at ../../libao-1.2.2/src/audio_out.c:1337
+#4  0x5699fbb5 in SoundInit_ao () at linux/audio.c:197
+#5  InitSound () at linux/audio.c:338
+#6  0x569a2f7f in initwinvideo () at linux/sdllink.c:1080
+#7  0x569a07d3 in initvideo ()
+#8  0x56ad59bc in regptwa ()
+#9  0x56a3c490 in SA1tableG ()
+#10 0xffffc808 in ?? ()
+#11 0xf78619b5 in __libc_start_main (main=0x1, argc=1450015920, argv=0x0, init=0x566d7ce1 <_start+49>, fini=0x566d7c00 <main>, rtld_fini=0x1, stack_end=0xffffc8c4) at ../csu/libc-start.c:332
+#12 0x569cd000 in ?? ()
+--- a/linux/audio.c
++++ b/linux/audio.c
+@@ -166,6 +166,7 @@ static int SoundInit_ao()
+   if (driver_id < 0) { driver_id = ao_default_driver_id(); }
+ 
+   ao_sample_format driver_format;
++  memset(&driver_format, 0, sizeof(driver_format));
+   driver_format.bits = 16;
+   driver_format.channels = StereoSound+1;
+   driver_format.rate = freqtab[SoundQuality = ((SoundQuality > 6) ? 1 : SoundQuality)];

diff --git a/games-emulation/zsnes/files/zsnes-1.51-stack-align-v3.patch b/games-emulation/zsnes/files/zsnes-1.51-stack-align-v3.patch
new file mode 100644
index 00000000000..914c9afc449
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-stack-align-v3.patch
@@ -0,0 +1,40 @@
+--- a/linux/sdllink.c
++++ b/linux/sdllink.c
+@@ -133,7 +133,7 @@ extern unsigned char romispal;
+ 
+ /* FUNCTION DECLARATIONS */
+ void clearwin (void);
+-void drawscreenwin(void);
++void __attribute__((force_align_arg_pointer)) drawscreenwin(void);
+ void initwinvideo();
+ unsigned int sdl_keysym_to_pc_scancode(int);
+ void ProcessKeyBuf(int);
+--- a/ztimec.c
++++ b/ztimec.c
+@@ -25,7 +25,7 @@ short SystemTimewHour;
+ short SystemTimewMinute;
+ short SystemTimewSecond;
+ 
+-void GetLocalTime()
++void __attribute__((force_align_arg_pointer)) GetLocalTime()
+ {
+   time_t current;
+   struct tm *timeptr;
+@@ -37,7 +37,7 @@ void GetLocalTime()
+   SystemTimewSecond = timeptr->tm_sec;
+ }
+ 
+-unsigned int GetTime()
++unsigned __attribute__((force_align_arg_pointer)) int GetTime()
+ {
+   unsigned int value;
+   struct tm *newtime;
+@@ -52,7 +52,7 @@ unsigned int GetTime()
+   return(value);
+ }
+ 
+-unsigned int GetDate()
++unsigned __attribute__((force_align_arg_pointer))  int GetDate()
+ {
+   unsigned int value;
+   struct tm *newtime;

diff --git a/games-emulation/zsnes/zsnes-1.51-r10.ebuild b/games-emulation/zsnes/zsnes-1.51-r10.ebuild
new file mode 100644
index 00000000000..ffa490ba20b
--- /dev/null
+++ b/games-emulation/zsnes/zsnes-1.51-r10.ebuild
@@ -0,0 +1,128 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit autotools desktop flag-o-matic toolchain-funcs pax-utils
+
+DESCRIPTION="SNES (Super Nintendo) emulator that uses x86 assembly"
+HOMEPAGE="https://www.zsnes.com/ http://ipherswipsite.com/zsnes/"
+SRC_URI="mirror://sourceforge/zsnes/${PN}${PV//./}src.tar.bz2 -> ${P}-20071031.tar.bz2"
+S="${WORKDIR}/${PN}_${PV//./_}/src"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="-* ~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="ao custom-cflags +debug opengl png"
+
+RDEPEND="
+	media-libs/libsdl[sound,video,abi_x86_32(-)]
+	>=sys-libs/zlib-1.2.3-r1[abi_x86_32(-)]
+	ao? ( media-libs/libao[abi_x86_32(-)] )
+	debug? ( sys-libs/ncurses:0=[abi_x86_32(-)] )
+	opengl? ( virtual/opengl[abi_x86_32(-)] )
+	png? ( media-libs/libpng:0=[abi_x86_32(-)] )
+"
+DEPEND="${RDEPEND}"
+BDEPEND="
+	dev-lang/nasm
+	debug? ( virtual/pkgconfig )
+"
+
+PATCHES=(
+	# Fixing compilation without libpng installed
+	"${FILESDIR}"/${P}-libpng.patch
+
+	# Fix bug #186111
+	# Fix bug #214697
+	# Fix bug #170108
+	# Fix bug #260247
+	"${FILESDIR}"/${P}-gcc43-20071031.patch
+	"${FILESDIR}"/${P}-libao-thread.patch
+	"${FILESDIR}"/${P}-depbuild.patch
+	"${FILESDIR}"/${P}-CC-quotes.patch
+
+	# Fix compability with libpng15 wrt #378735
+	"${FILESDIR}"/${P}-libpng15.patch
+
+	# Fix buffer overwrite #257963
+	"${FILESDIR}"/${P}-buffer.patch
+	# Fix gcc47 compile #419635
+	"${FILESDIR}"/${P}-gcc47.patch
+	# Fix stack alignment issue #503138
+	"${FILESDIR}"/${P}-stack-align-v2.patch
+
+	"${FILESDIR}"/${P}-cross-compile.patch
+	"${FILESDIR}"/${P}-arch.patch
+
+	"${FILESDIR}"/${P}-gcc-10.patch
+	"${FILESDIR}"/${P}-c++17.patch
+	"${FILESDIR}"/${P}-ao-crash.patch
+	"${FILESDIR}"/${P}-stack-align-v3.patch
+)
+
+src_prepare() {
+	default
+
+	# The sdl detection logic uses AC_PROG_PATH instead of
+	# AC_PROG_TOOL, so force the var to get set the way we
+	# need for things to work correctly.
+	tc-is-cross-compiler && export ac_cv_path_SDL_CONFIG=${CHOST}-sdl-config
+
+	sed -i -e '67i#define OF(x) x' zip/zunzip.h || die
+
+	# Remove hardcoded CFLAGS and LDFLAGS
+	sed -i \
+		-e '/^CFLAGS=.*local/s:-pipe.*:-Wall -I.":' \
+		-e '/^LDFLAGS=.*local/d' \
+		-e '/\w*CFLAGS=.*fomit/s:-O3.*$STRIP::' \
+		-e '/lncurses/s:-lncurses:`pkg-config ncurses --libs`:' \
+		-e '/lcurses/s:-lcurses:`pkg-config ncurses --libs`:' \
+		configure.in || die
+	sed -i \
+		-e 's/configure.in/configure.ac/' \
+		Makefile.in || die
+	mv configure.in configure.ac || die
+	eautoreconf
+}
+
+src_configure() {
+	tc-export CC
+	export BUILD_CXX=$(tc-getBUILD_CXX)
+	export NFLAGS=-O1
+	use amd64 && multilib_toolchain_setup x86
+	use custom-cflags || strip-flags
+
+	append-cppflags -U_FORTIFY_SOURCE	#257963
+
+	econf \
+		$(use_enable ao libao) \
+		$(use_enable debug debugger) \
+		$(use_enable png libpng) \
+		$(use_enable opengl) \
+		--disable-debug \
+		--disable-cpucheck
+}
+
+src_compile() {
+	emake makefile.dep
+	emake
+}
+
+src_install() {
+	# Uses pic-unfriendly assembly code, bug #427104
+	QA_TEXTRELS="usr/bin/zsnes"
+
+	dobin zsnes
+	pax-mark m "${ED}"/usr/bin/zsnes
+
+	newman linux/zsnes.1 zsnes.6
+
+	dodoc \
+		../docs/{readme.1st,authors.txt,srcinfo.txt,stdards.txt,support.txt,thanks.txt,todo.txt,README.LINUX} \
+		../docs/readme.txt/*
+	HTML_DOCS="../docs/readme.htm/*" einstalldocs
+
+	make_desktop_entry zsnes ZSNES
+	newicon icons/48x48x32.png ${PN}.png
+}


             reply	other threads:[~2021-05-11 22:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 22:57 Sergei Trofimovich [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-07-29 20:53 [gentoo-commits] repo/gentoo:master commit in: games-emulation/zsnes/, games-emulation/zsnes/files/ James Le Cuirot
2021-12-22 18:15 Ionen Wolkens
2021-12-22 18:15 Ionen Wolkens
2020-07-30  7:37 Sergei Trofimovich
2020-02-04 21:38 Sergei Trofimovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1620773843.8b2eebf5117453efbe1e62e6314ad58614c0d587.slyfox@gentoo \
    --to=slyfox@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox