rse 98/04/10 03:34:37
Modified: . STATUS Makefile.tmpl configure
src CHANGES Configuration.tmpl Configure Makefile.tmpl
src/main http_main.c
src/support httpd.8
Log:
DSO support for SVR4-based Unix platforms
=========================================
What it provides:
-----------------
This patch is another milestone in the DSO support for Apache 1.3. It adds
Dynamic Shared Object (DSO) support for mostly all SVR4-based Unix platforms
(We cannot test all of them of course, but Martin has at least tested it under
SINIX-SVR4). Why is this patch a little bit larger then one would expect?
Mostly because this support goes hand in hand by providing a special variant
of the Apache core program. Read on if you are interested.
Background:
-----------
Usually the DSO mechanism was designed to be used for loading library code
dynamically into the address space of a running program. Here the library code
is a stand-alone program which has no knowledge of the program it is loaded
into. Technically speaking this means that no symbols of the loading program
are references in the DSO. The resolving is done only the other way: Symbols
of the library are resolved for the program (either automatically by ld.so
when one uses DSO-based libraries or manually via dlopen()/dlsym() when using
DSO-based program extensions.
Now when you use the latter situation the DSO usually contains a program
extension. This extension usually uses symbols from the program it extends:
from the API. Same here for Apache: The core provides API symbols and the
extensions are Apache modules which use those symbols. Now comes the problem:
when you load a DSO via dlopen() the loader has to resolve the symbols in this
DSO. Symbols from other DSO-based libraries can be resolved the same way ld.so
does. No problem. But to be able to resolve the API symbols the loader must be
able to access them. Technically speaking one would say the API symbols have
to be "exported". This is not the same as just being a "global" symbol,
although a lot of platforms treat this equally. Actually it is this way: When
the linker creates an executable program it does not treats global symbols as
exported symbols. But because this is needed for extending the program via
DSO, modern linkers usually either provide a flag (-rdynamic under Linux,
etc.) or are smart enough to do the exportation automatically (Solaris,
FreeBSD, etc.)
But as life goes, there are linkers out there who neither provide a flag to
force exportation nor are smart enough to do it automatically. FOR INSTANCE
THE LINKER UNDER SVR4! That's the problem this patch has to solve.
Solution:
---------
We have to make sure the global symbols from the Apache core program are
forced to be exported by the linker. The obvious way is this: Create a
dummy.so with dummy references for _ALL_ global symbols and link httpd against
this DSO. This works but has some drawbacks: You have to make sure the dummy.c
source is always in sync with the list of global symbols (ARGL!) and you have
to make sure the Unix loader can find "dummy.so" when starting httpd (Hmmmm).
So Martin and I've searched for a better solution. And because I'm a Perl
hacker I immediately tried to figure out why Perl is able to use the DSO
mechanism without problems under SVR4 while Apache has such problems. The
answer: Perl 5 uses a nifty trick. As we already know when program code stays
in a DSO the global symbols have to be exportable. So, when we put the
complete Apache core (the stuff httpd is usually build from) into a DSO we are
finished. Because this is both portable and causes no sideeffects like having
to sync a dummy.c source, etc.
While the theory is simple, the correct solution was not such simple. Martin
and I needed some iterations to provide this patch because we wanted to make
it perfect and clean. That's why it's a little bit longer....
The Patch:
----------
The patch does the following:
1. It introduces a new Rule: SHARED_CORE
2. It makes the main() function from http_main.c configurable
and sets it to ap_main if SHARED_CORE is active.
3. It adds two additional stand-alone main() functions to
http_main.c which are triggered by SHARED_CORE_BOOTSTRAP and
SHARED_CORE_TIESTATIC.
4. It splits the TARGET in Makefile.tmpl into subtargets.
One for the standard way of creating just httpd from the .a files. And one
for creating the alternative tuple: httpd/libhttpd.ep/libhttpd.so. The
first one is SHARED_CORE_BOOTSTRAP+http_main.c, the second one is
SHARED_CORE_TIESTATIC+httpd_main.c and the third one are the .a files
which usually form the httpd.
5. The DSO section in Configure was extended to force
SHARED_CORE under those platforms like SVR4 which essentially
require SHARED_CORE to provide the SHARED_MODULE stuff. Bingo!
6. Some minor tweaks to APACI etc. to automatically install
the SHARED_CORE generated stuff.
Of course the complete stuff is disabled per default, so you don't see
anything from it if SHARED_CORE is not activated. But just for fun you even
can use it under platforms who do not require it. But currently you gain
nothing here.
I've tested this stuff under FreeBSD, Linux and Solaris to make sure none of
the existing stuff gets broken. Martin has tested it under various SVR4
platforms to make sure it really solves our DSO problem for restrictive
platforms like SVR4. The chance is high that this way we even can provide DSO
support under AIX in the future.
Revision Changes Path
1.287 +1 -0 apache-1.3/STATUS
Index: STATUS
===================================================================
RCS file: /export/home/cvs/apache-1.3/STATUS,v
retrieving revision 1.286
retrieving revision 1.287
diff -u -r1.286 -r1.287
--- STATUS 1998/04/09 14:33:07 1.286
+++ STATUS 1998/04/10 10:34:30 1.287
@@ -152,6 +152,7 @@
* Fixed ordering of argument checks for RewriteBase directive, PR#2045
* Ralf's cleanup of subdir movement to again allow correct breaks on
error
* Ralf's consistent add of "distclean" targets for the src/-Makefiles
+ * Ralf's and Martin's DSO support for all SVR4-derivate Unix platforms
Available Patches:
1.13 +16 -0 apache-1.3/Makefile.tmpl
Index: Makefile.tmpl
===================================================================
RCS file: /export/home/cvs/apache-1.3/Makefile.tmpl,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Makefile.tmpl 1998/04/09 10:22:48 1.12
+++ Makefile.tmpl 1998/04/10 10:34:31 1.13
@@ -221,6 +221,22 @@
install-programs:
@echo "===> [programs: Installing Apache httpd program and shared
objects]"
$(INSTALL_PROGRAM) $(SRC)/httpd $(sbindir)/httpd
+ @if [ ".`grep 'SUBTARGET=target_shared' $(SRC)/Makefile`" != . ]; then \
+ echo "$(INSTALL_PROGRAM) $(SRC)/libhttpd.ep
$(libexecdir)/libhttpd.ep"; \
+ $(INSTALL_SCRIPT) $(SRC)/libhttpd.ep $(libexecdir)/libhttpd.ep;
\
+ echo "$(INSTALL_SCRIPT) $(SRC)/libhttpd.so
$(libexecdir)/libhttpd.so"; \
+ $(INSTALL_SCRIPT) $(SRC)/libhttpd.so $(libexecdir)/libhttpd.so;
\
+ SHLIB_SUFFIX_LIST="`grep '^SHLIB_SUFFIX_LIST=' $(SRC)/Makefile
| sed -e 's:^.*=::'`"; \
+ if [ ".$$SHLIB_SUFFIX_LIST" != . ]; then \
+ echo "rm -f $(libexecdir)/libhttpd.so.*"; \
+ rm -f $(libexecdir)/libhttpd.so.*; \
+ for suffix in $$SHLIB_SUFFIX_LIST ""; do \
+ [ ".$$suffix" = . ] && continue; \
+ echo "ln $(libexecdir)/libhttpd.so
$(libexecdir)/libhttpd.so.$$suffix"; \
+ ln $(libexecdir)/libhttpd.so
$(libexecdir)/libhttpd.so.$$suffix; \
+ done; \
+ fi; \
+ fi
$(INSTALL_DATA) $(SRC)/support/httpd.8 $(mandir)/man8/httpd.8
[EMAIL PROTECTED] -f .install.conf; touch .install.conf
[EMAIL PROTECTED] [ ".`grep '^[ ]*SharedModule'
$(SRC)/Configuration.apaci`" != . ]; then \
1.6 +2 -0 apache-1.3/configure
Index: configure
===================================================================
RCS file: /export/home/cvs/apache-1.3/configure,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- configure 1998/04/01 11:28:36 1.5
+++ configure 1998/04/10 10:34:31 1.6
@@ -653,6 +653,7 @@
echo "Compilation paths:"
echo " HTTPD_ROOT: $prefix"
echo " SUEXEC_BIN: $sbindir/suexec"
+ echo " SHARED_CORE_DIR: $libexecdir"
echo " DEFAULT_PIDLOG:
${localstatedir_relative}${localstatesubdir_run}/httpd.pid"
echo " DEFAULT_SCOREBOARD:
${localstatedir_relative}${localstatesubdir_run}/httpd.scoreboard"
echo " DEFAULT_LOCKFILE:
${localstatedir_relative}${localstatesubdir_run}/httpd.lock"
@@ -709,6 +710,7 @@
echo "## WITHOUT DISTURBING THE KNOWN MAKE BUILD PROCESS DISPLAY"
>>$src/apaci
echo "echo '-DHTTPD_ROOT=\"$prefix\"'" >>$src/apaci
echo "echo '-DSUEXEC_BIN=\"$sbindir/suexec\"'" >>$src/apaci
+echo "echo '-DSHARED_CORE_DIR=\"$libexecdir\"'" >>$src/apaci
echo "echo
'-DDEFAULT_PIDLOG=\"${localstatedir_relative}${localstatesubdir_run}/httpd.pid\"'"
>>$src/apaci
echo "echo
'-DDEFAULT_SCOREBOARD=\"${localstatedir_relative}${localstatesubdir_run}/httpd.scoreboard\"'"
>>$src/apaci
echo "echo
'-DDEFAULT_LOCKFILE=\"${localstatedir_relative}${localstatesubdir_run}/httpd.lock\"'"
>>$src/apaci
1.764 +19 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.763
retrieving revision 1.764
diff -u -r1.763 -r1.764
--- CHANGES 1998/04/09 19:30:58 1.763
+++ CHANGES 1998/04/10 10:34:32 1.764
@@ -1,5 +1,24 @@
Changes with Apache 1.3b6
+ *) Added dynamic shared object (DSO) support for SVR4-derivates: The
+ problem under SVR4 is that there is no command flag to force the linker
+ to export the global symbols of the httpd executable therewith they are
+ available to the DSO's. Instead of problematic hacks like creating a
+ dummy.so file (containing dummy references to all global symbols) the
+ httpd binary is linked against, we use a clean trick stolen from Perl 5:
+ Placing the Apache core code itself into a DSO library named
libhttpd.so.
+ This way the global symbols _HAVE_ to be exported and thus are available
+ to any manually loaded DSO's under runtime. To reduce the impact to the
+ user to null we go even further and create a stub httpd executable which
+ automatically keeps track of the DSO library loading itself and thus
+ hides the complete mechanism from the user. Although the generation of
+ this DSO library is automatically triggered for platforms which
+ essentially need it (mostly all SVR4-derivates) it can be also enabled
+ manually via the Rule SHARED_CORE. This can be interesting in the future
+ where we perhaps exploit this libhttpd.so mechanism for providing nifty
+ features like graceful upgrades, or whatever.
+ [Ralf S. Engelschall, Martin Kraemer]
+
*) Build the libraries before building the rest of the tools. [Ben Hyde]
*) Add "distclean" target to src/-Makefiles to provide "make distclean"
also
1.98 +25 -17 apache-1.3/src/Configuration.tmpl
Index: Configuration.tmpl
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/Configuration.tmpl,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- Configuration.tmpl 1998/04/10 03:34:22 1.97
+++ Configuration.tmpl 1998/04/10 10:34:32 1.98
@@ -51,36 +51,44 @@
#RANLIB=
################################################################
-# Makefile configuration (Shared Object support)
+# Dynamic Shared Object (DSO) support
#
-# There is experimental support for compiling Apache Modules as
-# shared objects and loading them under runtime without
-# recompilation when the module mod_so is enabled (see below).
-# The shared object feature then can be enabled for each module
-# individually by replacing the `AddModule' command of the
-# corresponding module line below with `SharedModule' and
-# changing the filename extension from `.o' to `.so'.
+# There is experimental support for compiling the Apache core and
+# the Apache modules into dynamic shared object (DSO) files for
+# maximum runtime flexibility.
#
# The Configure script currently has only limited built-in
-# knowledge on how to compile shared objects because this is
+# knowledge on how to compile these DSO files because this is
# heavily platform-dependent. The current state is this:
#
# Out-of-the-box supported platforms:
-# Linux, FreeBSD, Solaris, SunOS, IRIX, OSF1, UnixWare
+# Linux, FreeBSD, Solaris, SunOS,
+# IRIX, OSF1, UnixWare, SINIX, SVR4
#
-# Entirely unsupported platforms (no dlopen-style API):
-# HP-UX, AIX, Ultrix
+# Explicitly unsupported platforms:
+# HP/UX, AIX, Ultrix
#
-# For other platforms where you want to use the `SharedModule'
-# directive you first have to make sure it supports the dlopen()
+# For other platforms where you want to use the DSO mechanism you
+# first have to make sure it supports the pragmatic dlopen()
# system call and then you have to provide the appropriate
-# compiler and linker flags here to create the shared object
-# files on your particular platform.
+# compiler and linker flags below to create the DSO files on your
+# particular platform.
#
-#
+# The placement of the Apache core into a DSO file is triggered
+# by the SHARED_CORE rule below while support for building
+# individual Apache Modules as DSO files and loading them under
+# runtime without recompilation is triggered by `SharedModule'
+# commands. To be able to use the latter one first enable the
+# module mod_so (see corresponding `AddModule' command below).
+# Then enable the DSO feature for particular modules individually
+# by replacing their `AddModule' command with `SharedModule' and
+# change the filename extension from `.o' to `.so'.
+
#CFLAGS_SHLIB=
#LDFLAGS_SHLIB=
#LDFLAGS_SHLIB_EXPORT=
+
+Rule SHARED_CORE=default
################################################################
# Rules configuration
1.233 +83 -0 apache-1.3/src/Configure
Index: Configure
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/Configure,v
retrieving revision 1.232
retrieving revision 1.233
diff -u -r1.232 -r1.233
--- Configure 1998/04/09 19:30:58 1.232
+++ Configure 1998/04/10 10:34:33 1.233
@@ -232,8 +232,16 @@
RULE_IRIXNIS=`./helpers/CutRule IRIXNIS $file`
RULE_IRIXN32=`./helpers/CutRule IRIXN32 $file`
RULE_PARANOID=`./helpers/CutRule PARANOID $file`
+RULE_SHARED_CORE=`./helpers/CutRule SHARED_CORE $file`
####################################################################
+## Rule SHARED_CORE implies required DSO support
+##
+if [ "$RULE_SHARED_CORE" = "yes" ]; then
+ using_shlib=1
+fi
+
+####################################################################
## Preset some "constants";
## can be overridden on a per-platform basis below.
##
@@ -241,6 +249,8 @@
DB_LIB="-ldb"
SHELL="/bin/sh"
TARGET="httpd"
+SUBTARGET="target_static"
+SHLIB_SUFFIX_LIST=""
PRINTPATH=PrintPath
CAT="cat"
if ./helpers/$PRINTPATH -s ranlib; then
@@ -730,6 +740,8 @@
## required. For more platforms just add the required lines below.
##
if [ "x$using_shlib" = "x1" ] ; then
+ DEF_SHARED_CORE=no
+ SHLIB_SUFFIX_DEPTH=all
case "$PLAT" in
*-linux1)
CFLAGS_SHLIB="-fpic"
@@ -740,11 +752,13 @@
CFLAGS_SHLIB="-fpic"
LDFLAGS_SHLIB="-Bshareable"
LDFLAGS_SHLIB_EXPORT="-rdynamic"
+ SHLIB_SUFFIX_DEPTH=0
;;
*-freebsd*)
CFLAGS_SHLIB="-fpic"
LDFLAGS_SHLIB="-Bshareable"
LDFLAGS_SHLIB_EXPORT=""
+ SHLIB_SUFFIX_DEPTH=2
;;
*-solaris2*)
case $CC in
@@ -753,6 +767,7 @@
esac
LDFLAGS_SHLIB="-G"
LDFLAGS_SHLIB_EXPORT=""
+ SHLIB_SUFFIX_DEPTH=1
;;
*-sunos4*)
case $CC in
@@ -803,7 +818,37 @@
esac
LDFLAGS_SHLIB="-Bdynamic -G"
LDFLAGS_SHLIB_EXPORT=""
+ DEF_SHARED_CORE=yes
+ ;;
+ RM*-sni-sysv4*)
+ # MIPS hosts can take advantage of the LDFLAGS_SHLIB_EXPORT
switch
+ case $CC in
+ */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
+ */cc|cc ) CFLAGS_SHLIB="-KPIC" ;;
+ esac
+ LDFLAGS_SHLIB="-G"
+ LDFLAGS_SHLIB_EXPORT="-Wl,-Blargedynsym"
;;
+ *-sni-sysv4*)
+ # Older SINIX machines must be linked as "shared core"-Apache
+ case $CC in
+ */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
+ */cc|cc ) CFLAGS_SHLIB="-KPIC" ;;
+ esac
+ LDFLAGS_SHLIB="-G"
+ LDFLAGS_SHLIB_EXPORT=""
+ SHLIB_SUFFIX_DEPTH=0
+ DEF_SHARED_CORE=yes
+ ;;
+ *-sysv4*)
+ case $CC in
+ */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
+ */cc|cc ) CFLAGS_SHLIB="-KPIC" ;;
+ esac
+ LDFLAGS_SHLIB="-G"
+ LDFLAGS_SHLIB_EXPORT=""
+ DEF_SHARED_CORE=yes
+ ;;
*)
## ok, no known explict support for shared objects
## on this platform, but we give not up immediately.
@@ -1147,6 +1192,42 @@
fi
####################################################################
+## Now the SHARED_CORE stuff
+##
+if [ "x$using_shlib" = "x1" ] ; then
+ if [ ".$RULE_SHARED_CORE" = .default ] ; then
+ RULE_SHARED_CORE=$DEF_SHARED_CORE
+ fi
+ if [ ".$RULE_SHARED_CORE" = .yes ]; then
+ echo " + enabling generation of Apache core as DSO"
+ # shuffle compiler flags from shlib variant to standard
+ CFLAGS="$CFLAGS $CFLAGS_SHLIB"
+ CFLAGS_SHLIB=""
+ # indicate that Rule SHARED_CORE is active
+ CFLAGS="$CFLAGS -DSHARED_CORE"
+ # select the special subtarget for shared core generation
+ SUBTARGET=target_shared
+ # determine additional suffixes for libhttpd.so
+ V=1 R=3 P=0
+ if [ ".$SHLIB_SUFFIX_DEPTH" = .0 ]; then
+ SHLIB_SUFFIX_LIST=""
+ fi
+ if [ ".$SHLIB_SUFFIX_DEPTH" = .1 ]; then
+ SHLIB_SUFFIX_LIST="$V"
+ fi
+ if [ ".$SHLIB_SUFFIX_DEPTH" = .2 ]; then
+ SHLIB_SUFFIX_LIST="$V.$R"
+ fi
+ if [ ".$SHLIB_SUFFIX_DEPTH" = .3 ]; then
+ SHLIB_SUFFIX_LIST="$V.$R.$P"
+ fi
+ if [ ".$SHLIB_SUFFIX_DEPTH" = .all ]; then
+ SHLIB_SUFFIX_LIST="$V $V.$R $V.$R.$P"
+ fi
+ fi
+fi
+
+####################################################################
## Now create modules.c
##
sed 's/_module//' $tmpfile | awk >modules.c '
@@ -1270,6 +1351,8 @@
## Now add the target for the main Makefile
##
echo "TARGET=$TARGET" >> Makefile
+echo "SUBTARGET=$SUBTARGET" >> Makefile
+echo "SHLIB_SUFFIX_LIST=$SHLIB_SUFFIX_LIST" >> Makefile
echo "" >> Makefile
####################################################################
1.91 +27 -3 apache-1.3/src/Makefile.tmpl
Index: Makefile.tmpl
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/Makefile.tmpl,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- Makefile.tmpl 1998/04/09 10:22:50 1.90
+++ Makefile.tmpl 1998/04/10 10:34:33 1.91
@@ -23,9 +23,33 @@
@echo "If not, you will at least have to touch @@Configuration@@."
@false
-$(TARGET): subdirs modules.o
+$(TARGET): $(SUBTARGET)
+
+target_static: subdirs modules.o
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(SPACER) buildmark.c
+ $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SHLIB_EXPORT) \
+ -o $(TARGET) buildmark.o $(OBJS) $(REGLIB) $(LIBS)
+
+target_shared: libhttpd.ep
+ $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SHLIB_EXPORT) \
+ -o $(TARGET) -DSHARED_CORE_BOOTSTRAP main/http_main.c
+
+libhttpd.ep: libhttpd.so
+ $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SHLIB_EXPORT) \
+ -o libhttpd.ep -DSHARED_CORE_TIESTATIC main/http_main.c \
+ -L. -lhttpd $(LIBS)
+
+libhttpd.so: subdirs modules.o
$(CC) -c $(INCLUDES) $(CFLAGS) $(SPACER) buildmark.c
- $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SHLIB_EXPORT) -o $(TARGET)
buildmark.o $(OBJS) $(REGLIB) $(LIBS)
+ $(LD) $(LDFLAGS_SHLIB) -o libhttpd.so buildmark.o $(OBJS) $(REGLIB)
+ @if [ ".$(SHLIB_SUFFIX_LIST)" != . ]; then \
+ rm -f libhttpd.so.*; \
+ for suffix in $(SHLIB_SUFFIX_LIST) ""; do \
+ [ ".$$suffix" = . ] && continue; \
+ echo "ln libhttpd.so libhttpd.so.$$suffix"; \
+ ln libhttpd.so libhttpd.so.$$suffix; \
+ done; \
+ fi
subdirs:
@for i in $(SUBDIRS); do \
@@ -42,7 +66,7 @@
echo "<=== $(SDP)support"
clean:
- rm -f $(TARGET) *.o
+ rm -f $(TARGET) libhttpd.* *.o
@for i in $(SUBDIRS); do \
echo "===> $(SDP)$$i"; \
( cd $$i && $(MAKE) $(MFLAGS_STATIC) SDP='$(SDP)' $@ ) || exit
1; \
1.323 +164 -5 apache-1.3/src/main/http_main.c
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.322
retrieving revision 1.323
diff -u -r1.322 -r1.323
--- http_main.c 1998/04/06 07:43:32 1.322
+++ http_main.c 1998/04/10 10:34:35 1.323
@@ -78,6 +78,15 @@
* Extensive rework for Apache.
*/
+#ifndef SHARED_CORE_BOOTSTRAP
+#ifndef SHARED_CORE_TIESTATIC
+
+#ifdef SHARED_CORE
+#define REALMAIN ap_main
+#else
+#define REALMAIN main
+#endif
+
#define CORE_PRIVATE
#include "httpd.h"
@@ -788,10 +797,17 @@
for (i = 0; i < strlen(bin); i++)
pad[i] = ' ';
pad[i] = '\0';
+#ifdef SHARED_CORE
+ fprintf(stderr, "Usage: %s [-L directory] [-d directory] [-f file]\n",
bin);
+#else
fprintf(stderr, "Usage: %s [-d directory] [-f file]\n", bin);
+#endif
fprintf(stderr, " %s [-C \"directive\"] [-c \"directive\"]\n",
pad);
fprintf(stderr, " %s [-v] [-V] [-h] [-l]\n", pad);
fprintf(stderr, "Options:\n");
+#ifdef SHARED_CORE
+ fprintf(stderr, " -L directory : specify an alternate location for
shared object files\n");
+#endif
fprintf(stderr, " -d directory : specify an alternate initial
ServerRoot\n");
fprintf(stderr, " -f file : specify an alternate
ServerConfigFile\n");
fprintf(stderr, " -C \"directive\" : process directive before reading
config files\n");
@@ -3023,6 +3039,9 @@
#ifdef NEED_HASHBANG_EMUL
printf(" -D NEED_HASHBANG_EMUL\n");
#endif
+#ifdef SHARED_CORE
+ printf(" -D SHARED_CORE\n");
+#endif
}
@@ -3935,7 +3954,7 @@
extern char *optarg;
extern int optind;
-int main(int argc, char *argv[])
+int REALMAIN(int argc, char *argv[])
{
int c;
@@ -3950,9 +3969,9 @@
setup_prelinked_modules();
#ifdef DEBUG_SIGSTOP
- while ((c = getopt(argc, argv, "C:c:Xd:f:vVhlZ:")) != -1) {
+ while ((c = getopt(argc, argv, "C:c:Xd:f:vVhlL:Z:")) != -1) {
#else
- while ((c = getopt(argc, argv, "C:c:Xd:f:vVhl")) != -1) {
+ while ((c = getopt(argc, argv, "C:c:Xd:f:vVhlL:")) != -1) {
#endif
char **new;
switch (c) {
@@ -3991,6 +4010,15 @@
raise_sigstop_flags = atoi(optarg);
break;
#endif
+#ifdef SHARED_CORE
+ case 'L':
+ /* just ignore this option here, because it has only
+ * effect when SHARED_CORE is used and then it was
+ * already handled in the Shared Core Bootstrap
+ * program.
+ */
+ break;
+#endif
case '?':
usage(argv[0]);
}
@@ -5005,7 +5033,7 @@
__declspec(dllexport)
int apache_main(int argc, char *argv[])
#else
-int main(int argc, char *argv[])
+int REALMAIN(int argc, char *argv[])
#endif
{
int c;
@@ -5138,5 +5166,136 @@
return (0);
}
-
#endif /* ndef MULTITHREAD */
+
+#else /* ndef SHARED_CORE_TIESTATIC */
+
+/*
+** Standalone Tie Program for Shared Core support
+**
+** It's purpose is to tie the static libraries and
+** the shared core library under link-time and
+** passing execution control to the real main function
+** in the shared core library under run-time.
+*/
+
+int main(int argc, char *argv[])
+{
+ extern int ap_main(int argc, char *argv[]);
+ return ap_main(argc, argv);
+}
+
+#endif /* ndef SHARED_CORE_TIESTATIC */
+#else /* ndef SHARED_CORE_BOOTSTRAP */
+
+/*
+** Standalone Bootstrap Program for Shared Core support
+**
+** It's purpose is to initialise the LD_LIBRARY_PATH
+** environment variable therewith the Unix loader is able
+** to start the Standalone Tie Program (see above)
+** and then replacing itself with this program by
+** immediately passing execution to it.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "conf.h"
+#include "httpd.h"
+
+#define VARNAME "LD_LIBRARY_PATH"
+
+#ifndef SHARED_CORE_DIR
+#define SHARED_CORE_DIR HTTPD_ROOT "/libexec"
+#endif
+
+#ifndef SHARED_CORE_EXECUTABLE_PROGRAM
+#define SHARED_CORE_EXECUTABLE_PROGRAM "libhttpd.ep"
+#endif
+
+int main(int argc, char *argv[], char *envp[])
+{
+ extern char *optarg;
+ extern int optind;
+ char prog[MAX_STRING_LEN];
+ char llp_buf[MAX_STRING_LEN];
+ char **llp_slot;
+ char *llp_existing;
+ char *llp_dir;
+ char **envpnew;
+ int c, i, l;
+
+ /*
+ * parse argument line,
+ * but only handle the -L option
+ */
+ llp_dir = SHARED_CORE_DIR;
+ while ((c = getopt(argc, argv, "C:c:Xd:f:vVhlL:Z:")) != -1) {
+ switch (c) {
+ case 'C':
+ case 'c':
+ case 'X':
+ case 'd':
+ case 'f':
+ case 'v':
+ case 'V':
+ case 'h':
+ case 'l':
+ case 'Z':
+ case '?':
+ break;
+ case 'L':
+ llp_dir = strdup(optarg);
+ break;
+ }
+ }
+
+ /*
+ * create path to SHARED_CORE_EXECUTABLE_PROGRAM
+ */
+ sprintf(prog, "%s/%s", llp_dir, SHARED_CORE_EXECUTABLE_PROGRAM);
+
+ /*
+ * adjust process environment therewith the Unix loader
+ * is able to start the SHARED_CORE_EXECUTABLE_PROGRAM.
+ */
+ llp_slot = NULL;
+ llp_existing = NULL;
+ l = strlen(VARNAME);
+ for (i = 0; envp[i] != NULL; i++) {
+ if (strncmp(envp[i], VARNAME "=", l+1) == 0) {
+ llp_slot = &envp[i];
+ llp_existing = strchr(envp[i], '=') + 1;
+ }
+ }
+ if (llp_slot == NULL) {
+ envpnew = (char **)malloc(sizeof(char *)*(i + 2));
+ memcpy(envpnew, envp, sizeof(char *)*i);
+ envp = envpnew;
+ llp_slot = &envp[i++];
+ envp[i] = NULL;
+ }
+ if (llp_existing != NULL)
+ sprintf(llp_buf, "%s=%s:%s", VARNAME, llp_dir, llp_existing);
+ else
+ sprintf(llp_buf, "%s=%s", VARNAME, llp_dir);
+ *llp_slot = strdup(llp_buf);
+
+ /*
+ * finally replace our process with
+ * the SHARED_CORE_EXECUTABLE_PROGRAM
+ */
+ if (execve(prog, argv, envp) == -1) {
+ fprintf(stderr,
+ "httpd: Unable to exec Shared Core Executable Program `%s'\n",
+ prog);
+ return 1;
+ }
+ else
+ return 0;
+}
+
+#endif /* ndef SHARED_CORE_BOOTSTRAP */
+
1.7 +11 -0 apache-1.3/src/support/httpd.8
Index: httpd.8
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/support/httpd.8,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- httpd.8 1998/03/31 12:53:49 1.6
+++ httpd.8 1998/04/10 10:34:36 1.7
@@ -60,6 +60,8 @@
[
.B \-X
] [
+.BI \-L " libexecdir"
+] [
.BI \-d " serverroot"
] [
.BI \-f " config"
@@ -107,6 +109,15 @@
compiled into
.B httpd.
.SH OPTIONS
+.TP 12
+.BI \-L " libexecdir"
+This option is only available if Apache was built with
+the
+.I SHARED_CORE
+rule enabled which forces the Apache core code to be
+placed into a dynamic shared object (DSO) file. This file
+is searched in a hardcoded path under ServerRoot per default. Use this
+option if you want to override it.
.TP 12
.BI \-d " serverroot"
Set the initial value for the ServerRoot directive to \fIserverroot\fP. This