This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

rebase src patch (Was: rebase not compilable)


Reini Urban schrieb:
Brian Dessent schrieb:
Reini Urban wrote:
I thought I'll improve the rebase logic by adding some fixed base
addresses and space to certain apps
(bash, perl, python, rest) to be able to properly rebase the culprit
packages in advance.

I wanted to start with
  /usr/bin/bash.exe
  /usr/bin/cygintl-8.dll
  /usr/bin/cygiconv-2.dll
  /usr/bin/cygreadline6.dll
  /usr/bin/cygncurses-8.dll
starting at -b 0x70000000 -o 0x10000 downwards,
then perl downwards with some reserve,
then python downwards with some reserve,
then fix rebaseall to work with bash and use the new base below python,
so that for a rebaseall only the cygwin services have to be stopped.

Is this really a good direction to move in? The long term plan, as I understood it, was to simply build everything with --enable-auto-image-base and avoid forever the problem of having to manually rebase ever. Rebaseall is just a crutch to get us there while we still have legacy packages built without having image bases assigned by the hash; it should not be considered a permanent solution.

I use --enable-auto-image-base for all standard dll's within perl, but nevertheless I got base conflicts.
auto-image-base just uses a quasi-random hash based on the file contents (or header), which is obviously too fragile for my sum of dll's.
For the few packages like bash, perl and python which fail into this trap, I would rather suggest using some reserved base address space.
I started for perl with 0x52000000 upwards but this was also not enough.


So I tried it with a custom rebase and rebaseall first.
rebaseall being bash enabled again, which would be a big winner.

sections.cc: In member function `bool Relocations::relocate(int)':
sections.cc:366: error: ISO C++ forbids cast to non-reference type
used as lvalue
make: *** [sections.o] Error 1

The cast-as-lvalue was a nonstandard gcc extension that was disabled in C++ mode (and deprecated for C mode) starting with gcc 3.4.x. Likely this package is so old that it was last built with gcc 3.3.x which still allowed the construct. So, one workaround is to temporarily install the [prev] version of gcc-g++ and gcc-core which are the 3.3 versions.

I know.
I wanted to hear some magic g++ --allow-non-ansi switch (-std=c89 or such for C++) or some INT2PTR macro.


$ g++ --help|grep ISO
is empty

Got it:
- for (; (char *)&relocp->SizeOfBlock < (char *)relocs + size && relocp->SizeOfBlock != 0; ((char *)relocp) += relocp->SizeOfBlock)
+ for (; (char *)&relocp->SizeOfBlock < *(char**)relocs + size && relocp->SizeOfBlock != 0; (*(char**)relocp) += relocp->SizeOfBlock)


Attached is my current status for an updated rebase package, cygwin compiled. And cygwin-1.7 support.

The code for the ordering on a full rebaseall is still not in.
I suggest to use a manual rebase with reserved bases for the 4 bash deps, the perl dll's and the python dll's.
Who else forks a lot? x11 maybe.
--
Reini Urban
http://phpwiki.org/ http://murbreak.at/
difforig rebase-2.4.3-1

diff -u  rebase-2.4.3-1/Changes.orig
--- rebase-2.4.3-1/Changes.orig	2005-07-28 13:29:49.000000000 +0000
+++ rebase-2.4.3-1/Changes	2008-06-02 18:31:49.875000000 +0000
@@ -1,5 +1,18 @@
 $Id: Changes,v 1.3 2005/07/28 13:29:44 jt Exp $
 
+2.5:
+===
+rebase:
+
+    * Fix compilation fixes for gcc-3.4
+    * Support cygwin 1.7
+    * Added switches -l (LIST) and -c (CHECK)
+
+rebaseall-bash:
+
+    * Added. rebase all but bash and its dependencies, thus allowing 
+      rebasing from bash.
+
 2.4:
 ===
 The following are the changes to rebaseall:
diff -u  rebase-2.4.3-1/Makefile.orig
--- rebase-2.4.3-1/Makefile.orig	2006-07-09 14:36:13.000000000 +0000
+++ rebase-2.4.3-1/Makefile	2008-06-02 18:35:25.171875000 +0000
@@ -1,13 +1,13 @@
 # $Id: Makefile,v 1.21 2006/07/09 14:36:04 jt Exp $
 
-Version = 2.4.3
+Version = 2.5.0
 LibVersion = $(shell fgrep RELEASE= imagehelper/Makefile.in|egrep -o '[0-9.]+')
 
 Files = rebase.c
 Objects = $(Files:.c=.o)
 Libs = -L imagehelper -limagehelper
 Exclude = --exclude='*.[ao]' --exclude='*.exe' --exclude='*.out' \
-  	--exclude='.[A-Za-z\#]*' --exclude='*.bz2' --exclude=CVS --exclude=RCS \
+	--exclude='.[A-Za-z\#]*' --exclude='*.bz2' --exclude=CVS --exclude=RCS \
 	--exclude=pkgs --exclude=save --exclude=test
 
 DESTDIR =
@@ -37,6 +37,7 @@
 	$(INSTALL) -d $(DESTDIR)$(BINDIR)
 	$(INSTALL) -m 755 rebase $(DESTDIR)$(BINDIR)
 	$(INSTALL) -m 755 rebaseall $(DESTDIR)$(BINDIR)
+	$(INSTALL) -m 755 rebaseall-bash $(DESTDIR)$(BINDIR)
 	$(INSTALL) -d $(DESTDIR)$(DOCDIR)
 	$(INSTALL) -m 644 README $(DESTDIR)$(DOCDIR)/rebase-$(Version).README
 
diff -u  rebase-2.4.3-1/imagehelper/ChangeLog.orig
--- rebase-2.4.3-1/imagehelper/ChangeLog.orig	2003-02-18 15:53:17.000000000 +0000
+++ rebase-2.4.3-1/imagehelper/ChangeLog	2008-06-02 17:26:55.140625000 +0000
@@ -1,3 +1,7 @@
+2008-06-02 Reini Urban <rurban@x-ray.at>
+
+	*	sections.cc: Fixed compilation for g++ 3.4
+	
 2003-02-17  Jason Tishler <jason@tishler.net>
 						
 	*	rebaseimage.cc (RebaseImage): Fixes bug when rebasing up 
diff -u  rebase-2.4.3-1/imagehelper/INSTALL.orig
--- rebase-2.4.3-1/imagehelper/INSTALL.orig	2003-01-02 17:05:13.000000000 +0000
+++ rebase-2.4.3-1/imagehelper/INSTALL	2008-06-02 17:29:16.093750000 +0000
@@ -1,34 +1,27 @@
-INSTALLATION

-============

-

-Compiling 

----------

-

-Currently compiling and installing needs the cygwin environment, targets are cygwi nand mingw 

-

-compiling for cygwin 

-

-	$ make -f Makefile.cygwin 

-

-compiling for mingw 

-

-	$ make -f Makefile.mingw 

-

-

-installing

-

-	make -f Makefile.[cygwin|mingw] install 

-

-

-Unpack this archive in the cygwin root tree. It will install the rebase executable in /usr/local/bin

-

-rebase has some options. See below: 

-

-$ rebase

-rebase Release: 0.4

-usage: rebase [-D] -b BaseAddress [-d] -o Offset <file> ...  rebase <file>  ([-D] print debug infos)

-usage: rebase [-D] -l <file> ...        list Imagebase and -size of <file>

-usage: rebase [-D] -c                   check relocations

-usage: rebase [-D] -f                   fix bad relocations

-

-

+INSTALLATION
+============
+
+Compiling 
+---------
+
+Currently compiling and installing needs the cygwin environment, targets are cygwin and mingw 
+
+compiling for cygwin 
+	$ make -f Makefile.cygwin 
+
+compiling for mingw 
+	$ make -f Makefile.mingw 
+
+installing
+	make -f Makefile.[cygwin|mingw] install 
+
+Unpack this archive in the cygwin root tree. It will install the rebase executable 
+in /usr/local/bin
+rebase has some options. See below: 
+
+$ rebase
+rebase Release: 0.8
+usage: rebase [-D] -b BaseAddress [-d] -o Offset <file> ...  rebase <file>  ([-D] print debug infos)
+usage: rebase [-D] -l <file> ...        list Imagebase and -size of <file>
+usage: rebase [-D] -c                   check relocations
+usage: rebase [-D] -f                   fix bad relocations
diff -u  rebase-2.4.3-1/imagehelper/Makefile.in.orig
--- rebase-2.4.3-1/imagehelper/Makefile.in.orig	2003-01-02 20:07:35.000000000 +0000
+++ rebase-2.4.3-1/imagehelper/Makefile.in	2008-06-02 17:35:04.625000000 +0000
@@ -1,4 +1,4 @@
-RELEASE=0.7
+RELEASE=0.8
 
 CXXFLAGS=-O2  $(CXXFLAGS_OPT)
 LDFLAGS=$(LDFLAGS_OPT)
@@ -49,15 +49,13 @@
 version.c: 	Makefile.in 
 	echo "float release = $(RELEASE); " >version.c 
 
-	
 install: $(TARGETS)
 	/usr/bin/install $^ /usr/local/bin
 	/usr/bin/install -d /usr/doc/rebase-$(RELEASE)
 	/usr/bin/install README INSTALL /usr/doc/rebase-$(RELEASE)
-	
+
 clean: 
 	rm -f *.o *.dll *.exe *.bak *.stackdump *.bz2 version.c *.orig *.doxygen *.a
-	
 
 indent: 
 	astyle --style=gnu -s2 --convert-tabs *.cc *.h
@@ -70,8 +68,7 @@
 	@make clean
 	@cd .. && tar -cjvf rebase-$(RELEASE)-src.tar.bz2 rebase/*
 	@echo "archive '`cygpath -aw $rebase-$(RELEASE)-src.tar.bz2`' created"
-	
+
 bindist: 
 	cd / && tar -cjvf /tmp/rebase-$(RELEASE).tar.bz2 /usr/local/bin/rebase.exe /usr/doc/rebase-$(RELEASE)
 	mv /tmp/rebase-$(RELEASE).tar.bz2 .
-	
\ No newline at end of file
diff -u  rebase-2.4.3-1/imagehelper/objectfile.cc.orig
--- rebase-2.4.3-1/imagehelper/objectfile.cc.orig	2003-01-04 12:43:00.000000000 +0000
+++ rebase-2.4.3-1/imagehelper/objectfile.cc	2008-06-02 17:39:35.015625000 +0000
@@ -28,17 +28,22 @@
 // read a dll into the cache
 
 #ifdef __CYGWIN__
-#include <sys/cygwin.h>
+#  include <sys/cygwin.h>
+#  include <cygwin/version.h>
 #endif
 
 #ifdef __CYGWIN__
-
-static char * Win32Path(char * s)
+static char * 
+Win32Path(char * s)
 {
   char buf[MAX_PATH];
   if (!s || *s == '\0')
     return "";
+#if (CYGWIN_VERSION_API_MINOR >= 181)
+  cygwin_conv_path(CCP_WIN_TO_POSIX_W | CCP_RELATIVE, s, buf, MAX_PATH);
+#else
   cygwin_conv_to_win32_path(s, buf);
+#endif
   return strdup(buf);
 }
 #else
diff -u  rebase-2.4.3-1/imagehelper/rebase_main.cc.orig
--- rebase-2.4.3-1/imagehelper/rebase_main.cc.orig	2003-01-03 22:44:56.000000000 +0000
+++ rebase-2.4.3-1/imagehelper/rebase_main.cc	2008-06-02 17:39:44.171875000 +0000
@@ -26,7 +26,8 @@
 #include <stdlib.h>
 #include <getopt.h>
 #ifdef __CYGWIN__
-#include <sys/cygwin.h>
+#  include <sys/cygwin.h>
+#  include <cygwin/version.h>
 #endif
 #include <windows.h>
 
@@ -122,7 +123,11 @@
 PosixToWin32(const string& aPosixPath)
 {
   char aWin32Path[MAX_PATH];
+#if (CYGWIN_VERSION_API_MINOR >= 181)
+  cygwin_conv_path(CCP_POSIX_TO_WIN_W | CCP_RELATIVE, aPosixPath.c_str(), aWin32Path, MAX_PATH);
+#else
   cygwin_conv_to_win32_path(aPosixPath.c_str(), aWin32Path);
+#endif
   return aWin32Path;
 }
 #endif
diff -u  rebase-2.4.3-1/imagehelper/sections.cc.orig
--- rebase-2.4.3-1/imagehelper/sections.cc.orig	2003-02-14 15:01:13.000000000 +0000
+++ rebase-2.4.3-1/imagehelper/sections.cc	2008-06-02 17:24:38.781250000 +0000
@@ -285,7 +285,7 @@
   if (debug)
     std::cerr << "debug: checking relocations .... " << std::endl;
 
-  for (; (char *)&relocp->SizeOfBlock < (char *)relocs + size && relocp->SizeOfBlock != 0; ((char *)relocp) += relocp->SizeOfBlock)
+  for (; (char *)&relocp->SizeOfBlock < *(char**)relocs + size && relocp->SizeOfBlock != 0; (*(char**)relocp) += relocp->SizeOfBlock)
     {
       int NumOfRelocs = (relocp->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof (WORD);
       int va = relocp->VirtualAddress;
@@ -328,7 +328,7 @@
   if (debug)
     std::cerr << "warning: fixing bad relocations .... ";
 
-  for (; (char *)&relocp->SizeOfBlock < (char *)relocs + size && relocp->SizeOfBlock != 0; ((char *)relocp) += relocp->SizeOfBlock)
+  for (; (char *)&relocp->SizeOfBlock < *(char**)relocs + size && relocp->SizeOfBlock != 0; (*(char**)relocp) += relocp->SizeOfBlock)
     {
       int NumOfRelocs = (relocp->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof (WORD);
       int va = relocp->VirtualAddress;
@@ -363,7 +363,7 @@
   if (!relocs)
     return false;
 
-  for (; (char *)&relocp->SizeOfBlock < (char *)relocs + size && relocp->SizeOfBlock != 0; ((char *)relocp) += relocp->SizeOfBlock)
+  for (; (char *)&relocp->SizeOfBlock < *(char**)relocs + size && relocp->SizeOfBlock != 0; (*(char**)relocp) += relocp->SizeOfBlock)
     {
       int NumOfRelocs = (relocp->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof (WORD);
       int va = relocp->VirtualAddress;
diff -u  rebase-2.4.3-1/imagehelper/version.c.orig
--- rebase-2.4.3-1/imagehelper/version.c.orig	2008-06-02 17:25:39.234375000 +0000
+++ rebase-2.4.3-1/imagehelper/version.c	2008-06-02 17:39:56.015625000 +0000
@@ -1 +1 @@
-float release = 0.7; 
+float release = 0.8; 
diff -u  rebase-2.4.3-1/rebase.c.orig
--- rebase-2.4.3-1/rebase.c.orig	2004-03-11 21:46:44.000000000 +0000
+++ rebase-2.4.3-1/rebase.c	2008-06-02 18:29:51.078125000 +0000
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2001, 2002, 2003 Jason Tishler
+ * Copyright (c) 2008 Reini Urban
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,6 +24,10 @@
 #include <string.h>
 #include <unistd.h>
 #include <getopt.h>
+#ifdef __CYGWIN__
+#  include <sys/cygwin.h>
+#  include <cygwin/version.h>
+#endif
 #include "imagehelper.h"
 
 BOOL rebase (const char *pathname, ULONG *new_image_base);
@@ -34,12 +39,19 @@
 char *file_list_fgets (char *buf, int size, FILE *file);
 int file_list_fclose (FILE *file);
 void version ();
+#ifdef __CYGWIN__
+char *posix_to_win32(const char *posix_path);
+#else
+#define posix_to_win32(posix_path) posix_path
+#endif
 
 ULONG image_base = 0;
 BOOL down_flag = FALSE;
 ULONG offset = 0;
 int args_index = 0;
 int verbose = 0;
+int list_flag = 0;
+int check_flag = 0;
 const char *file_list = 0;
 const char *stdin_file_list = "-";
 
@@ -99,6 +111,17 @@
       return TRUE;
     }
 
+  if (list_flag) 
+    {
+	status = GetImageInfos((char *)pathname, &prev_new_image_base, &new_image_size);
+      if (status)
+	  fprintf (stderr, "%s: ImageBase=0x%x ImageSize=0x%x\n", pathname, 
+		   prev_new_image_base, new_image_size);
+      else
+	  fprintf (stderr, "%s: list failed\n", pathname);
+      return status;
+    }
+
   /* Skip if not writable. */
   if (access (pathname, W_OK) == -1)
     {
@@ -109,28 +132,35 @@
   /* Skip if not rebaseable. */
   if (!is_rebaseable (pathname))
     {
-      if (verbose)
+      if (verbose || check_flag)
 	fprintf (stderr, "%s: skipped because not rebaseable\n", pathname);
       return TRUE;
     }
 
+  if (check_flag) 
+    {
+      status = CheckImage((char *)pathname);
+      fprintf (stderr, "%s: CheckImage %s\n", pathname, status ? "ok" : "not ok");
+      return status;
+    }
+
   /* Calculate next base address, if rebasing down. */
   if (down_flag)
     *new_image_base -= offset;
 
   /* Rebase the image. */
   prev_new_image_base = *new_image_base;
-  status = ReBaseImage ((char*) pathname,	/* CurrentImageName */
-			 "",			/* SymbolPath */
-			 TRUE,			/* fReBase */
-			 FALSE,			/* fRebaseSysfileOk */
-			 down_flag,		/* fGoingDown */
-			 0,			/* CheckImageSize */
-			 &old_image_size,	/* OldImageSize */
-			 &old_image_base,	/* OldImageBase */
-			 &new_image_size,	/* NewImageSize */
-			 new_image_base,	/* NewImageBase */
-			 time (0));		/* TimeStamp */
+  status = ReBaseImage ((char *)pathname,	/* CurrentImageName */
+			"",			/* SymbolPath */
+			TRUE,			/* fReBase */
+			FALSE,			/* fRebaseSysfileOk */
+			down_flag,		/* fGoingDown */
+			0,			/* CheckImageSize */
+			&old_image_size,	/* OldImageSize */
+			&old_image_base,	/* OldImageBase */
+			&new_image_size,	/* NewImageSize */
+			new_image_base,		/* NewImageBase */
+			time (0));		/* TimeStamp */
 
   /* MS's ReBaseImage seems to never return false! */
   status2 = GetLastError ();
@@ -140,7 +170,7 @@
     {
       if (verbose)
 	fprintf (stderr, "%s: fixing bad relocations\n", pathname);
-      BOOL status3 = FixImage ((char*) pathname);
+      BOOL status3 = FixImage ((char *)pathname);
       if (!status3)
 	{
 	  fprintf (stderr, "FixImage (%s) failed with last error = %lu\n",
@@ -149,7 +179,7 @@
 	}
 
       /* Retry rebase.*/
-      status = ReBaseImage ((char*) pathname,	/* CurrentImageName */
+      status = ReBaseImage ((char *)pathname,	/* CurrentImageName */
 			    "",			/* SymbolPath */
 			    TRUE,		/* fReBase */
 			    FALSE,		/* fRebaseSysfileOk */
@@ -191,7 +221,7 @@
 void
 parse_args (int argc, char *argv[])
 {
-  const char *anOptions = "b:do:T:vV";
+  const char *anOptions = "b:do:T:vVlc";
   int anOption = 0;
 
   for (anOption; (anOption = getopt (argc, argv, anOptions)) != -1;)
@@ -212,11 +242,18 @@
 	  break;
 	case 'v':
 	  verbose = TRUE;
+	  SetImageHelperDebug(1);
 	  break;
 	case 'V':
 	  version ();
 	  exit (1);
 	  break;
+	case 'l':
+	  list_flag = 1;
+	  break;
+	case 'c':
+	  check_flag = 1;
+	  break;
 	default:
 	  usage ();
 	  exit (1);
@@ -224,7 +261,7 @@
 	}
     }
 
-  if (image_base == 0)
+  if (image_base == 0 && list_flag == 0 && check_flag == 0)
     {
       usage ();
       exit (1);
@@ -245,8 +282,9 @@
 usage ()
 {
   fprintf (stderr,
-	   "usage: rebase -b BaseAddress [-Vdv] [-o Offset] "
-	   "[-T FileList | -] Files...\n");
+	   "usage: rebase -b BaseAddress [-Vdv] [-o Offset] [-T FileList | -] Files...\n"
+           "usage: rebase [-v] -l <file> ...        list Imagebase and -size of <file>\n"
+           "usage: rebase [-v] -c                   check relocations");
 }
 
 BOOL
@@ -334,5 +372,19 @@
   fprintf (stderr, "rebase version %s (imagehelper version %s)\n",
 	   VERSION, LIB_VERSION);
   fprintf (stderr, "Copyright (c) 2001, 2002, 2003, 2004 "
-	   "Ralf Habacker and Jason Tishler\n");
+	   "Ralf Habacker and Jason Tishler\nCopyright (c) 2008 Reini Urban");
+}
+
+#ifdef __CYGWIN__
+char *
+posix_to_win32(const char *posix_path)
+{
+  char win32_path[MAX_PATH];
+#if (CYGWIN_VERSION_API_MINOR >= 181)
+  cygwin_conv_path(CCP_POSIX_TO_WIN_W | CCP_RELATIVE, posix_path, win32_path, MAX_PATH);
+#else
+  cygwin_conv_to_win32_path(posix_path, win32_path);
+#endif
+  return win32_path;
 }
+#endif
diff -u  rebase-2.4.3-1/rebaseall-bash.orig
--- rebase-2.4.3-1/rebaseall-bash.orig	2008-06-02 18:23:20.421875000 +0000
+++ rebase-2.4.3-1/rebaseall-bash	2008-06-02 18:34:24.171875000 +0000
@@ -0,0 +1,124 @@
+#!/bin/bash
+#
+# Copyright (c) 2003, 2005, 2006 Jason Tishler
+# Copyright (c) 2008 Reini Urban
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# A copy of the GNU General Public License can be found at
+# http://www.gnu.org/
+#
+# Written by Jason Tishler <jason@tishler.net>
+#
+# $Id: rebaseall,v 1.20 2006/07/09 14:36:18 jt Exp $
+#
+
+# Define constants
+PATH=/bin
+ProgramName=`basename $0`
+ProgramOptions='b:o:s:T:v'
+# bash deps start at 0x70000000 with size
+DefaultBaseAddress=0x6fff0000
+DefaultOffset=0x10000
+DefaultVerbose=
+DefaultFileList=
+DefaultSuffixes='dll|so'
+BashExcludes='/bin/bash\.exe|/bin/cygintl-8\.dll|/bin/cygiconv-2\.dll|/bin/cygreadline6\.dll|/bin/cygncurses-8\.dll'
+
+# Define functions
+usage()
+{
+    echo "usage: $ProgramName [-b BaseAddress] [-o Offset] [-s DllSuffix] [-T FileList | -] [-v]"
+    exit 1
+}
+
+cleanup()
+{
+    rm -f "$TmpFile"
+    exit $ExitCode
+}
+
+# Set traps
+trap cleanup 1 2 15
+
+# Set defaults
+BaseAddress=$DefaultBaseAddress
+Offset=$DefaultOffset
+Verbose=$DefaultVerbose
+FileList=$DefaultFileList
+Suffixes=$DefaultSuffixes
+
+# Verify only bash processes are running
+grep -E -q -i -v '/bash(.exe)?$' /proc/[0-9]*/exename
+if [ $? -eq 0 -a -z "$RebaseDebug" ]
+then
+    echo "$ProgramName: only bash processes are allowed during rebasing"
+    echo "    Exit all Cygwin processes and stop all Cygwin services."
+    echo "    Execute '/bin/$ProgramName' from bash."
+    exit 2
+fi
+
+# Parse command line arguments
+while getopts $ProgramOptions Option "$@"
+do
+    case $Option in
+    b)
+	BaseAddress=$OPTARG;;
+    o)
+	Offset=$OPTARG;;
+    s)
+	Suffixes="$Suffixes|$OPTARG";;
+    T)
+	FileList="$OPTARG";;
+    v)
+	Verbose=-v;;
+    \?)
+	usage;;
+    esac
+done
+
+# Set temp directory
+TmpDir="${TMP:-${TEMP:-/tmp}}"
+
+# Validate temp directory
+if [ ! -d "$TmpDir" ]
+then
+    echo "$ProgramName: '$TmpDir' is not a directory"
+    exit 2
+fi
+if [ ! -w "$TmpDir" ]
+then
+    echo "$ProgramName: '$TmpDir' is not writable"
+    exit 2
+fi
+
+# Validate user supplied file list, if necessary
+if [ -n "$FileList" -a ! -r "$FileList" -a "$FileList" != - ]
+then
+    echo "$ProgramName: '$FileList' is not readable"
+    exit 2
+fi
+
+# Set temp file
+TmpFile="$TmpDir/rebase.lst"
+
+# Create rebase list
+# TODO: Do some reshuffling with some fixed entries at the front (bash, perl, python)
+gzip -d -c /etc/setup/*.lst.gz | grep -E "($Suffixes)\$" | grep -vE "($BashExcludes)\$" |\
+    sed -e '/cygwin1.dll$/d' -e 's/^/\//' >"$TmpFile"
+
+# Append user supplied file list, if any
+if [ -n "$FileList" ]
+then
+    cat "$FileList" >>"$TmpFile"
+fi
+
+# Rebase files
+rebase $Verbose -d -b $BaseAddress -o $Offset -T "$TmpFile"
+ExitCode=$?
+
+# Clean up
+cleanup
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]