This is the mail archive of the cygwin@sourceware.cygnus.com 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]

Re: Specifying a base address


"Jon Leichter" <jon@symas.com> 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=<BASE_ADDR> to the linker. If you're using GCC to
create the DLL, use -Wl,--image-base=<BASE_ADDR>
  
  $ 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@sourceware.cygnus.com


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