Hi Jason, On Feb 13 10:42, Corinna Vinschen wrote: > On Feb 12 20:24, Jason Tishler wrote: > > On Tue, Feb 12, 2013 at 12:01:52PM +0100, Corinna Vinschen wrote: > > > On Feb 12 04:19, Yaakov wrote: > > > > Then the conf.d could be in addition to my patch, in which case my > > > > patch is just avoiding the need for the packages in question to > > > > state that which we already know. > > > > > > I'm ok with that, but ultimately it's Jason's call. > > > > I'm fine with the above too. Let me know when your patches are > > committed and I will release rebase. > > Here's a preliminary patch for 64 bit Cygwin. > [...]
Below is an entirely new patch. Not only that the cyg64 prefix got dropped, but only With these changes rebase builds fine on x86_64-pc-cygwin. There are a few problems related to datatype conversion, most of them can be fixed by simply casting another part of the expression. I uploaded a binary x86_64-pc-cygwin version of rebase, based on the below patch, here: ftp://cygwin.com/pub/cygwin/64bit/rebase-4.4.0-1.x86_64.tar.xz Ok to apply? Thanks, Corinna * peflags.c (main): Drop unused variable. (do_mark): Add unambiguous casts to arguments of printf statement. * rebase-db.c: Ditto, throughout. * rebase-dump.c: Ditto, throughout. * rebase.c: Ditto. (main): Fix computation of 32 bit Cygwin DLL dead zone. Handle x86_64 Cygwin as well. (rebase): Remove unused variable. * rebaseall.in: Take x86_64 Cygwin into account. imagehelper: Throughout, tweak pointer expressions to use unambiguous cast on all supported platforms. * sections.cc (Exports::dump): Constify argument to avoid compiler warning. (Imports::dump): Ditto. * sections.h (SectionBase::getAdjust): Change type to ptrdiff_t. (SectionBase::adjust): Ditto. (Exports::dump): Constify argument in declaration to avoid compiler warning. (Imports::dump): Ditto. Index: peflags.c =================================================================== RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/peflags.c,v retrieving revision 1.9 diff -u -p -r1.9 peflags.c --- peflags.c 11 Aug 2011 07:01:13 -0000 1.9 +++ peflags.c 15 Feb 2013 17:22:38 -0000 @@ -263,7 +263,7 @@ main (int argc, char *argv[]) /* Operate on files in file list, if specified. */ if (file_list) { - int status = 0, ret = 0; + int status = 0; char filename[MAX_PATH + 2]; FILE *file = file_list_fopen (file_list); @@ -461,8 +461,8 @@ do_mark (const char *pathname) printed_characteristic ? (int) strlen (pathname) + 2 : 0, "", sizeof_vals[i].name, - sizeof_vals[i].value, - sizeof_vals[i].value, + (uint64_t) sizeof_vals[i].value, + (uint64_t) sizeof_vals[i].value, sizeof_vals[i].unit); printed_characteristic = TRUE; } Index: rebase-db.c =================================================================== RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/rebase-db.c,v retrieving revision 1.2 diff -u -p -r1.2 rebase-db.c --- rebase-db.c 3 Aug 2011 13:40:16 -0000 1.2 +++ rebase-db.c 15 Feb 2013 17:22:38 -0000 @@ -62,9 +62,9 @@ dump_rebasedb_header (FILE *f, img_info_ " machine: %s\n" " version: %d\n" " base : 0x%0*" PRIx64 "\n" - " offset : 0x%08lx\n" + " offset : 0x%08x\n" " downflg: %s\n" - " count : %ld\n", + " count : %d\n", h->magic[0], h->magic[1], h->magic[2], h->magic[3], (h->machine == IMAGE_FILE_MACHINE_I386 ? "i386" @@ -73,10 +73,10 @@ dump_rebasedb_header (FILE *f, img_info_ : "unknown")), h->version, (h->machine == IMAGE_FILE_MACHINE_I386 ? 8 : 12), - h->base, - h->offset, + (uint64_t) h->base, + (uint32_t) h->offset, (h->down_flag ? "true" : "false"), - h->count); + (uint32_t) h->count); } void @@ -95,13 +95,13 @@ dump_rebasedb_entry (FILE *f, return; } fprintf (f, - "%-*s base 0x%0*" PRIx64 " size 0x%08lx slot 0x%08lx %c\n", + "%-*s base 0x%0*" PRIx64 " size 0x%08x slot 0x%08x %c\n", h->machine == IMAGE_FILE_MACHINE_I386 ? 45 : 41, entry->name, h->machine == IMAGE_FILE_MACHINE_I386 ? 8 : 12, - entry->base, - entry->size, - entry->slot_size, + (uint64_t) entry->base, + (uint32_t) entry->size, + (uint32_t) entry->slot_size, entry->flag.needs_rebasing ? '*' : ' '); } Index: rebase-dump.c =================================================================== RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/rebase-dump.c,v retrieving revision 1.3 diff -u -p -r1.3 rebase-dump.c --- rebase-dump.c 13 Jul 2012 20:13:35 -0000 1.3 +++ rebase-dump.c 15 Feb 2013 17:22:38 -0000 @@ -125,7 +125,7 @@ load_image_info () } if (verbose) printf ("== read %" PRIu64 " (0x%08" PRIx64 ") bytes (database header)\n", - (unsigned long long) sizeof hdr, (unsigned long long) sizeof hdr); + (uint64_t) sizeof hdr, (uint64_t) sizeof hdr); /* Check the header. */ if (memcmp (hdr.magic, IMG_INFO_MAGIC, 4) != 0) @@ -150,8 +150,8 @@ load_image_info () if (hdr.version != IMG_INFO_VERSION) { fprintf (stderr, "%s: \"%s\" is a version %u rebase database.\n" - "I can only handle versions up to %lu.\n", - progname, db_file, hdr.version, IMG_INFO_VERSION); + "I can only handle versions up to %u.\n", + progname, db_file, hdr.version, (uint32_t) IMG_INFO_VERSION); close (fd); return -1; } @@ -179,8 +179,8 @@ load_image_info () if (ret == 0 && verbose) { printf ("== read %" PRIu64 " (0x%08" PRIx64 ") bytes (database w/o strings)\n", - (unsigned long long) img_info_size * sizeof (img_info_t), - (unsigned long long) img_info_size * sizeof (img_info_t)); + (uint64_t) img_info_size * sizeof (img_info_t), + (uint64_t) img_info_size * sizeof (img_info_t)); } /* Make sure all pointers are NULL (also dump db as read) */ if (ret == 0) @@ -192,13 +192,13 @@ load_image_info () { img_info_list[i].name = NULL; if (verbose) - printf ("%03d: base 0x%0*" PRIx64 " size 0x%08lx slot 0x%08lx namesize %4ld %c\n", + printf ("%03d: base 0x%0*" PRIx64 " size 0x%08x slot 0x%08x namesize %4d %c\n", i, hdr.machine == IMAGE_FILE_MACHINE_I386 ? 8 : 12, - img_info_list[i].base, - img_info_list[i].size, - img_info_list[i].slot_size, - img_info_list[i].name_size, + (uint64_t) img_info_list[i].base, + (uint32_t) img_info_list[i].size, + (uint32_t) img_info_list[i].slot_size, + (uint32_t) img_info_list[i].name_size, img_info_list[i].flag.needs_rebasing ? '*' : ' '); } } @@ -229,9 +229,9 @@ load_image_info () } else if (verbose) { - printf ("%03d: namesize %4ld (0x%04lx) %s\n", i, - img_info_list[i].name_size, - img_info_list[i].name_size, + printf ("%03d: namesize %4d (0x%04x) %s\n", i, + (uint32_t) img_info_list[i].name_size, + (uint32_t) img_info_list[i].name_size, img_info_list[i].name); } } Index: rebase.c =================================================================== RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/rebase.c,v retrieving revision 1.17 diff -u -p -r1.17 rebase.c --- rebase.c 16 Jan 2013 16:15:40 -0000 1.17 +++ rebase.c 15 Feb 2013 17:22:39 -0000 @@ -163,15 +163,23 @@ main (int argc, char *argv[]) into the memory area taken by the Cygwin DLL. */ GetImageInfos64 ("/bin/cygwin1.dll", NULL, &cygwin_dll_image_base, &cygwin_dll_image_size); - /* Take the three shared memory areas preceeding the DLL into account. */ - cygwin_dll_image_base -= 3 * ALLOCATION_SLOT; + /* Take the up to four shared memory areas preceeding the DLL into + account. */ + cygwin_dll_image_base -= 4 * ALLOCATION_SLOT; /* Add a slack of 8 * 64K at the end of the Cygwin DLL. This leave a bit of room to install newer, bigger Cygwin DLLs, as well as room to install non-optimized DLLs for debugging purposes. Otherwise the slightest change might break fork again :-P */ - cygwin_dll_image_size += 3 * ALLOCATION_SLOT + 8 * ALLOCATION_SLOT; + cygwin_dll_image_size += 4 * ALLOCATION_SLOT + 8 * ALLOCATION_SLOT; } -#endif + else + { + /* On x86_64 Cygwin, we want to keep free the whole 2 Gigs area in which + the Cygwin DLL resides, no matter what. */ + cygwin_dll_image_base = 0x180000000L; + cygwin_dll_image_size = 0x080000000L; + } +#endif /* __CYGWIN__ */ /* Collect file list, if specified. */ if (file_list) @@ -449,8 +457,8 @@ load_image_info () if (hdr.version != IMG_INFO_VERSION) { fprintf (stderr, "%s: \"%s\" is a version %u rebase database.\n" - "I can only handle versions up to %lu.\n", - progname, db_file, hdr.version, IMG_INFO_VERSION); + "I can only handle versions up to %u.\n", + progname, db_file, hdr.version, (uint32_t) IMG_INFO_VERSION); close (fd); return -1; } @@ -966,12 +974,12 @@ print_image_info () img_info_list[i].flag.needs_rebasing = 1; img_info_list[tst].flag.needs_rebasing = 1; } - printf ("%-*s base 0x%0*" PRIx64 " size 0x%08lx %c\n", + printf ("%-*s base 0x%0*" PRIx64 " size 0x%08x %c\n", name_width, img_info_list[i].name, machine == IMAGE_FILE_MACHINE_I386 ? 8 : 12, - img_info_list[i].base, - img_info_list[i].size, + (uint64_t) img_info_list[i].base, + (uint32_t) img_info_list[i].size, img_info_list[i].flag.needs_rebasing ? '*' : ' '); } } @@ -981,7 +989,7 @@ rebase (const char *pathname, ULONG64 *n { ULONG64 old_image_base, prev_new_image_base; ULONG old_image_size, new_image_size; - BOOL status, status2; + BOOL status; /* Skip if not writable. */ if (access (pathname, W_OK) == -1) @@ -1001,56 +1009,56 @@ retry: /* Rebase the image. */ prev_new_image_base = *new_image_base; - status = ReBaseImage64 ((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 */ + ReBaseImage64 ((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 (); + status = GetLastError (); /* If necessary, attempt to fix bad relocations. */ - if (status2 == ERROR_INVALID_DATA) + if (status == ERROR_INVALID_DATA) { if (verbose) fprintf (stderr, "%s: fixing bad relocations\n", pathname); BOOL status3 = FixImage ((char*) pathname); if (!status3) { - fprintf (stderr, "FixImage (%s) failed with last error = %lu\n", - pathname, GetLastError ()); + fprintf (stderr, "FixImage (%s) failed with last error = %u\n", + pathname, (uint32_t) GetLastError ()); return FALSE; } /* Retry rebase.*/ - status = ReBaseImage64 ((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 */ + ReBaseImage64 ((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 (); + status = GetLastError (); } /* Check status of rebase. */ - if (status2 != 0) + if (status != 0) { - fprintf (stderr, "ReBaseImage (%s) failed with last error = %lu\n", - pathname, GetLastError ()); + fprintf (stderr, "ReBaseImage (%s) failed with last error = %u\n", + pathname, (uint32_t) GetLastError ()); return FALSE; } @@ -1070,10 +1078,10 @@ retry: /* Display rebase results, if verbose. */ if (verbose) { - printf ("%s: new base = %" PRIx64 ", new size = %lx\n", + printf ("%s: new base = %" PRIx64 ", new size = %x\n", pathname, - ((down_flag) ? *new_image_base : prev_new_image_base), - new_image_size + offset); + (uint64_t) ((down_flag) ? *new_image_base : prev_new_image_base), + (uint32_t) new_image_size + offset); } /* Calculate next base address, if rebasing up. */ @@ -1196,7 +1204,7 @@ parse_args (int argc, char *argv[]) { fprintf (stderr, "%s: Base address 0x%" PRIx64 " too big for 32 bit machines.\n", - progname, image_base); + progname, (uint64_t) image_base); exit (1); } Index: rebaseall.in =================================================================== RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/rebaseall.in,v retrieving revision 1.9 diff -u -p -r1.9 rebaseall.in --- rebaseall.in 7 Jun 2012 18:50:33 -0000 1.9 +++ rebaseall.in 15 Feb 2013 17:22:39 -0000 @@ -88,6 +88,15 @@ case $Platform in ;; esac +# On x86_64 Cygwin, set DefaultAddressBase to 0x4:00000000 +case $Platform in + cygwin ) + [ `uname -m` = "x86_64" ] && DefaultBaseAddress=0x400000000 + ;; + * ) + ;; +esac + # Parse command line arguments while getopts "${ProgramOptions}" Option "$@" do Index: imagehelper/objectfile.cc =================================================================== RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/imagehelper/objectfile.cc,v retrieving revision 1.8 diff -u -p -r1.8 objectfile.cc --- imagehelper/objectfile.cc 3 Aug 2011 10:33:11 -0000 1.8 +++ imagehelper/objectfile.cc 15 Feb 2013 17:22:39 -0000 @@ -260,7 +260,7 @@ bool LinkedObjectFile::rebind(ObjectFile { bool autoImportFlag; int *patch_address; - char *dllname = (char *)p->Name + idata->getAdjust(); + char *dllname = (char *)idata->getAdjust() + p->Name; // std::cerr << dllname << std::endl; if (!(obj = (LinkedObjectFile *)cache.get(dllname) ) ) @@ -408,7 +408,7 @@ bool LinkedObjectFile::PrintDependencies while ((p = imports->getNextDescriptor()) != NULL) { Section *sect = sections->find(p->Name); - char *dllname = (char *)p->Name + sect->getAdjust(); + char *dllname = (char *)sect->getAdjust() + p->Name; if (!(obj = (LinkedObjectFile *)cache.get(dllname) ) ) { Index: imagehelper/sections.cc =================================================================== RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/imagehelper/sections.cc,v retrieving revision 1.5 diff -u -p -r1.5 sections.cc --- imagehelper/sections.cc 16 Jan 2013 12:47:26 -0000 1.5 +++ imagehelper/sections.cc 15 Feb 2013 17:22:39 -0000 @@ -151,9 +151,9 @@ uint Exports::getVirtualAddress(char *sy return 0; int n = exports->NumberOfFunctions; - uint *p = (unsigned int *)((char *)exports->AddressOfFunctions + adjust); - char **s = (char **)((char *)exports->AddressOfNames + adjust); - ushort *o = (ushort *)((char *)exports->AddressOfNameOrdinals + adjust); + uint *p = (unsigned int *)((char *)adjust + exports->AddressOfFunctions); + char **s = (char **)((char *)adjust + exports->AddressOfNames); + ushort *o = (ushort *)((char *)adjust + exports->AddressOfNameOrdinals); for (int i = 0; i < n; i++,p++,s++) { if (strcmp(symbol,*s+adjust) == 0) @@ -178,7 +178,7 @@ char *Exports::getNext(void) if (iterator < exports->NumberOfNames) { - char **s = (char **)((char *)exports->AddressOfNames + adjust); + char **s = (char **)((char *)adjust + exports->AddressOfNames); return (char *)(*(s+iterator++) + adjust); } else @@ -186,7 +186,7 @@ char *Exports::getNext(void) } -void Exports::dump(char *title) +void Exports::dump(const char *title) { char *p; @@ -241,7 +241,7 @@ ImportDescriptor *Imports::getNextDescri return 0; } -void Imports::dump(char *title) +void Imports::dump(const char *title) { ImportDescriptor *p; @@ -257,7 +257,7 @@ void Imports::dump(char *title) std::cout << std::setw(8) << std::setfill('0') << std::hex << p->OriginalFirstThunk << std::dec << " "; std::cout << std::setw(8) << std::setfill('0') << std::hex << p->TimeDateStamp << std::dec << " "; std::cout << std::setw(8) << std::setfill('0') << std::hex << p->ForwarderChain << std::dec << " "; - std::cout << std::setw(8) << std::setfill('0') << std::hex << (void *)p->Name << std::dec << " "; + std::cout << std::setw(8) << std::setfill('0') << std::hex << p->Name << std::dec << " "; std::cout << std::setw(8) << std::setfill('0') << std::hex << p->FirstThunk << std::dec << std::endl; } Index: imagehelper/sections.h =================================================================== RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/imagehelper/sections.h,v retrieving revision 1.6 diff -u -p -r1.6 sections.h --- imagehelper/sections.h 16 Jan 2013 12:47:26 -0000 1.6 +++ imagehelper/sections.h 15 Feb 2013 17:22:39 -0000 @@ -84,13 +84,13 @@ class Base class SectionBase : public Base { public: - int getAdjust() + ptrdiff_t getAdjust() { return adjust; } protected: - int adjust; + ptrdiff_t adjust; private: }; @@ -172,7 +172,7 @@ class Exports : SectionBase // return next exported name char *getNext(void); - void dump(char *title = ""); + void dump(const char *title = ""); private: ExportDirectory *exports; @@ -190,7 +190,7 @@ class Imports : public SectionBase Imports(SectionList §ions, DataDirectory *iddp); void reset(void); ImportDescriptor *getNextDescriptor(void); - void dump(char *title = ""); + void dump(const char *title = ""); private: ImportDescriptor *imports; -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat
