Author: alexander
Date: 2007-08-14 08:16:08 -0600 (Tue, 14 Aug 2007)
New Revision: 2019

Added:
   trunk/packages/linux32/
   trunk/packages/linux32/Makefile
   trunk/packages/linux32/README
   trunk/packages/linux32/linux32.1
   trunk/packages/linux32/linux32.c
Modified:
   trunk/Makefile
Log:
Added the linux32 program - it makes "uname -m" return "i686" instead of 
"x86_64"

Modified: trunk/Makefile
===================================================================
--- trunk/Makefile      2007-08-14 14:02:43 UTC (rev 2018)
+++ trunk/Makefile      2007-08-14 14:16:08 UTC (rev 2019)
@@ -290,7 +290,7 @@
        ch-libchewing ch-scim-chewing ch-scim-pinyin ch-scim-input-pad \
        ch-hibernate-script ch-slang ch-mc ch-fuse ch-dosfstools ch-ntfsprogs \
        ch-libaal ch-reiser4progs ch-vbetool ch-bin86 ch-lilo ch-syslinux \
-       ch-scsi-firmware ch-net-firmware
+       ch-scsi-firmware ch-net-firmware ch-linux32
 ifeq ($(CD_ARCH),x86)
        make ch-grub
        make ch-linux

Added: trunk/packages/linux32/Makefile
===================================================================
--- trunk/packages/linux32/Makefile                             (rev 0)
+++ trunk/packages/linux32/Makefile     2007-08-14 14:16:08 UTC (rev 2019)
@@ -0,0 +1,26 @@
+# linux32 Makefile
+
+NM= linux32
+
+# Targets
+
+chroot:
+       chroot "$(MP)" $(chenv-blfs) \
+       'cd $(ROOT) && make ch-$(NM) $(chbash-post-bash)'
+
+stage2: Makefile
+       make -f Makefile compile-$@
+       make clean
+       touch $@        
+
+compile-stage2:
+       gcc $(CFLAGS) -o linux32 linux32.c
+       install -m 755 linux32 /usr/bin
+       install -m644 linux32.1 /usr/share/man/man1
+       ln -sf linux32 /usr/bin/linux64
+       ln -sf linux32 /usr/share/man/man1/linux64.1
+
+clean:
+       rm -f linux32
+
+.PHONY: clean chroot compile-stage2

Added: trunk/packages/linux32/README
===================================================================
--- trunk/packages/linux32/README                               (rev 0)
+++ trunk/packages/linux32/README       2007-08-14 14:16:08 UTC (rev 2019)
@@ -0,0 +1,6 @@
+The "linux32.c" and "linux32.1" files were downloaded from:
+
+ftp://ftp.x86-64.org/pub/linux-x86_64/tools/linux32
+
+The "stupid" 3 gb address space default was changed to 4 gb, because
+the buggy version of Java is no longer relevant.

Added: trunk/packages/linux32/linux32.1
===================================================================
--- trunk/packages/linux32/linux32.1                            (rev 0)
+++ trunk/packages/linux32/linux32.1    2007-08-14 14:16:08 UTC (rev 2019)
@@ -0,0 +1,55 @@
+.TH LINUX32 1 "May 2002" "SuSE Labs" "Linux User's Manual"
+.SH NAME 
+linux32 \- Set i686 uname emulation processes. 
+linux64 \- Reset uname emulation
+.SH SYNOPSIS
+.B linux32
+[
+.B \-\-3gb
+]
+[
+.B \-\-4gb
+]
+command arguments...
+.br
+.B linux64
+command arguments...
+.br
+.SH DESCRIPTION
+.I linux32
+changes the personality of command and all its children to 
+return 
+.I i686
+instead of
+.I x86_64 
+in 
+.I uname -a.
+This is useful to fool shell scripts or programs that check for the 
architecture
+explicitely into believing that they run on a true 
+.I i686
+system.
+In addition it moves the top of stack of the 32bit child processes to 
+.I 0xc0000000.
+This is useful to execute some broken applications that break when
+the stack top is at 4GB. On the other hand it limits the usable heap
+memory more than necessary.
+When 
+.I --4gb 
+is specified this is not done.
+
+.I linux64
+resets the uname personality to default.
+.SH SEE ALSO
+.I uname(1)
+
+.I uname(2) 
+
+.I personality(2)
+
+
+
+
+
+
+
+

Added: trunk/packages/linux32/linux32.c
===================================================================
--- trunk/packages/linux32/linux32.c                            (rev 0)
+++ trunk/packages/linux32/linux32.c    2007-08-14 14:16:08 UTC (rev 2019)
@@ -0,0 +1,53 @@
+/* 
+ * Copyright 2002 Andi Kleen, SuSE Labs.
+ * This file is subject to the GNU General Public License v.2 
+ */
+#include <linux/personality.h>
+#undef personality
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+
+/* Setting this to 1 would make --3gb the default for buggy Java */
+#define STUPID_DEFAULT 0
+
+#ifdef STUPID_DEFAULT 
+#define DFL_PER PER_LINUX32_3GB
+#else
+#define DFL_PER PER_LINUX32
+#endif
+
+#define  ADDR_LIMIT_3GB        0x8000000
+#define  PER_LINUX32_3GB       (0x0008 | ADDR_LIMIT_3GB)
+
+int main(int ac, char **av) 
+{ 
+       int pers = DFL_PER; 
+       if (!av[1]) { 
+               fprintf(stderr, "usage: %s [--3gb] [--4gb] program args ...\n", 
av[0]); 
+#if DFL_PER == PER_LINUX32_3GB
+               fprintf(stderr, "Default is --3gb to limit the address space of 
the 32bit children to 3GB\n"); 
+#endif
+               exit(1); 
+       } 
+       if (!strcmp(av[0],"linux64")) pers= PER_LINUX;
+       else if (!strcmp(av[0],"linux32")) pers = DFL_PER;
+
+       if (!strcmp(av[1], "--3gb")) {
+               pers = PER_LINUX32_3GB; 
+               av++; 
+       }       
+       if (!strcmp(av[1], "--4gb")) {
+               pers = PER_LINUX32; 
+               av++; 
+       }       
+
+       if (personality(pers) < 0) {
+               fprintf(stderr, "Cannot set %x personality: %s\n", pers,
+                       strerror(errno));
+               exit(1);
+       } 
+       execvp(av[1],av+1);
+       fprintf(stderr, "Cannot execute %s: %s\n", av[1], strerror(errno)); 
+       exit(1); 
+} 

-- 
http://linuxfromscratch.org/mailman/listinfo/livecd
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to