[packages/libx86] - rel 4, add fixes from fedora
baggins
baggins at pld-linux.org
Mon May 11 22:18:19 CEST 2026
commit 951f31da9ccdf4f2f76bd8d0354cde0e8144bfc9
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Tue May 12 00:17:57 2026 +0200
- rel 4, add fixes from fedora
libx86-1.1-24-fix-invalid-hlt-opcode.patch | 22 ++++
libx86-add-pkgconfig.patch | 64 ++++++++++
libx86-c99-2.patch | 20 +++
libx86-c99.patch | 17 +++
libx86-fix_processor_flags.patch | 23 ++++
libx86-ld_flags.patch | 19 +++
libx86-libc-test.patch | 39 ++++++
libx86-mmap-offset.patch | 187 +++++++++++++++++++++++++++++
libx86.spec | 21 +++-
9 files changed, 409 insertions(+), 3 deletions(-)
---
diff --git a/libx86.spec b/libx86.spec
index 47bbeb9..7fac13a 100644
--- a/libx86.spec
+++ b/libx86.spec
@@ -2,12 +2,19 @@ Summary: A hardware-independent library for executing real-mode x86 code
Summary(pl.UTF-8): Niezależna od sprzętu biblioteka do wykonywania kodu trybu rzeczywistego x86
Name: libx86
Version: 1.1
-Release: 4
+Release: 5
License: MIT (libx86), BSD (x86emu)
Group: Libraries
Source0: http://www.codon.org.uk/~mjg59/libx86/downloads/%{name}-%{version}.tar.gz
# Source0-md5: 41bee1f8e22b82d82b5f7d7ba51abc2a
Patch0: %{name}-lrmi.patch
+Patch1: %{name}-add-pkgconfig.patch
+Patch2: %{name}-mmap-offset.patch
+Patch3: %{name}-libc-test.patch
+Patch4: %{name}-ld_flags.patch
+Patch5: %{name}-1.1-24-fix-invalid-hlt-opcode.patch
+Patch6: %{name}-c99.patch
+Patch7: %{name}-c99-2.patch
URL: http://www.codon.org.uk/~mjg59/libx86/
# it's supposed to be arch independant emu library but unfortunately right now it doesn't build
# on other architectures; check with newer versions!
@@ -54,6 +61,13 @@ Statyczna biblioteka libx86.
%prep
%setup -q
%patch -P0 -p0
+%patch -P1 -p1
+%patch -P2 -p1
+%patch -P3 -p1
+%patch -P4 -p0
+%patch -P5 -p1
+%patch -P6 -p1
+%patch -P7 -p1
%build
%{__make} \
@@ -78,12 +92,13 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
-%attr(755,root,root) %{_libdir}/libx86.so.1
+%{_libdir}/libx86.so.1
%files devel
%defattr(644,root,root,755)
-%attr(755,root,root) %{_libdir}/libx86.so
+%{_libdir}/libx86.so
%{_includedir}/libx86.h
+%{_pkgconfigdir}/x86.pc
%files static
%defattr(644,root,root,755)
diff --git a/libx86-1.1-24-fix-invalid-hlt-opcode.patch b/libx86-1.1-24-fix-invalid-hlt-opcode.patch
new file mode 100644
index 0000000..50824f8
--- /dev/null
+++ b/libx86-1.1-24-fix-invalid-hlt-opcode.patch
@@ -0,0 +1,22 @@
+http://cgit.freedesktop.org/~vignatti/libx86/commit/src/lrmi/backend-x86emu.c?id=b327015cf23f
+http://ref.x86asm.net/coder32.html#xF4
+http://pdos.csail.mit.edu/6.828/2010/readings/i386/HLT.htm
+
+HLT is 0xf4 and not 0x4f
+
+Spotted by Thierry Vignaud
+
+From Mageia
+
+
+--- libx86-1.1/thunk.c.orig 2015-05-20 01:45:50.000000000 +0200
++++ libx86-1.1/thunk.c 2015-05-20 01:46:11.000000000 +0200
+@@ -179,7 +179,7 @@
+ X86_ESP = 0xFFF9;
+ memset (stack, 0, 64*1024);
+
+- *mmap_addr = 0x4f; /* Make sure that we end up jumping back to a
++ *mmap_addr = 0xf4; /* Make sure that we end up jumping back to a
+ halt instruction */
+
+ M.mem_base = (unsigned long)mmap_addr;
diff --git a/libx86-add-pkgconfig.patch b/libx86-add-pkgconfig.patch
new file mode 100644
index 0000000..3aeaff7
--- /dev/null
+++ b/libx86-add-pkgconfig.patch
@@ -0,0 +1,64 @@
+From fc4f25c4d16aaff7dcb5dd42cc20b292f4eb2218 Mon Sep 17 00:00:00 2001
+From: Dave Airlie <airlied at redhat.com>
+Date: Tue, 4 Aug 2009 13:08:42 +1000
+Subject: [PATCH] git add x86.pc
+
+---
+ Makefile | 15 ++++++++++++---
+ x86.pc.in | 10 ++++++++++
+ 2 files changed, 22 insertions(+), 3 deletions(-)
+ create mode 100644 x86.pc.in
+
+diff --git a/Makefile b/Makefile
+index 951b617..953a499 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,6 +1,7 @@
+ OBJECTS = x86-common.o
+ CFLAGS ?= -O2 -Wall -DDEBUG -g
+ LIBDIR ?= /usr/lib
++INCLUDEDIR ?= /usr/include
+
+ ifeq ($(BACKEND),x86emu)
+ OBJECTS += thunk.o x86emu/decode.o x86emu/debug.o x86emu/fpu.o \
+@@ -29,10 +30,18 @@ objclean:
+ rm -f *.o *~
+
+ clean: objclean
+- rm -f *.so.1 *.a
++ rm -f *.so.1 *.a x86.pc
+
+-install: libx86.so.1
++x86.pc:
++ sed -e's, at prefix@,/usr,' x86.pc.in > x86.pc
++ sed -e's, at exec_prefix@,/usr,' -i x86.pc
++ sed -e's, at libdir@,${LIBDIR},' -i x86.pc
++ sed -e's, at includedir@,${INCLUDEDIR},' -i x86.pc
++ sed -e's, at PACKAGE_VERSION@,1.1,' -i x86.pc
++
++install: libx86.so.1 x86.pc
+ install -D libx86.so.1 $(DESTDIR)$(LIBDIR)/libx86.so.1
+ install -D libx86.a $(DESTDIR)$(LIBDIR)/libx86.a
++ install -D x86.pc $(DESTDIR)$(LIBDIR)/pkgconfig/x86.pc
+ ln -sf libx86.so.1 $(DESTDIR)$(LIBDIR)/libx86.so
+- install -p -m 0644 -D lrmi.h $(DESTDIR)/usr/include/libx86.h
++ install -p -m 0644 -D lrmi.h $(DESTDIR)$(INCLUDEDIR)/libx86.h
+diff --git a/x86.pc.in b/x86.pc.in
+new file mode 100644
+index 0000000..711d90d
+--- /dev/null
++++ b/x86.pc.in
+@@ -0,0 +1,10 @@
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++libdir=@libdir@
++includedir=@includedir@
++
++Name: x86
++Description: Library providing x86 emulator access
++Version: @PACKAGE_VERSION@
++Cflags: -I${includedir}
++Libs: -L${libdir} -lx86
+--
+1.5.4.1
+
diff --git a/libx86-c99-2.patch b/libx86-c99-2.patch
new file mode 100644
index 0000000..a738139
--- /dev/null
+++ b/libx86-c99-2.patch
@@ -0,0 +1,20 @@
+The glibc implementations used for x_inl and x_outl have slightly
+different types.
+
+diff --git a/thunk.c b/thunk.c
+index 9facd4386478c735..63d4452d4e1cf35a 100644
+--- a/thunk.c
++++ b/thunk.c
+@@ -157,10 +157,10 @@ int LRMI_init() {
+ X86EMU_pioFuncs pioFuncs = {
+ (&x_inb),
+ (&x_inw),
+- (&x_inl),
++ ((x86emuu32 (*)(X86EMU_pioAddr)) &x_inl),
+ (&x_outb),
+ (&x_outw),
+- (&x_outl)
++ ((void (*)(X86EMU_pioAddr, x86emuu32)) &x_outl)
+ };
+
+ X86EMU_setupPioFuncs(&pioFuncs);
diff --git a/libx86-c99.patch b/libx86-c99.patch
new file mode 100644
index 0000000..618030a
--- /dev/null
+++ b/libx86-c99.patch
@@ -0,0 +1,17 @@
+Avoid an int-conversion error. The offset variable is later used as a
+pointer argument to mmap, so it makes sense to keep it as a void *
+variable.
+
+diff --git a/x86-common.c b/x86-common.c
+index 137bc3ca6e12c0e1..0978276c3aa7d2c0 100644
+--- a/x86-common.c
++++ b/x86-common.c
+@@ -213,7 +213,7 @@ void *LRMI_common_init(int high_page)
+ if (!real_mem_init(high_page))
+ return NULL;
+
+- offset = mem_info.offset - REAL_MEM_BASE;
++ offset = (void *) (mem_info.offset - REAL_MEM_BASE);
+
+ /*
+ Map the Interrupt Vectors (0x0 - 0x400) + BIOS data (0x400 - 0x502)
diff --git a/libx86-fix_processor_flags.patch b/libx86-fix_processor_flags.patch
new file mode 100644
index 0000000..6737a29
--- /dev/null
+++ b/libx86-fix_processor_flags.patch
@@ -0,0 +1,23 @@
+Linux 2.6.26-rc1 and newer no longer define *_MASK; use X86_EFLAGS_*
+instead (thanks to Colin Watson)
+--- libx86.orig/lrmi.c
++++ libx86/lrmi.c
+@@ -55,6 +55,18 @@
+ #include "x86-common.h"
+
+ #if defined(__linux__)
++#ifndef TF_MASK
++#define TF_MASK X86_EFLAGS_TF
++#endif
++#ifndef IF_MASK
++#define IF_MASK X86_EFLAGS_IF
++#endif
++#ifndef IOPL_MASK
++#define IOPL_MASK X86_EFLAGS_IOPL
++#endif
++#ifndef VIF_MASK
++#define VIF_MASK X86_EFLAGS_VIF
++#endif
+ #define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK)
+ #elif defined(__NetBSD__) || defined(__FreeBSD__)
+ #define DEFAULT_VM86_FLAGS (PSL_I | PSL_IOPL)
diff --git a/libx86-ld_flags.patch b/libx86-ld_flags.patch
new file mode 100644
index 0000000..aa8f32b
--- /dev/null
+++ b/libx86-ld_flags.patch
@@ -0,0 +1,19 @@
+--- Makefile.orig 2021-12-13 10:48:43.690174577 -0600
++++ Makefile 2021-12-13 10:49:21.037556290 -0600
+@@ -2,6 +2,7 @@ OBJECTS = x86-common.o
+ CFLAGS ?= -O2 -Wall -DDEBUG -g
+ LIBDIR ?= /usr/lib
+ INCLUDEDIR ?= /usr/include
++LDFLAGS ?= -Wl,-z,now
+
+ ifeq ($(BACKEND),x86emu)
+ OBJECTS += thunk.o x86emu/decode.o x86emu/debug.o x86emu/fpu.o \
+@@ -24,7 +25,7 @@ static: $(OBJECTS)
+ $(AR) cru libx86.a $(OBJECTS)
+
+ shared: $(OBJECTS)
+- $(CC) $(CFLAGS) -o libx86.so.1 -shared -Wl,-soname,libx86.so.1 $(OBJECTS)
++ $(CC) $(CFLAGS) -o libx86.so.1 -shared $(LDFLAGS) -Wl,-soname,libx86.so.1 $(OBJECTS)
+
+ objclean:
+ $(MAKE) -C x86emu clean
diff --git a/libx86-libc-test.patch b/libx86-libc-test.patch
new file mode 100644
index 0000000..a62da4a
--- /dev/null
+++ b/libx86-libc-test.patch
@@ -0,0 +1,39 @@
+diff -Naur libx86-1.1+ds1.orig/Makefile libx86-1.1+ds1/Makefile
+--- libx86-1.1+ds1.orig/Makefile 2008-05-19 12:28:59.000000000 +0300
++++ libx86-1.1+ds1/Makefile 2012-02-20 01:32:03.750068423 +0200
+@@ -5,6 +5,7 @@
+ ifeq ($(BACKEND),x86emu)
+ OBJECTS += thunk.o x86emu/decode.o x86emu/debug.o x86emu/fpu.o \
+ x86emu/ops.o x86emu/ops2.o x86emu/prim_ops.o x86emu/sys.o
++ CFLAGS += -DX86EMU
+ else
+ OBJECTS += lrmi.o
+ endif
+diff -Naur libx86-1.1+ds1.orig/thunk.c libx86-1.1+ds1/thunk.c
+--- libx86-1.1+ds1.orig/thunk.c 2008-04-03 03:48:00.000000000 +0300
++++ libx86-1.1+ds1/thunk.c 2012-02-20 01:12:56.468820192 +0200
+@@ -32,6 +32,7 @@
+ #define TRUE 1
+ #define FALSE 0
+
++#ifndef X86EMU
+ #define __BUILDIO(bwl,bw,type) \
+ static inline void out##bwl##_local(unsigned long port, unsigned type value) { __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \
+ }\
+@@ -44,6 +45,15 @@
+ __BUILDIO(b,b,char)
+ __BUILDIO(w,w,short)
+ __BUILDIO(l,,int)
++#else
++/* use libc functions */
++#define inb_local inb
++#define inw_local inw
++#define inl_local inl
++#define outb_local outb
++#define outw_local outw
++#define outl_local outl
++#endif /* X86EMU */
+
+
+ char *mmap_addr = SHMERRORPTR;
+
diff --git a/libx86-mmap-offset.patch b/libx86-mmap-offset.patch
new file mode 100644
index 0000000..881bc66
--- /dev/null
+++ b/libx86-mmap-offset.patch
@@ -0,0 +1,187 @@
+diff -ur libx86-1.1/lrmi.c libx86-1.1.hack/lrmi.c
+--- libx86-1.1/lrmi.c 2006-10-30 15:10:16.000000000 -0500
++++ libx86-1.1.hack/lrmi.c 2009-10-26 15:55:42.000000000 -0400
+@@ -136,7 +136,7 @@
+ if (context.ready)
+ return 1;
+
+- if (!LRMI_common_init())
++ if (!LRMI_common_init(0))
+ return 0;
+
+ /*
+diff -ur libx86-1.1/thunk.c libx86-1.1.hack/thunk.c
+--- libx86-1.1/thunk.c 2008-04-02 20:48:00.000000000 -0400
++++ libx86-1.1.hack/thunk.c 2009-10-26 16:05:39.000000000 -0400
+@@ -139,11 +139,11 @@
+ int i;
+ X86EMU_intrFuncs intFuncs[256];
+
+- if (!LRMI_common_init())
++ mmap_addr = LRMI_common_init(1);
++
++ if (!mmap_addr)
+ return 0;
+
+- mmap_addr = 0;
+-
+ X86EMU_pioFuncs pioFuncs = {
+ (&x_inb),
+ (&x_inw),
+@@ -169,10 +169,10 @@
+ X86_ESP = 0xFFF9;
+ memset (stack, 0, 64*1024);
+
+- *((char *)0) = 0x4f; /* Make sure that we end up jumping back to a
+- halt instruction */
++ *mmap_addr = 0x4f; /* Make sure that we end up jumping back to a
++ halt instruction */
+
+- M.mem_base = 0;
++ M.mem_base = (unsigned long)mmap_addr;
+ M.mem_size = 1024*1024;
+
+ return 1;
+diff -ur libx86-1.1/x86-common.c libx86-1.1.hack/x86-common.c
+--- libx86-1.1/x86-common.c 2008-05-16 12:56:23.000000000 -0400
++++ libx86-1.1.hack/x86-common.c 2009-10-26 16:03:21.000000000 -0400
+@@ -45,14 +45,15 @@
+ static struct {
+ int ready;
+ int count;
++ void *offset;
+ struct mem_block blocks[REAL_MEM_BLOCKS];
+ } mem_info = { 0 };
+
+ static int
+-real_mem_init(void)
++real_mem_init(int high_page)
+ {
+ void *m;
+- int fd_zero;
++ int fd_zero, flags = MAP_SHARED;
+
+ if (mem_info.ready)
+ return 1;
+@@ -63,9 +64,12 @@
+ return 0;
+ }
+
++ if (!high_page)
++ flags |= MAP_FIXED;
++
+ m = mmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE,
+- PROT_READ | PROT_WRITE | PROT_EXEC,
+- MAP_FIXED | MAP_SHARED, fd_zero, 0);
++ PROT_READ | PROT_WRITE | PROT_EXEC,
++ flags, fd_zero, 0);
+
+ if (m == (void *)-1) {
+ perror("mmap /dev/zero");
+@@ -76,6 +80,7 @@
+ close(fd_zero);
+
+ mem_info.ready = 1;
++ mem_info.offset = m;
+ mem_info.count = 1;
+ mem_info.blocks[0].size = REAL_MEM_SIZE;
+ mem_info.blocks[0].free = 1;
+@@ -87,7 +92,7 @@
+ real_mem_deinit(void)
+ {
+ if (mem_info.ready) {
+- munmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE);
++ munmap(mem_info.offset, REAL_MEM_SIZE);
+ mem_info.ready = 0;
+ }
+ }
+@@ -119,7 +124,7 @@
+ LRMI_alloc_real(int size)
+ {
+ int i;
+- char *r = (char *)REAL_MEM_BASE;
++ char *r = (char *)mem_info.offset;
+
+ if (!mem_info.ready)
+ return NULL;
+@@ -151,7 +156,7 @@
+ LRMI_free_real(void *m)
+ {
+ int i;
+- char *r = (char *)REAL_MEM_BASE;
++ char *r = (char *)mem_info.offset;
+
+ if (!mem_info.ready)
+ return;
+@@ -200,13 +205,15 @@
+ return *(unsigned short *)(i * 4);
+ }
+
+-int LRMI_common_init(void)
++void *LRMI_common_init(int high_page)
+ {
+- void *m;
++ void *m, *offset;
+ int fd_mem;
+
+- if (!real_mem_init())
+- return 0;
++ if (!real_mem_init(high_page))
++ return NULL;
++
++ offset = mem_info.offset - REAL_MEM_BASE;
+
+ /*
+ Map the Interrupt Vectors (0x0 - 0x400) + BIOS data (0x400 - 0x502)
+@@ -217,33 +224,33 @@
+ if (fd_mem == -1) {
+ real_mem_deinit();
+ perror("open /dev/mem");
+- return 0;
++ return NULL;
+ }
+
+- m = mmap((void *)0, 0x502,
+- PROT_READ | PROT_WRITE | PROT_EXEC,
+- MAP_FIXED | MAP_SHARED, fd_mem, 0);
++ m = mmap(offset, 0x502,
++ PROT_READ | PROT_WRITE | PROT_EXEC,
++ MAP_FIXED | MAP_SHARED, fd_mem, 0);
+
+ if (m == (void *)-1) {
+ close(fd_mem);
+ real_mem_deinit();
+ perror("mmap /dev/mem");
+- return 0;
++ return NULL;
+ }
+
+- m = mmap((void *)0xa0000, 0x100000 - 0xa0000,
++ m = mmap(offset+0xa0000, 0x100000 - 0xa0000,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_FIXED | MAP_SHARED, fd_mem, 0xa0000);
+
+ if (m == (void *)-1) {
+- munmap((void *)0, 0x502);
++ munmap(offset, 0x502);
+ close(fd_mem);
+ real_mem_deinit();
+ perror("mmap /dev/mem");
+- return 0;
++ return NULL;
+ }
+
+ close(fd_mem);
+
+- return 1;
++ return offset;
+ }
+diff -ur libx86-1.1/x86-common.h libx86-1.1.hack/x86-common.h
+--- libx86-1.1/x86-common.h 2006-09-07 18:44:27.000000000 -0400
++++ libx86-1.1.hack/x86-common.h 2009-10-26 16:01:19.000000000 -0400
+@@ -40,4 +40,4 @@
+
+ void *LRMI_alloc_real(int size);
+ void LRMI_free_real(void *m);
+-int LRMI_common_init(void);
++void *LRMI_common_init(int high_page);
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/libx86.git/commitdiff/951f31da9ccdf4f2f76bd8d0354cde0e8144bfc9
More information about the pld-cvs-commit
mailing list