[SCM] Emulator of the Super Nintendo Entertainment System (TM) branch, master, updated. debian/1.510+bz2-4-11-g8183446

Fabian Greffrath fabian+debian at greffrath.com
Mon Sep 10 09:30:36 UTC 2012


The following commit has been merged in the master branch:
commit 5851a5001c6bb724651c71e3e466d6a57a80f346
Author: Fabian Greffrath <fabian+debian at greffrath.com>
Date:   Thu Jul 5 16:22:55 2012 +0200

    * Append CPPFLAGS to CFLAGS and CXXFLAGS to enable -D_FORTIFY_SOURCE=2.
    * 0015-fortify-source.patch: New patch from RPM Fusion by Hans de Goede to fix compilation with -D_FORTIFY_SOURCE=2 (LP: #250425).
    * 0016-parsegen.patch: Another patch from RPM Fusion by Ralf Corsepius to create an intermediate .c file instead of an .o file with parsegen, also needed to fix compilation with -D_FORTIFY_SOURCE=2.
    * debian/clean: Remove the intermediate .c files in the clean rule.

diff --git a/debian/changelog b/debian/changelog
index 47d7016..9b55a7b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,6 +19,13 @@ zsnes (1.510+bz2-7) unstable; urgency=low
   * Add myself to Uploaders.
   * 0001-gcc-fno-rtti.patch: Patch src/configure.in instead of the
     auto-generated src/configure.
+  * Append CPPFLAGS to CFLAGS and CXXFLAGS to enable "-D_FORTIFY_SOURCE=2".
+  * 0015-fortify-source.patch: New patch from RPM Fusion by Hans de Goede
+    to fix compilation with "-D_FORTIFY_SOURCE=2" (LP: #250425).
+  * 0016-parsegen.patch: Another patch from RPM Fusion by Ralf Corsepius
+    to create an intermediate .c file instead of an .o file with parsegen,
+    also needed to fix compilation with "-D_FORTIFY_SOURCE=2".
+  * debian/clean: Remove the intermediate .c files in the clean rule.
 
  -- Etienne Millon <etienne.millon at gmail.com>  Fri, 29 Jun 2012 17:37:53 +0200
 
diff --git a/debian/clean b/debian/clean
new file mode 100644
index 0000000..10b9d81
--- /dev/null
+++ b/debian/clean
@@ -0,0 +1,3 @@
+src/cfg.c
+src/input.c
+src/md.c
diff --git a/debian/patches/0015-fortify-source.patch b/debian/patches/0015-fortify-source.patch
new file mode 100644
index 0000000..402da7d
--- /dev/null
+++ b/debian/patches/0015-fortify-source.patch
@@ -0,0 +1,122 @@
+Author: Hans de Goede
+Origin: http://cvs.rpmfusion.org/viewvc/rpms/zsnes/devel/zsnes-1.51-FORTIFY_SOURCE.patch?root=free&view=markup
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/intrepid/+source/zsnes/+bug/250425
+Subject: Upstream has strange memory manipulations that upset FORTIFY_SOURCE
+ The problem is an interaction between the uncommon (to put it mildly) way
+ zsnes calls memcpy to restore its global state from the "regsbackup" buffer,
+ and _FORTIFY_SOURCE:
+ .
+ gcc -ggdb3 -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__
+ -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DNO_DEBUGGER -D__LIBAO__
+ -D__OPENGL__ -march=i486 -O3 -fomit-frame-pointer -fprefetch-loop-arrays
+ -fforce-addr -s -D__RELEASE__ -o initc.o -c initc.c
+ [...]
+ In function ‘memcpy’,
+    inlined from ‘powercycle’ at initc.c:2624:
+ /usr/include/bits/string3.h:52: warning: call to __builtin___memcpy_chk will
+ always overflow destination buffer
+ .
+ The corresponding block of code is:
+ .
+    sramsavedis = 0;
+    memcpy(&sndrot, regsbackup, 3019);
+ .
+ And the declaration for the relevant variables, from the same file:
+ .
+ extern unsigned char NextLineCache, sramsavedis, sndrot, regsbackup[3019];
+ .
+ The reason this strange memcpy call will always work correctly is that the
+ storage for sndrot and the rest of the state variables is allocated in
+ assembly (cpu/regs.inc, included from cpu/table.asm), in a way which
+ guarantees that all the correct variables will be sequential in memory, with
+ no padding (sndrot is just the first variable on that block). However, gcc
+ cannot know that; it sees instead an attempt to write 3019 bytes to a single
+ byte-sized variable, which will obviously overflow (and, in fact, overflowing
+ is precisely the desired behaviour!).
+ <https://bugs.launchpad.net/ubuntu/intrepid/+source/zsnes/+bug/250425/comments/45>
+
+--- a/src/initc.c
++++ b/src/initc.c
+@@ -1464,8 +1464,8 @@ void clearmem()
+   clearmem2();
+ }
+ 
+-extern unsigned char BRRBuffer[32];
+-extern unsigned char echoon0;
++extern unsigned char BRRBuffer[];
++extern unsigned char echoon0[];
+ extern unsigned int PHdspsave;
+ extern unsigned int PHdspsave2;
+ unsigned char echobuf[90000];
+@@ -1479,7 +1479,7 @@ void clearvidsound()
+   memset(vidmemch4, 0, 4096);
+   memset(vidmemch8, 0, 4096);
+   memset(BRRBuffer, 0, PHdspsave);
+-  memset(&echoon0, 0, PHdspsave2);
++  memset(echoon0, 0, PHdspsave2);
+   memset(echobuf, 0, 90000);
+   memset(spcBuffera, 0, 65536*4+4096);
+   memset(DSPMem, 0, 256);
+@@ -1822,7 +1822,7 @@ unsigned int showinfogui()
+ 
+ extern unsigned int nmiprevaddrl, nmiprevaddrh, nmirept, nmiprevline, nmistatus;
+ extern unsigned char spcnumread, yesoutofmemory;
+-extern unsigned char NextLineCache, sramsavedis, sndrot, regsbackup[3019];
++extern unsigned char NextLineCache, sramsavedis, sndrot[], regsbackup[3019];
+ extern unsigned int Voice0Freq, Voice1Freq, Voice2Freq, Voice3Freq;
+ extern unsigned int Voice4Freq, Voice5Freq, Voice6Freq, Voice7Freq;
+ extern unsigned int dspPAdj;
+@@ -2621,7 +2621,7 @@ void powercycle(bool sramload, bool roml
+     }
+ 
+     sramsavedis = 0;
+-    memcpy(&sndrot, regsbackup, 3019);
++    memcpy(sndrot, regsbackup, 3019);
+ 
+     if (yesoutofmemory) { asm_call(outofmemfix); }
+     asm_call(GUIDoReset);
+--- a/src/zstate.c
++++ b/src/zstate.c
+@@ -99,15 +99,15 @@ static void copy_snes_data(unsigned char
+   copy_func(buffer, &cycpbl, 4);
+   copy_func(buffer, &cycpblt, 4);
+   //SNES PPU Register status
+-  copy_func(buffer, &sndrot, 3019);
++  copy_func(buffer, sndrot, 3019);
+ }
+ 
+ static void copy_spc_data(unsigned char **buffer, void (*copy_func)(unsigned char **, void *, size_t))
+ {
+   //SPC stuff, DSP stuff
+   copy_func(buffer, SPCRAM, PHspcsave);
+-  copy_func(buffer, &BRRBuffer, PHdspsave);
+-  copy_func(buffer, &DSPMem, sizeof(DSPMem));
++  copy_func(buffer, BRRBuffer, PHdspsave);
++  copy_func(buffer, DSPMem, sizeof(DSPMem));
+ }
+ 
+ static void copy_extra_data(unsigned char **buffer, void (*copy_func)(unsigned char **, void *, size_t))
+@@ -156,7 +156,7 @@ static void copy_state_data(unsigned cha
+     /*
+     if (buffer) //Rewind stuff
+     {
+-      copy_func(&buffer, &echoon0, PHdspsave2);
++      copy_func(&buffer, echoon0, PHdspsave2);
+     }
+     */
+   }
+--- a/src/gblvars.h
++++ b/src/gblvars.h
+@@ -33,9 +33,9 @@ extern unsigned int nmirept, nmiprevline
+ extern unsigned int SfxR0, *setaramdata, ramsize, *sram, nmiprevaddrh;
+ extern unsigned int tempesi, tempedi, tempedx, tempebp;
+ extern unsigned int SPCMultA, PHnum2writespc7110reg, PHdspsave2;
+-extern unsigned char sndrot, SPCRAM[65472], DSPMem[256], SA1Status, *SA1RAMArea;
+-extern unsigned char DSP1Enable, DSP1COp, prevoamptr, BRRBuffer[32], *romdata;
+-extern unsigned char curcyc, echoon0, spcnumread, NextLineCache, HIRQNextExe;
++extern unsigned char sndrot[], SPCRAM[65472], DSPMem[256], SA1Status, *SA1RAMArea;
++extern unsigned char DSP1Enable, DSP1COp, prevoamptr, BRRBuffer[], *romdata;
++extern unsigned char curcyc, echoon0[], spcnumread, NextLineCache, HIRQNextExe;
+ extern unsigned char vidmemch4[4096], vidmemch8[4096], vidmemch2[4096];
+ 
+ extern bool C4Enable, SFXEnable, SA1Enable, SPC7110Enable, SETAEnable, DSP4Enable, spcon;
diff --git a/debian/patches/0016-parsegen.patch b/debian/patches/0016-parsegen.patch
new file mode 100644
index 0000000..fedcb33
--- /dev/null
+++ b/debian/patches/0016-parsegen.patch
@@ -0,0 +1,18 @@
+Author: Ralf Corsepius
+Origin: http://cvs.rpmfusion.org/viewvc/rpms/zsnes/devel/zsnes-1.51-psr.patch?root=free&view=markup
+Subject: Create an intermediate .c file instead of an .o file with parsegen,
+ also needed to fix compilation with "-D_FORTIFY_SOURCE=2".
+
+--- a/src/Makefile.in
++++ b/src/Makefile.in
+@@ -94,8 +94,8 @@ Z_OBJS=$(MAIN_O) $(CHIP_O) $(CPU_O) $(DE
+ 	@CC@ @CFLAGS@ -o $@ -c $<
+ %.o: %.cpp
+ 	@CXX@ @CXXFLAGS@ -o $@ -c $<
+-%.o %.h: %.psr $(PSR)
+-	./$(PSR) @PSRFLAGS@ -gcc @CC@ -compile -flags "@CFLAGS@ -O1" -cheader $*.h -fname $* $*.o $<
++%.c %.h: %.psr $(PSR)
++	./$(PSR) @PSRFLAGS@ -cheader $*.h -fname $* $*.c $<
+ 
+ default: main
+ all: main tools
diff --git a/debian/patches/series b/debian/patches/series
index 3d70a56..72cf7c6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -12,3 +12,5 @@
 0012-Fix-build-with-gcc-4.7.patch
 0013-Fix-sound-with-libao.patch
 0014-Initialize-driver_format.matrix-with-NULL.patch
+0015-fortify-source.patch
+0016-parsegen.patch
diff --git a/debian/rules b/debian/rules
index 5090080..8bc31de 100755
--- a/debian/rules
+++ b/debian/rules
@@ -10,6 +10,8 @@
 #export DH_VERBOSE=1
 #export DH_OPTIONS=-v
 
+CFLAGS   += $(CPPFLAGS)
+CXXFLAGS += $(CPPFLAGS)
 export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed -lpthread
 
 %:

-- 
Emulator of the Super Nintendo Entertainment System (TM)



More information about the Pkg-games-commits mailing list