Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com From: "Jon Leichter" To: "Mumit Khan" Cc: Subject: RE: Specifying a base address Date: Fri, 5 Nov 1999 00:07:38 -0800 Message-ID: <000101bf2764$d3055c60$a0418218@bass.we.mediaone.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 In-Reply-To: <199911050530.XAA03616@mercury.xraylith.wisc.edu> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Importance: Normal Thanks Mumit. That worked. A few comments: - I'm using 'libtool' to build my binaries. I don't have much of a choice because it's an integral part of the project that I'm working on. Unfortunately, 'libtool' has a bad bug where it strips certain command line switches on the final link. This seems to include the -Wl switch, which is very irritating. - The reason I asked this question to begin with was because of a strange thing I was seeing in 'gdb' (both Cygwin and Mingw32 versions). I have an .exe binary that ends up explicitly loading 2 DLLs, both of which had the same base image addresses, by default. The problem that I saw is that after the second DLL loads and relocates, the symbol names in the stack were corrupt. The symbols names for the first DLL were coming out of the address space of the second DLL. Thus, I wanted to change the image base address before the DLLs were automatically relocated to verify that this would resolve the problem in 'gdb', and it did. I don't know if I really care about always building with the base address explicitly set. - Prior to posting the question, I DID TRY to find documentation on ld. The web pages on Cygwin's site don't cover any i386pe specific options. However, I did do a 'ld --help', and I really must have been blind because I now see the --image-base switch, although it somehow eluded me before. Thanks again. - About EDITBIN. I just did something wrong when I tried before. When I tried again, it worked.... sort of... First of all, I DID use the /rebase option. I can't tell which option to use if that's not the one. After using /rebase, I was able to get the base address to change, but this messed up things in 'gdb' even worse. 'gdb' was unable to read any symbols from any DLL that I loaded whose address was not the original before EDITBIN (i.e. 0x10000000). So I really don't know what to think about this. Jon Leichter jon AT symas DOT com > -----Original Message----- > From: Mumit Khan [mailto:khan AT thor DOT xraylith DOT wisc DOT edu] > Sent: Thursday, November 04, 1999 9:30 PM > To: Jon Leichter > Cc: cygwin AT sourceware DOT cygnus DOT com > Subject: Re: Specifying a base address > > > "Jon Leichter" writes: > > Forgive me if this has been asked before. I searched the archives > but didn't > > come up with an answer. > > > > With the Cygwin set of compiler utilities, how does one go about > setting the > > base image address for a DLL? > > Pass the --image-base= to the linker. If you're using GCC to > create the DLL, use -Wl,--image-base= > > $ gcc -Wl,--image-base=0x66000000 [... rest ...] > > > Is there a particular tool that I can use to change the base image address > > after the DLL is built? For instance, MSVC provides a tool called > EDITBIN tha > > t > > does just that. (By the way, I tried to use EDITBIN on a DLL that > I built wit > > h > > gcc, and EDITBIN failed). > > EDITBIN has always worked for me, so perhaps something is wrong with the > DLL (eg,. due to a bug in the linker)? There's also REBASE, but I've never > used it. > > > If there is no tool, is there a way to specify the base address > at link time? > > Do I need to provide a .def file for this? > > You can use a .DEF file, but I prefer either (1) using dllwrap, which > takes an --image-base parameter, and if not supplied, creates an image > base by hashing the output filename, or (2) supply -Wl,--image-base to > GCC or --image-base to the linker. See the documentation on the linker > (ld) for more info. > > Regards, > Mumit > -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com