* .reloc section in EXE
@ 1998-10-17 8:28 Jose Vasconcellos
1998-10-18 9:44 ` Guido Masarotto
1998-10-18 20:47 ` Mumit Khan
0 siblings, 2 replies; 5+ messages in thread
From: Jose Vasconcellos @ 1998-10-17 8:28 UTC (permalink / raw)
To: gnu-win32
Anyone know if it is possible to have the
linker generate a .reloc section in an EXE?
It does it with the -dll option, but I want
to create a relocatable EXE.
Thank you,
Jose Vasconcellos
-----
Free e-mail group hosting at http://www.eGroups.com/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: .reloc section in EXE
1998-10-17 8:28 .reloc section in EXE Jose Vasconcellos
@ 1998-10-18 9:44 ` Guido Masarotto
1998-10-18 20:47 ` Mumit Khan
1 sibling, 0 replies; 5+ messages in thread
From: Guido Masarotto @ 1998-10-18 9:44 UTC (permalink / raw)
To: Jose Vasconcellos, gnu-win32
On Sat, Oct 17, 1998 at 03:27:48PM -0000, Jose Vasconcellos wrote:
> Anyone know if it is possible to have the
> linker generate a .reloc section in an EXE?
> It does it with the -dll option, but I want
> to create a relocatable EXE.
>
Jose,
hoping that can help, I enclose a file (I call it MkRules) with the rules
that I use with Mumit's egcs. Observe that I use mingw32.
The rule for an executable automatically generate
a .reloc section (and also export all the public symbols).
As you can see the rules to build a relocable exe and a
relocable dll are very similar.
Use is very simple. For example, the Makefile
------------------------------------------------------------------
include MkRules
my.exe:a.o b.o
------------------------------------------------------------------
build a relocable executable my.exe from a.c and b.c.
Observe that it is possible to have special compiler flags
for every .c or .f file and special linker and library
flags for every executable (and, BTW, dll). In this case
you must use something like the following Makefile (look to
the comments):
------------------------------------------------------------------
include MkRules
CFLAGS=-O2 #used for every .c file
a-CFLAGS=-DaFlag #special flag for compiling a.c
LINKERFLAGS=-s #used in building every .exe
my-LINKFLAGS=-mwindows #used only for my.exe
LIBS=-laLib #used for every .exe
my-LIBS=-LaDir -lanotherLib #special library for my.exe
my.exe: a.o b.o
------------------------------------------------------------------
guido
(ps) Some rules can be simplified (e.g. the .rc -> .o one). But I used
this file also for cross-compiling (just change MINGW32DIR and
BINPREF to reflect your system) and in a cross-compiler setting
I found necessary to use the full rules (don't ask me why).
---------------------- MkRules -----------------------------------
.SUFFIXES: .c .f .o .a .def .exp .dll .exe
MINGW32DIR=/egcs
BINPREF=
HEADER=$(MINGW32DIR)/i386-mingw32/include
RM=rm -f
SED=sed
ECHO=echo
CP=cp
MKDIR=mkdir
CAT=cat
CC=$(BINPREF)gcc
F77=$(BINPREF)g77
FLIBS=-lg2c
AS=$(BINPREF)as
DLL=$(CC) -mdll
DLLTOOL=$(BINPREF)dlltool -k --as $(AS)
LINKER=$(CC)
AR=$(BINPREF)ar
RANLIB=$(BINPREF)ranlib
NM=$(BINPREF)nm
CPP=$(CC) -E
RESCOMP=$(BINPREF)windres --preprocessor $(CPP) --include-dir $(HEADER) --define RC_INVOKED=1
.c.o:
$(CC) $(CFLAGS) $($*-CFLAGS) -o $@ -c $<
.f.o:
$(F77) $(FFLAGS) $($*-FFLAGS) -o $@ -c $<
%.exe %.exp:
@$(ECHO) -------- Building $@ --------
$(ECHO) EXPORTS > $*.exp
$(NM) $^ | $(SED) -n "/^........ [DT] _/s/^........ [DT] _/ /p" >> $*.exp
$(DLLTOOL) --dllname $@ --output-exp $*.e --def $*.exp
$(LINKER) $(LINKFLAGS) $($*-LINKFLAGS) -o $@ -Wl,--base-file,$*.b $*.e $^ $($*-LIBS) $(LIBS)
$(DLLTOOL) --dllname $@ --base-file $*.b --output-exp $*.e --def $*.exp
$(LINKER) $(LINKFLAGS) $($*-LINKFLAGS) -o $@ $*.e $^ $($*-LIBS) $(LIBS)
rm $*.e $*.b
%.dll %.def:
@$(ECHO) ------- Building $@ --------
$(ECHO) LIBRARY $* > $*.def
$(ECHO) EXPORTS >> $*.def
$(NM) $^ | $(SED) -n "/^........ [DT] _/s/^........ [BCDRT] _/ /p" >> $*.def
$(DLL) -Wl,--base-file,$*.b $(DLLFLAGS) $($*-DLLFLAGS) -o $@ $^ $($*-DLLLIBS) $(DLLLIBS)
$(DLLTOOL) $(DLLTOOLFLAGS) $($*-DLLTOOLFLAGS) --dllname $@ --base-file $*.b --output-exp $*.e --def $*.def
$(DLL) -Wl,--base-file,$*.b $(DLLFLAGS) $($*-DLLFLAGS) -o $@ $*.e $^ $($*-DLLLIBS) $(DLLLIBS)
$(DLLTOOL) $(DLLTOOLFLAGS) $($*-DLLTOOLFLAGS) --dllname $@ --base-file $*.b --output-exp $*.e --def $*.def
$(DLL) $(DLLFLAGS) $($*-DLLFLAGS) -o $@ $*.e $^ $($*-DLLLIBS) $(DLLLIBS)
$(RM) $*.b $*.e
lib%.a: %.def
@$(ECHO) -------- Building $@ --------
$(DLLTOOL) $(DLLTOOLFLAGS) $($*-DLLTOOLFLAGS) --dllname $*.dll --def $*.def --output-lib lib$*.a
lib%.a: %.exp
@$(ECHO) -------- Building $@ --------
$(DLLTOOL) $(DLLTOOLFLAGS) $($*-DLLTOOLFLAGS) --dllname $*.exe --def $*.exp --output-lib lib$*.a
%.a:
@$(ECHO) -------- Building $@ --------
$(AR) cr $@ $^
$(RANLIB) $@
%.o: %.rc
$(RESCOMP) $(RESFLAGS) $($*-RESFLAGS) -i $^ -o $@
-----------------------------end MkRules---------------------------------
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: .reloc section in EXE
1998-10-17 8:28 .reloc section in EXE Jose Vasconcellos
1998-10-18 9:44 ` Guido Masarotto
@ 1998-10-18 20:47 ` Mumit Khan
1998-10-19 23:57 ` Glen Fullmer-EGF002
1 sibling, 1 reply; 5+ messages in thread
From: Mumit Khan @ 1998-10-18 20:47 UTC (permalink / raw)
To: Jose Vasconcellos; +Cc: gnu-win32
"Jose Vasconcellos" <josev@utstar.com> writes:
> Anyone know if it is possible to have the
> linker generate a .reloc section in an EXE?
> It does it with the -dll option, but I want
> to create a relocatable EXE.
>
For help on creating relocatable DLLs, see my dllhelpers package at
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/ . Colin Peters
has a nice intro on creating dlls as well on his web page (follow
the link from my "Related Sites" area).
Regards,
Mumit
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: .reloc section in EXE
1998-10-18 20:47 ` Mumit Khan
@ 1998-10-19 23:57 ` Glen Fullmer-EGF002
0 siblings, 0 replies; 5+ messages in thread
From: Glen Fullmer-EGF002 @ 1998-10-19 23:57 UTC (permalink / raw)
To: gnu-win32; +Cc: khan
Howdy,
>>>> "MK" == Mumit Khan <khan@xraylith.wisc.edu> writes:
MK> For help on creating relocatable DLLs, see my dllhelpers package at
MK> http://www.xraylith.wisc.edu/~khan/software/gnu-win32/ . Colin Peters
MK> has a nice intro on creating dlls as well on his web page (follow
MK> the link from my "Related Sites" area).
Q#1: Gcc, Java, and dlls. Using Mumit's recommendations and others I was
able to create a dll with all my JNI calls and nm confirms that they are
there. However when I try to open the DLL from Java I get:
Error: error: java.lang.UnsatisfiedLinkError: no libjtoc in shared
library path
I do have the directory in which libjtoc.dll resides in the PATH
environment variable.
On the Sun and HP one deletes the 'lib' prefix to the libjtoc. I
have tried it both ways on the PC - both failing similarly.
Java code snippet looks like:
String libname = "libjtoc";
try {
System.loadLibrary(libname);
} catch (UnsatisfiedLinkError Err) {
gutil.errorMsg("error: " + Err);
return;
}
Suggestions to fix this?
Q#2: When trying to link a couple of other static libraries into the dll for
which I don't have source I get a number of compile error messages
complaining about:
undefined reference to "_imp__<some function>"
Where <some function> includes:
free
fprintf
printf
malloc
strncpy
etc....
What could be causing this? The libraries include C and C++ code.
Q#3: I assume that Java JNI requires a relocatable DLL. Is that correct?
Any help on any of these questions would be appreciated.
Thanks,
--
Glen Fullmer,(847)538-3082, Mail: <gfullmer@ccrl.mot.com>,
*******************************************************************************
* "For a successful technology, reality must take precedence *
* over public relations, for Nature cannot be fooled." - Richard P. Feynman *
*******************************************************************************
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 5+ messages in thread
* .reloc section in EXE
@ 1998-10-17 8:15 Jose Vasconcellos
0 siblings, 0 replies; 5+ messages in thread
From: Jose Vasconcellos @ 1998-10-17 8:15 UTC (permalink / raw)
To: gnu-win32
Anyone know if it is possible to have the
linker generate a .reloc section in an EXE?
It does it with the -dll option, but I want
to create a relocatable EXE.
Thank you,
Jose Vasconcellos
-----
Free e-mail group hosting at http://www.eGroups.com/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1998-10-19 23:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-17 8:28 .reloc section in EXE Jose Vasconcellos
1998-10-18 9:44 ` Guido Masarotto
1998-10-18 20:47 ` Mumit Khan
1998-10-19 23:57 ` Glen Fullmer-EGF002
-- strict thread matches above, loose matches on Subject: below --
1998-10-17 8:15 Jose Vasconcellos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).