commit:     d282fda7e459da30a48f0b2f57888fb4b98271e0
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 12 19:53:12 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Nov 12 19:54:01 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d282fda7

app-emulation/dosemu: fix crash w/ >=gcc-10, require bison

Closes: https://bugs.gentoo.org/886119
Closes: https://bugs.gentoo.org/890302
Thanks-to: Matthew Ogilvie <mmogilvi+gnto <AT> zoho.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...5.ebuild => dosemu-1.4.1_pre20130107-r6.ebuild} |  4 ++
 .../dosemu-1.4.1_pre20130107-gcc10-const.patch     | 64 ++++++++++++++++++++++
 2 files changed, 68 insertions(+)

diff --git a/app-emulation/dosemu/dosemu-1.4.1_pre20130107-r5.ebuild 
b/app-emulation/dosemu/dosemu-1.4.1_pre20130107-r6.ebuild
similarity index 97%
rename from app-emulation/dosemu/dosemu-1.4.1_pre20130107-r5.ebuild
rename to app-emulation/dosemu/dosemu-1.4.1_pre20130107-r6.ebuild
index bb6904b66047..96d4eda00252 100644
--- a/app-emulation/dosemu/dosemu-1.4.1_pre20130107-r5.ebuild
+++ b/app-emulation/dosemu/dosemu-1.4.1_pre20130107-r6.ebuild
@@ -21,6 +21,7 @@ KEYWORDS="-* amd64 x86"
 IUSE="X alsa debug fluidsynth gpm svga"
 
 BDEPEND="app-arch/unzip
+       sys-devel/bison
        X? (
                x11-apps/bdftopcf
                >=x11-apps/mkfontscale-1.2.0
@@ -58,6 +59,7 @@ PATCHES=(
        "${FILESDIR}"/${P}-as.patch
        "${FILESDIR}"/${P}-nm.patch
        
"${FILESDIR}"/${P}-pcm_write_interleaved-incompatiible-pointer-type.patch
+       "${FILESDIR}"/${P}-gcc10-const.patch
 )
 
 pkg_pretend() {
@@ -80,6 +82,8 @@ src_prepare() {
 }
 
 src_configure() {
+       unset YACC
+
        # workaround binutils ld.gold bug #618366
        local nopie_flag=
        if tc-enables-pie; then

diff --git 
a/app-emulation/dosemu/files/dosemu-1.4.1_pre20130107-gcc10-const.patch 
b/app-emulation/dosemu/files/dosemu-1.4.1_pre20130107-gcc10-const.patch
new file mode 100644
index 000000000000..01cf146c603c
--- /dev/null
+++ b/app-emulation/dosemu/files/dosemu-1.4.1_pre20130107-gcc10-const.patch
@@ -0,0 +1,64 @@
+https://bugs.gentoo.org/890302
+https://bugzilla.redhat.com/1866474
+https://sourceforge.net/p/dosemu/patches/129/
+
+commit b3320c3a67c0bb050b40e76831ec95a4d156890a
+Author: Matthew Ogilvie <[email protected]>
+Date:   Thu Jun 15 21:55:30 2023 -0600
+
+    mem_base: avoid undefined behavior writing to const global with casts
+    
+    Fix crash under gcc 10 or later.
+
+--- a/src/arch/linux/mapping/mapping.c
++++ b/src/arch/linux/mapping/mapping.c
+@@ -47,8 +47,8 @@ static int kmem_mappings = 0;
+ static struct mem_map_struct kmem_map[MAX_KMEM_MAPPINGS];
+ 
+ static int init_done = 0;
+-unsigned char * const mem_base;
+-char * const lowmem_base;
++unsigned char * mem_base;
++char * lowmem_base;
+ 
+ static struct mappingdrivers *mappingdrv[] = {
+ #ifdef HAVE_SHM_OPEN
+@@ -205,7 +205,7 @@ void *alias_mapping(int cap, unsigned targ, size_t 
mapsize, int protect, void *s
+   addr = mappingdriver.alias(cap, target, mapsize, protect, source);
+   update_aliasmap(target, mapsize, (cap & MAPPING_VGAEMU) ? target : source);
+   if (cap & MAPPING_INIT_LOWRAM) {
+-    *(unsigned char **)&mem_base = addr;
++    mem_base = addr;
+   }
+   return addr;
+ }
+@@ -416,7 +416,7 @@ void *alloc_mapping(int cap, size_t mapsize, off_t target)
+ 
+   if (cap & MAPPING_INIT_LOWRAM) {
+     Q__printf("MAPPING: LOWRAM_INIT, cap=%s, base=%p\n", cap, addr);
+-    *(char **)(&lowmem_base) = addr;
++    lowmem_base = addr;
+   }
+   return addr;
+ }
+--- a/src/include/memory.h
++++ b/src/include/memory.h
+@@ -209,7 +209,7 @@ void *lowmemp(const void *ptr);
+    restrictions it can be non-zero. Non-zero values block vm86 but at least
+    give NULL pointer protection.
+ */
+-extern unsigned char * const mem_base;
++extern unsigned char * mem_base;
+ 
+ /* lowmem_base points to a shared memory image of the area 0--1MB+64K.
+    It does not have any holes or mapping for video RAM etc.
+@@ -221,7 +221,7 @@ extern unsigned char * const mem_base;
+    It is set "const" to help GCC optimize accesses. In reality it is set only
+    once, at startup
+ */
+-extern char * const lowmem_base;
++extern char * lowmem_base;
+ 
+ #define UNIX_READ_BYTE(addr)          (*(Bit8u *) (addr))
+ #define UNIX_WRITE_BYTE(addr, val)    (*(Bit8u *) (addr) = (val) )
+

Reply via email to