aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2013-02-24 21:55:37 -0800
committerPaul Eggert2013-02-24 21:55:37 -0800
commit1ddc2bd6ff0b5071454d2591f835927ea5b85a06 (patch)
treedff377164bcc7d9e8a84e0279cee6f9c28e3fcc5
parent82fcf982c39d5ff821bb7d3353ca973e277e1810 (diff)
downloademacs-1ddc2bd6ff0b5071454d2591f835927ea5b85a06.tar.gz
emacs-1ddc2bd6ff0b5071454d2591f835927ea5b85a06.zip
Simplify data_start configuration.
This is a followon simplification to the fix for Bug#13650. * admin/CPP-DEFINES (DATA_START, ORDINARY_LINK): Remove. * configure.ac (CRT_DIR, LIB_STANDARD, START_FILES, DATA_START) (LD_FIRSTFLAG, ORDINARY_LINK, LIB_GCC): Remove. (AC_CHECK_HEADERS_ONCE): Remove sys/resource.h, as it's not always needed. (HAVE_DATA_START): New macro. * etc/PROBLEMS (LIBS_SYSTEM, LIBS_MACHINE, LIBS_STANDARD): Remove. Remove legacy-systems section, as this stuff is no longer applicable with current linking strategies. * src/Makefile.in (LD_FIRSTFLAG, LIB_GCC, CRT_DIR, LIB_STANDARD) (START_FILES): Remove. All uses removed. (otherobj): Remove $(VMLIMIT_OBJ), as it's now first. (ALLOBJS): Move here from autodeps.mk, and with VMLIMITS_OBJ first. (buildobj.h): Use it. ($(ALLOBJS)): Depend on globals.h. (temacs$(EXEEXT)): Use $(ALLOBJS). * src/autodeps.mk (ALLOBJS): Move to Makefile.in. * src/deps.mk (vm-limit.o): * src/makefile.w32-in ($(BLD)/vm-limit.$(O)): Do not depend on mem-limits.h. * src/emacs.c (__do_global_ctors, __do_global_ctors_aux) (__do_global_dtors, __CTOR_LIST__, __DTOR_LIST__) [__GNUC__ && !ORDINARY_LINK]: Remove. * src/mem-limits.h, src/pre-crt0.c: Remove. * src/unexaix.c, src/unexcoff.c: Don't include mem-limits.h. * src/unexcoff.c (etext): New decl. (make_hdr): Use it instead of start_of_data. * src/vm-limit.c: Move most of mem-limits.h's contents here. (data_start): New decl. It's OK if this is approximate, so simplify-away some unnecessary exactness. (POINTER): Remove; all uses removed. (data_space_start): Now char *, to avoid casts. (exceeds_lisp_ptr): New function, replacing the old EXCEEDS_LISP_PTR macro. All uses changed. (check_memory_limits): Simplify and remove casts. (start_of_data) [!CANNOT_DUMP || !SYSTEM_MALLOC]: Remove. (memory_warnings): Use data_start instead of start_of_data. Fixes: debbugs:13783
-rw-r--r--ChangeLog9
-rw-r--r--admin/CPP-DEFINES2
-rw-r--r--admin/ChangeLog5
-rw-r--r--configure.ac219
-rw-r--r--etc/ChangeLog7
-rw-r--r--etc/PROBLEMS35
-rw-r--r--src/ChangeLog33
-rw-r--r--src/Makefile.in34
-rw-r--r--src/autodeps.mk1
-rw-r--r--src/deps.mk2
-rw-r--r--src/emacs.c26
-rw-r--r--src/makefile.w32-in1
-rw-r--r--src/mem-limits.h43
-rw-r--r--src/pre-crt0.c10
-rw-r--r--src/unexaix.c2
-rw-r--r--src/unexcoff.c4
-rw-r--r--src/vm-limit.c103
17 files changed, 133 insertions, 403 deletions
diff --git a/ChangeLog b/ChangeLog
index 711971a61ad..5b289f27ef1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
12013-02-25 Paul Eggert <eggert@cs.ucla.edu>
2
3 Simplify data_start configuration (Bug#13783).
4 * configure.ac (CRT_DIR, LIB_STANDARD, START_FILES, DATA_START)
5 (LD_FIRSTFLAG, ORDINARY_LINK, LIB_GCC): Remove.
6 (AC_CHECK_HEADERS_ONCE): Remove sys/resource.h, as it's
7 not always needed.
8 (HAVE_DATA_START): New macro.
9
12013-02-18 Aidan Gauland <aidalgol@no8wireless.co.nz> 102013-02-18 Aidan Gauland <aidalgol@no8wireless.co.nz>
2 11
3 * lisp/eshell/em-cmpl.el: Corrected "context-related help" 12 * lisp/eshell/em-cmpl.el: Corrected "context-related help"
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES
index 393cf56e993..da8dec5a0f6 100644
--- a/admin/CPP-DEFINES
+++ b/admin/CPP-DEFINES
@@ -90,7 +90,6 @@ BROKEN_NON_BLOCKING_CONNECT
90BROKEN_PTY_READ_AFTER_EAGAIN 90BROKEN_PTY_READ_AFTER_EAGAIN
91CLASH_DETECTION 91CLASH_DETECTION
92DATA_SEG_BITS 92DATA_SEG_BITS
93DATA_START
94DEFAULT_SOUND_DEVICE 93DEFAULT_SOUND_DEVICE
95DEVICE_SEP 94DEVICE_SEP
96DIRECTORY_SEP 95DIRECTORY_SEP
@@ -408,7 +407,6 @@ NO_EDITRES
408NSIG 407NSIG
409NSIG_MINIMUM 408NSIG_MINIMUM
410NULL_DEVICE 409NULL_DEVICE
411ORDINARY_LINK
412PAGESIZE 410PAGESIZE
413PREFER_VSUSP 411PREFER_VSUSP
414PTY_ITERATION 412PTY_ITERATION
diff --git a/admin/ChangeLog b/admin/ChangeLog
index 7e72e10cd9f..28e25ad98a3 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,8 @@
12013-02-25 Paul Eggert <eggert@cs.ucla.edu>
2
3 Simplify data_start configuration (Bug#13783).
4 * CPP-DEFINES (DATA_START, ORDINARY_LINK): Remove.
5
12013-02-11 Paul Eggert <eggert@cs.ucla.edu> 62013-02-11 Paul Eggert <eggert@cs.ucla.edu>
2 7
3 Tune by using memchr and memrchr. 8 Tune by using memchr and memrchr.
diff --git a/configure.ac b/configure.ac
index 3b1b9a92b54..2d843a01a0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -230,12 +230,6 @@ if test "X${with_pkg_config_prog}" != X; then
230 fi 230 fi
231fi 231fi
232 232
233CRT_DIR=
234AC_ARG_WITH([crt-dir],dnl
235[AS_HELP_STRING([--with-crt-dir=DIR],[directory containing crtn.o etc.
236The default is /usr/lib, or /usr/lib64 on some platforms.])])
237CRT_DIR="${with_crt_dir}"
238
239AC_ARG_WITH(gameuser,dnl 233AC_ARG_WITH(gameuser,dnl
240[AS_HELP_STRING([--with-gameuser=USER],[user for shared game score files])]) 234[AS_HELP_STRING([--with-gameuser=USER],[user for shared game score files])])
241test "X${with_gameuser}" != X && test "${with_gameuser}" != yes \ 235test "X${with_gameuser}" != X && test "${with_gameuser}" != yes \
@@ -1051,42 +1045,29 @@ AC_DEFUN([AC_TYPE_UID_T])
1051 1045
1052 1046
1053LIB_MATH=-lm 1047LIB_MATH=-lm
1054LIB_STANDARD=
1055START_FILES=
1056dnl Current possibilities handled by sed (aix4-2 -> aix, 1048dnl Current possibilities handled by sed (aix4-2 -> aix,
1057dnl gnu-linux -> gnu/linux, etc.): 1049dnl gnu-linux -> gnu/linux, etc.):
1058dnl gnu, gnu/linux, gnu/kfreebsd, aix, cygwin, darwin, hpux, irix. 1050dnl gnu, gnu/linux, gnu/kfreebsd, aix, cygwin, darwin, hpux, irix.
1059dnl And special cases: berkeley-unix, usg-unix-v, ms-dos, windows-nt. 1051dnl And special cases: berkeley-unix, usg-unix-v, ms-dos, windows-nt.
1060SYSTEM_TYPE=`echo $opsys | sed -e 's/[[0-9]].*//' -e 's|-|/|'` 1052SYSTEM_TYPE=`echo $opsys | sed -e 's/[[0-9]].*//' -e 's|-|/|'`
1061 1053
1062dnl NB do not use CRT_DIR unquoted here, since it might not be set yet.
1063case $opsys in 1054case $opsys in
1064 cygwin ) 1055 cygwin )
1065 LIB_MATH= 1056 LIB_MATH=
1066 START_FILES='pre-crt0.o'
1067 ;; 1057 ;;
1068 darwin ) 1058 darwin )
1069 ## Adding -lm confuses the dynamic linker, so omit it. 1059 ## Adding -lm confuses the dynamic linker, so omit it.
1070 LIB_MATH= 1060 LIB_MATH=
1071 START_FILES='pre-crt0.o'
1072 ;; 1061 ;;
1073 freebsd ) 1062 freebsd )
1074 LIB_STANDARD='-lgcc -lc -lgcc $(CRT_DIR)/crtn.o'
1075 START_FILES='pre-crt0.o $(CRT_DIR)/crt1.o $(CRT_DIR)/crti.o'
1076 SYSTEM_TYPE=berkeley-unix 1063 SYSTEM_TYPE=berkeley-unix
1077 ;; 1064 ;;
1078 gnu-linux | gnu-kfreebsd ) 1065 gnu-linux | gnu-kfreebsd )
1079 LIB_STANDARD='-lgcc -lc -lgcc $(CRT_DIR)/crtn.o'
1080 START_FILES='pre-crt0.o $(CRT_DIR)/crt1.o $(CRT_DIR)/crti.o'
1081 ;; 1066 ;;
1082 hpux10-20 | hpux11 ) 1067 hpux10-20 | hpux11 )
1083 LIB_STANDARD=-lc
1084 START_FILES='pre-crt0.o $(CRT_DIR)/crt0.o'
1085 ;; 1068 ;;
1086 dnl NB this may be adjusted below. 1069 dnl NB this may be adjusted below.
1087 netbsd | openbsd ) 1070 netbsd | openbsd )
1088 LIB_STANDARD='-lgcc -lc -lgcc $(CRT_DIR)/crtend.o'
1089 START_FILES='pre-crt0.o $(CRT_DIR)/crt0.o $(CRT_DIR)/crtbegin.o'
1090 SYSTEM_TYPE=berkeley-unix 1071 SYSTEM_TYPE=berkeley-unix
1091 ;; 1072 ;;
1092 1073
@@ -1097,96 +1078,9 @@ case $opsys in
1097esac 1078esac
1098 1079
1099AC_SUBST(LIB_MATH) 1080AC_SUBST(LIB_MATH)
1100AC_SUBST(START_FILES)
1101AC_DEFINE_UNQUOTED(SYSTEM_TYPE, "$SYSTEM_TYPE", 1081AC_DEFINE_UNQUOTED(SYSTEM_TYPE, "$SYSTEM_TYPE",
1102 [The type of system you are compiling for; sets `system-type'.]) 1082 [The type of system you are compiling for; sets `system-type'.])
1103 1083
1104dnl Not all platforms use crtn.o files. Check if the current one does.
1105crt_files=
1106
1107for file in x $LIB_STANDARD $START_FILES; do
1108 case "$file" in
1109 *CRT_DIR*) crt_files="$crt_files `echo $file | sed -e 's|.*/||'`" ;;
1110 esac
1111done
1112
1113if test "x$crt_files" != x; then
1114
1115 ## If user specified a crt-dir, use that unconditionally.
1116 crt_gcc=no
1117
1118 if test "X$CRT_DIR" = "X"; then
1119
1120 CRT_DIR=/usr/lib # default
1121
1122 case "$canonical" in
1123 x86_64-*-linux-gnu* | s390x-*-linux-gnu*)
1124 ## On x86-64 and s390x GNU/Linux distributions, the standard library
1125 ## can be in a variety of places. We only try /usr/lib64 and /usr/lib.
1126 ## For anything else (eg /usr/lib32), it is up the user to specify
1127 ## the location (bug#5655).
1128 ## Test for crtn.o, not just the directory, because sometimes the
1129 ## directory exists but does not have the relevant files (bug#1287).
1130 ## FIXME better to test for binary compatibility somehow.
1131 test -e /usr/lib64/crtn.o && CRT_DIR=/usr/lib64
1132 ;;
1133
1134 powerpc64-*-linux-gnu* | sparc64-*-linux-gnu*) CRT_DIR=/usr/lib64 ;;
1135 esac
1136
1137 case "$opsys" in
1138 hpux10-20) CRT_DIR=/lib ;;
1139 esac
1140
1141 test "x${GCC}" = xyes && crt_gcc=yes
1142
1143 fi # CRT_DIR = ""
1144
1145 crt_missing=
1146
1147 for file in $crt_files; do
1148
1149 ## If we're using gcc, try to determine it automatically by asking
1150 ## gcc. [If this doesn't work, CRT_DIR will remain at the
1151 ## system-dependent default from above.]
1152 if test $crt_gcc = yes && test ! -e $CRT_DIR/$file; then
1153
1154 crt_file=`$CC --print-file-name=$file 2>/dev/null`
1155 case "$crt_file" in
1156 */*)
1157 CRT_DIR=`AS_DIRNAME(["$crt_file"])`
1158 ;;
1159 esac
1160 fi
1161
1162 dnl We expect all the files to be in a single directory, so after the
1163 dnl first there is no point asking gcc.
1164 crt_gcc=no
1165
1166 test -e $CRT_DIR/$file || crt_missing="$crt_missing $file"
1167 done # $crt_files
1168
1169 test "x$crt_missing" = x || \
1170 AC_MSG_ERROR([Required file(s) not found:$crt_missing
1171Try using the --with-crt-dir option.])
1172
1173fi # crt_files != ""
1174
1175AC_SUBST(CRT_DIR)
1176
1177case $opsys in
1178 netbsd | openbsd )
1179 if test -f $CRT_DIR/crti.o; then
1180
1181 test -f $CRT_DIR/crtn.o || \
1182 AC_MSG_ERROR([Required file not found: crtn.o])
1183
1184 LIB_STANDARD='-lgcc -lc -lgcc $(CRT_DIR)/crtend.o $(CRT_DIR)/crtn.o'
1185 START_FILES='pre-crt0.o $(CRT_DIR)/crt0.o $(CRT_DIR)/crti.o $(CRT_DIR)/crtbegin.o'
1186 fi
1187 ;;
1188esac
1189
1190 1084
1191pre_PKG_CONFIG_CFLAGS=$CFLAGS 1085pre_PKG_CONFIG_CFLAGS=$CFLAGS
1192pre_PKG_CONFIG_LIBS=$LIBS 1086pre_PKG_CONFIG_LIBS=$LIBS
@@ -1304,7 +1198,7 @@ dnl checks for header files
1304AC_CHECK_HEADERS_ONCE( 1198AC_CHECK_HEADERS_ONCE(
1305 linux/version.h sys/systeminfo.h 1199 linux/version.h sys/systeminfo.h
1306 coff.h pty.h 1200 coff.h pty.h
1307 sys/vlimit.h sys/resource.h 1201 sys/resource.h
1308 sys/utsname.h pwd.h utmp.h util.h) 1202 sys/utsname.h pwd.h utmp.h util.h)
1309 1203
1310AC_MSG_CHECKING(if personality LINUX32 can be set) 1204AC_MSG_CHECKING(if personality LINUX32 can be set)
@@ -1521,8 +1415,6 @@ if test "${with_ns}" != no; then
1521 CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}" 1415 CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1522 LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}" 1416 LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}"
1523 LIBS_GNUSTEP="-lgnustep-gui -lgnustep-base -lobjc -lpthread" 1417 LIBS_GNUSTEP="-lgnustep-gui -lgnustep-base -lobjc -lpthread"
1524 LIB_STANDARD=
1525 START_FILES=
1526 dnl GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS to 0 or 1. 1418 dnl GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS to 0 or 1.
1527 dnl If they had chosen to either define it or not, we could have 1419 dnl If they had chosen to either define it or not, we could have
1528 dnl just used AC_CHECK_DECL here. 1420 dnl just used AC_CHECK_DECL here.
@@ -1611,7 +1503,6 @@ AC_SUBST(INSTALL_ARCH_INDEP_EXTRA)
1611AC_SUBST(ns_self_contained) 1503AC_SUBST(ns_self_contained)
1612AC_SUBST(NS_OBJ) 1504AC_SUBST(NS_OBJ)
1613AC_SUBST(NS_OBJC_OBJ) 1505AC_SUBST(NS_OBJC_OBJ)
1614AC_SUBST(LIB_STANDARD)
1615 1506
1616HAVE_W32=no 1507HAVE_W32=no
1617W32_OBJ= 1508W32_OBJ=
@@ -1751,6 +1642,20 @@ if test "${system_malloc}" = "yes"; then
1751else 1642else
1752 test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o 1643 test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
1753 VMLIMIT_OBJ=vm-limit.o 1644 VMLIMIT_OBJ=vm-limit.o
1645
1646 AC_CHECK_HEADERS([sys/vlimit.h])
1647 AC_CACHE_CHECK([for data_start], [emacs_cv_data_start],
1648 [AC_LINK_IFELSE(
1649 [AC_LANG_PROGRAM(
1650 [[extern char data_start[]; char ch;]],
1651 [[return data_start == &ch;]])],
1652 [emacs_cv_data_start=yes],
1653 [emacs_cv_data_start=no])])
1654 if test $emacs_cv_data_start = yes; then
1655 AC_DEFINE([HAVE_DATA_START], 1,
1656 [Define to 1 if data_start is the address of the start
1657 of the main data segment.])
1658 fi
1754fi 1659fi
1755AC_SUBST(GMALLOC_OBJ) 1660AC_SUBST(GMALLOC_OBJ)
1756AC_SUBST(VMLIMIT_OBJ) 1661AC_SUBST(VMLIMIT_OBJ)
@@ -3735,9 +3640,7 @@ case $opsys in
3735esac 3640esac
3736 3641
3737 3642
3738dnl Used in vm-limit.c 3643dnl Used in lisp.h, emacs.c, vm-limit.c
3739AH_TEMPLATE(DATA_START, [Address of the start of the data segment.])
3740dnl Used in lisp.h, emacs.c, mem-limits.h
3741dnl NEWS.18 describes this as "a number which contains 3644dnl NEWS.18 describes this as "a number which contains
3742dnl the high bits to be inclusive or'ed with pointers that are unpacked." 3645dnl the high bits to be inclusive or'ed with pointers that are unpacked."
3743AH_TEMPLATE(DATA_SEG_BITS, [Extra bits to be or'd in with any pointers 3646AH_TEMPLATE(DATA_SEG_BITS, [Extra bits to be or'd in with any pointers
@@ -3745,23 +3648,15 @@ stored in a Lisp_Object.])
3745dnl if Emacs uses fewer than 32 bits for the value field of a LISP_OBJECT. 3648dnl if Emacs uses fewer than 32 bits for the value field of a LISP_OBJECT.
3746 3649
3747case $opsys in 3650case $opsys in
3748 gnu)
3749 dnl libc defines data_start.
3750 AC_DEFINE(DATA_START, [({ extern int data_start; (char *) &data_start; })])
3751 ;;
3752
3753 aix*) 3651 aix*)
3754 dnl This works with 32-bit executables; Emacs doesn't support 64-bit. 3652 dnl This works with 32-bit executables; Emacs doesn't support 64-bit.
3755 AC_DEFINE(DATA_START, [0x20000000])
3756 AC_DEFINE(DATA_SEG_BITS, [0x20000000]) 3653 AC_DEFINE(DATA_SEG_BITS, [0x20000000])
3757 ;; 3654 ;;
3758 hpux*) 3655 hpux*)
3759 dnl The data segment on this machine always starts at address 0x40000000. 3656 dnl The data segment on this machine always starts at address 0x40000000.
3760 AC_DEFINE(DATA_START, [0x40000000])
3761 AC_DEFINE(DATA_SEG_BITS, [0x40000000]) 3657 AC_DEFINE(DATA_SEG_BITS, [0x40000000])
3762 ;; 3658 ;;
3763 irix6-5) 3659 irix6-5)
3764 AC_DEFINE(DATA_START, [0x10000000])
3765 AC_DEFINE(DATA_SEG_BITS, [0x10000000]) 3660 AC_DEFINE(DATA_SEG_BITS, [0x10000000])
3766 ;; 3661 ;;
3767esac 3662esac
@@ -4321,88 +4216,6 @@ esac
4321 4216
4322AC_SUBST(LD_SWITCH_SYSTEM_TEMACS) 4217AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
4323 4218
4324
4325LD_FIRSTFLAG=
4326ORDINARY_LINK=
4327case "$opsys" in
4328 ## gnu: GNU needs its own crt0.
4329 aix4-2|cygwin|darwin|gnu|hpux*|irix6-5|sol2*|unixware) ORDINARY_LINK=yes ;;
4330
4331 ## On post 1.3 releases of NetBSD, gcc -nostdlib also clears the
4332 ## library search parth, i.e. it won't search /usr/lib for libc and
4333 ## friends. Using -nostartfiles instead avoids this problem, and
4334 ## will also work on earlier NetBSD releases.
4335 netbsd|openbsd) LD_FIRSTFLAG="-nostartfiles" ;;
4336
4337 ## powerpc*: NAKAJI Hiroyuki <nakaji@tutrp.tut.ac.jp> says
4338 ## MkLinux/LinuxPPC needs this.
4339 ## s390x-* only supports opsys = gnu-linux so it can be added here.
4340 gnu-*)
4341 case "$canonical" in
4342 powerpc*|s390x-*) LD_FIRSTFLAG="-nostdlib" ;;
4343 esac
4344 ;;
4345esac
4346
4347
4348if test "x$ORDINARY_LINK" = "xyes"; then
4349
4350 LD_FIRSTFLAG=""
4351 AC_DEFINE(ORDINARY_LINK, 1, [Define if the C compiler is the linker.])
4352
4353## The system files defining neither ORDINARY_LINK nor LD_FIRSTFLAG are:
4354## freebsd, gnu-* not on powerpc*|s390x*.
4355elif test "x$GCC" = "xyes" && test "x$LD_FIRSTFLAG" = "x"; then
4356
4357 ## Versions of GCC >= 2.0 put their library, libgcc.a, in obscure
4358 ## places that are difficult to figure out at make time. Fortunately,
4359 ## these same versions allow you to pass arbitrary flags on to the
4360 ## linker, so there is no reason not to use it as a linker.
4361 ##
4362 ## Well, it is not quite perfect. The "-nostdlib" keeps GCC from
4363 ## searching for libraries in its internal directories, so we have to
4364 ## ask GCC explicitly where to find libgcc.a (LIB_GCC below).
4365 LD_FIRSTFLAG="-nostdlib"
4366fi
4367
4368## FIXME? What setting of EDIT_LDFLAGS should this have?
4369test "$NS_IMPL_GNUSTEP" = "yes" && LD_FIRSTFLAG="-rdynamic"
4370
4371AC_SUBST(LD_FIRSTFLAG)
4372
4373
4374## FIXME? The logic here is not precisely the same as that above.
4375## There is no check here for a pre-defined LD_FIRSTFLAG.
4376## Should we only be setting LIB_GCC if LD ~ -nostdlib?
4377LIB_GCC=
4378if test "x$GCC" = "xyes" && test "x$ORDINARY_LINK" != "xyes"; then
4379
4380 case "$opsys" in
4381 freebsd|netbsd|openbsd) LIB_GCC= ;;
4382
4383 gnu-*)
4384 ## armin76@gentoo.org reported that the lgcc_s flag is necessary to
4385 ## build on ARM EABI under GNU/Linux. (Bug#5518)
4386 case $host_cpu in
4387 arm*)
4388 LIB_GCC="-lgcc_s"
4389 ;;
4390 *)
4391 ## FIXME? s/gnu-linux.h used to define LIB_GCC as below, then
4392 ## immediately undefine it again and redefine it to empty.
4393 ## Was the C_SWITCH_X_SITE part really necessary?
4394## LIB_GCC=`$CC $C_SWITCH_X_SITE -print-libgcc-file-name`
4395 LIB_GCC=
4396 ;;
4397 esac
4398 ;;
4399
4400 ## Ask GCC where to find libgcc.a.
4401 *) LIB_GCC=`$CC -print-libgcc-file-name 2> /dev/null` ;;
4402 esac
4403fi dnl if $GCC
4404AC_SUBST(LIB_GCC)
4405
4406## Common for all window systems 4219## Common for all window systems
4407if test "$window_system" != "none"; then 4220if test "$window_system" != "none"; then
4408 AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.]) 4221 AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.])
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 2e0eb2d7056..49d03227c48 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,10 @@
12013-02-25 Paul Eggert <eggert@cs.ucla.edu>
2
3 Simplify data_start configuration (Bug#13783).
4 * PROBLEMS (LIBS_SYSTEM, LIBS_MACHINE, LIBS_STANDARD): Remove.
5 Remove legacy-systems section, as this stuff is no longer
6 applicable with current linking strategies.
7
12013-02-14 Michael Albinus <michael.albinus@gmx.de> 82013-02-14 Michael Albinus <michael.albinus@gmx.de>
2 9
3 * NEWS: Tramp methods "scpc" and "rsyncc" are discontinued. 10 * NEWS: Tramp methods "scpc" and "rsyncc" are discontinued.
diff --git a/etc/PROBLEMS b/etc/PROBLEMS
index 441ad7b4df4..b38a1240540 100644
--- a/etc/PROBLEMS
+++ b/etc/PROBLEMS
@@ -432,21 +432,7 @@ The fix is to install an unshared library that corresponds to what you
432installed in the shared library, and then relink Emacs. 432installed in the shared library, and then relink Emacs.
433 433
434If you have already installed the name resolver in the file libresolv.a, 434If you have already installed the name resolver in the file libresolv.a,
435then you need to compile Emacs to use that library. The easiest way to 435then you need to compile Emacs to use that library.
436do this is to add to config.h a definition of LIBS_SYSTEM, LIBS_MACHINE
437or LIB_STANDARD which uses -lresolv. Watch out! If you redefine a macro
438that is already in use in your configuration to supply some other libraries,
439be careful not to lose the others.
440
441Thus, you could start by adding this to config.h:
442
443#define LIBS_SYSTEM -lresolv
444
445Then if this gives you an error for redefining a macro, and you see that
446config.h already defines LIBS_SYSTEM as -lfoo -lbar at some other point
447(possibly in an included file) you could change it to say this:
448
449#define LIBS_SYSTEM -lresolv -lfoo -lbar
450 436
451*** Emacs does not know your host's fully-qualified domain name. 437*** Emacs does not know your host's fully-qualified domain name.
452 438
@@ -3179,25 +3165,6 @@ as a concentrator.
3179 3165
3180This problem seems to be a matter of configuring the DECserver to use 3166This problem seems to be a matter of configuring the DECserver to use
31817 bit characters rather than 8 bit characters. 31677 bit characters rather than 8 bit characters.
3182
3183* Build problems on legacy systems
3184
3185** SunOS: Emacs gets error message from linker on Sun.
3186
3187If the error message says that a symbol such as `f68881_used' or
3188`ffpa_used' or `start_float' is undefined, this probably indicates
3189that you have compiled some libraries, such as the X libraries,
3190with a floating point option other than the default.
3191
3192It's not terribly hard to make this work with small changes in
3193crt0.c together with linking with Fcrt1.o, Wcrt1.o or Mcrt1.o.
3194However, the easiest approach is to build Xlib with the default
3195floating point option: -fsoft.
3196
3197** HPUX 10.20: Emacs crashes during dumping on the HPPA machine.
3198
3199This seems to be due to a GCC bug; it is fixed in GCC 2.8.1.
3200
3201 3168
3202This file is part of GNU Emacs. 3169This file is part of GNU Emacs.
3203 3170
diff --git a/src/ChangeLog b/src/ChangeLog
index 8d3fc1e56fb..00d1f30dd46 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,36 @@
12013-02-25 Paul Eggert <eggert@cs.ucla.edu>
2
3 Simplify data_start configuration (Bug#13783).
4 This is a followon simplification to the fix for Bug#13650.
5 * Makefile.in (LD_FIRSTFLAG, LIB_GCC, CRT_DIR, LIB_STANDARD)
6 (START_FILES): Remove. All uses removed.
7 (otherobj): Remove $(VMLIMIT_OBJ), as it's now first.
8 (ALLOBJS): Move here from autodeps.mk, and with VMLIMITS_OBJ first.
9 (buildobj.h): Use it.
10 ($(ALLOBJS)): Depend on globals.h.
11 (temacs$(EXEEXT)): Use $(ALLOBJS).
12 * autodeps.mk (ALLOBJS): Move to Makefile.in.
13 * deps.mk (vm-limit.o):
14 * makefile.w32-in ($(BLD)/vm-limit.$(O)):
15 Do not depend on mem-limits.h.
16 * emacs.c (__do_global_ctors, __do_global_ctors_aux)
17 (__do_global_dtors, __CTOR_LIST__, __DTOR_LIST__)
18 [__GNUC__ && !ORDINARY_LINK]: Remove.
19 * mem-limits.h, pre-crt0.c: Remove.
20 * unexaix.c, unexcoff.c: Don't include mem-limits.h.
21 * unexcoff.c (etext): New decl.
22 (make_hdr): Use DATA_START instead of start_of_data.
23 * vm-limit.c: Move most of mem-limits.h's contents here.
24 (data_start): New decl. It's OK if this is approximate,
25 so simplify-away some unnecessary exactness.
26 (POINTER): Remove; all uses removed.
27 (data_space_start): Now char *, to avoid casts.
28 (exceeds_lisp_ptr): New function, replacing the old
29 EXCEEDS_LISP_PTR macro. All uses changed.
30 (check_memory_limits): Simplify and remove casts.
31 (start_of_data) [!CANNOT_DUMP || !SYSTEM_MALLOC]: Remove.
32 (memory_warnings): Use data_start instead of start_of_data.
33
12013-02-24 Andreas Schwab <schwab@linux-m68k.org> 342013-02-24 Andreas Schwab <schwab@linux-m68k.org>
2 35
3 * xdisp.c (set_message): Only check for debug-on-message if STRING 36 * xdisp.c (set_message): Only check for debug-on-message if STRING
diff --git a/src/Makefile.in b/src/Makefile.in
index 6ee03177861..b2034a3379d 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -36,7 +36,6 @@ WINDRES = @WINDRES@
36CFLAGS = @CFLAGS@ 36CFLAGS = @CFLAGS@
37CPPFLAGS = @CPPFLAGS@ 37CPPFLAGS = @CPPFLAGS@
38LDFLAGS = @LDFLAGS@ 38LDFLAGS = @LDFLAGS@
39LD_FIRSTFLAG=@LD_FIRSTFLAG@
40EXEEXT = @EXEEXT@ 39EXEEXT = @EXEEXT@
41version = @version@ 40version = @version@
42# Substitute an assignment for the MAKE variable, because 41# Substitute an assignment for the MAKE variable, because
@@ -102,10 +101,8 @@ LD_SWITCH_X_SITE_RPATH=@LD_SWITCH_X_SITE_RPATH@
102## System-specific LDFLAGS. 101## System-specific LDFLAGS.
103LD_SWITCH_SYSTEM=@LD_SWITCH_SYSTEM@ 102LD_SWITCH_SYSTEM=@LD_SWITCH_SYSTEM@
104 103
105## This holds any special options for linking temacs only (ie, not 104## This holds any special options for linking temacs only (i.e., not
106## used by configure). Not used elsewhere because it sometimes 105## used by configure).
107## contains options that have to do with using Emacs's crt0,
108## which are only good with temacs.
109LD_SWITCH_SYSTEM_TEMACS=@LD_SWITCH_SYSTEM_TEMACS@ 106LD_SWITCH_SYSTEM_TEMACS=@LD_SWITCH_SYSTEM_TEMACS@
110 107
111## Flags to pass to ld only for temacs. 108## Flags to pass to ld only for temacs.
@@ -120,14 +117,6 @@ PAXCTL = @PAXCTL@
120## Some systems define this to request special libraries. 117## Some systems define this to request special libraries.
121LIBS_SYSTEM=@LIBS_SYSTEM@ 118LIBS_SYSTEM=@LIBS_SYSTEM@
122 119
123## Where to find libgcc.a, if using gcc and necessary.
124LIB_GCC=@LIB_GCC@
125
126CRT_DIR=@CRT_DIR@
127## May use $CRT_DIR.
128LIB_STANDARD=@LIB_STANDARD@
129START_FILES = @START_FILES@
130
131## -lm, or empty. 120## -lm, or empty.
132LIB_MATH=@LIB_MATH@ 121LIB_MATH=@LIB_MATH@
133 122
@@ -389,17 +378,16 @@ POST_ALLOC_OBJ=@POST_ALLOC_OBJ@
389 378
390## List of object files that make-docfile should not be told about. 379## List of object files that make-docfile should not be told about.
391otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \ 380otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
392 $(POST_ALLOC_OBJ) $(VMLIMIT_OBJ) $(WIDGET_OBJ) $(LIBOBJS) 381 $(POST_ALLOC_OBJ) $(WIDGET_OBJ) $(LIBOBJS)
393 382
383## All object files linked into temacs. $(VMLIMIT_OBJ) should be first.
384ALLOBJS = $(VMLIMIT_OBJ) $(obj) $(otherobj)
394 385
395## Configure inserts the file lisp.mk at this point, defining $lisp. 386## Configure inserts the file lisp.mk at this point, defining $lisp.
396@lisp_frag@ 387@lisp_frag@
397 388
398 389
399## Construct full set of libraries to be linked. 390## Construct full set of libraries to be linked.
400## Note that SunOS needs -lm to come before -lc; otherwise, you get
401## duplicated symbols. If the standard libraries were compiled
402## with GCC, we might need LIB_GCC again after them.
403LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ 391LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
404 $(LIBX_OTHER) $(LIBSOUND) \ 392 $(LIBX_OTHER) $(LIBSOUND) \
405 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \ 393 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \
@@ -409,7 +397,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
409 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ 397 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
410 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ 398 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
411 $(LIBACL_LIBS) $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \ 399 $(LIBACL_LIBS) $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \
412 $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) 400 $(LIB_MATH)
413 401
414all: emacs$(EXEEXT) $(OTHER_FILES) 402all: emacs$(EXEEXT) $(OTHER_FILES)
415.PHONY: all 403.PHONY: all
@@ -456,7 +444,7 @@ $(libsrc)/make-docfile$(EXEEXT):
456 cd $(libsrc); $(MAKE) $(MFLAGS) make-docfile$(EXEEXT) 444 cd $(libsrc); $(MAKE) $(MFLAGS) make-docfile$(EXEEXT)
457 445
458buildobj.h: Makefile 446buildobj.h: Makefile
459 echo "#define BUILDOBJ \"$(obj) $(otherobj) " "\"" > buildobj.h 447 echo "#define BUILDOBJ \"$(ALLOBJS) " "\"" >$@
460 448
461globals.h: gl-stamp; @true 449globals.h: gl-stamp; @true
462 450
@@ -468,15 +456,15 @@ gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES)
468 $(srcdir)/../build-aux/move-if-change gl-tmp globals.h 456 $(srcdir)/../build-aux/move-if-change gl-tmp globals.h
469 echo timestamp > $@ 457 echo timestamp > $@
470 458
471$(obj) $(otherobj): globals.h 459$(ALLOBJS): globals.h
472 460
473$(lib)/libgnu.a: $(config_h) 461$(lib)/libgnu.a: $(config_h)
474 cd $(lib) && $(MAKE) libgnu.a 462 cd $(lib) && $(MAKE) libgnu.a
475 463
476temacs$(EXEEXT): $(START_FILES) stamp-oldxmenu $(obj) $(otherobj) \ 464temacs$(EXEEXT): stamp-oldxmenu $(ALLOBJS) \
477 $(lib)/libgnu.a $(W32_RES) 465 $(lib)/libgnu.a $(W32_RES)
478 $(CC) $(LD_FIRSTFLAG) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \ 466 $(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
479 -o temacs $(START_FILES) $(obj) $(otherobj) $(lib)/libgnu.a $(LIBES) \ 467 -o temacs $(ALLOBJS) $(lib)/libgnu.a $(LIBES) \
480 $(W32_RES_LINK) 468 $(W32_RES_LINK)
481 test "$(CANNOT_DUMP)" = "yes" || \ 469 test "$(CANNOT_DUMP)" = "yes" || \
482 test "X$(PAXCTL)" = X || $(PAXCTL) -r temacs$(EXEEXT) 470 test "X$(PAXCTL)" = X || $(PAXCTL) -r temacs$(EXEEXT)
diff --git a/src/autodeps.mk b/src/autodeps.mk
index fb0e21366c7..8b014a7508c 100644
--- a/src/autodeps.mk
+++ b/src/autodeps.mk
@@ -2,5 +2,4 @@
2 2
3## This is inserted in src/Makefile if AUTO_DEPEND=yes. 3## This is inserted in src/Makefile if AUTO_DEPEND=yes.
4 4
5ALLOBJS=$(START_FILES) ${obj} ${otherobj}
6-include $(ALLOBJS:%.o=${DEPDIR}/%.d) 5-include $(ALLOBJS:%.o=${DEPDIR}/%.d)
diff --git a/src/deps.mk b/src/deps.mk
index 47185c9262c..83444474c59 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -144,7 +144,7 @@ macros.o: macros.c window.h buffer.h commands.h macros.h keyboard.h msdos.h \
144 dispextern.h lisp.h globals.h $(config_h) systime.h coding.h composite.h 144 dispextern.h lisp.h globals.h $(config_h) systime.h coding.h composite.h
145gmalloc.o: gmalloc.c $(config_h) 145gmalloc.o: gmalloc.c $(config_h)
146ralloc.o: ralloc.c lisp.h $(config_h) 146ralloc.o: ralloc.c lisp.h $(config_h)
147vm-limit.o: vm-limit.c mem-limits.h lisp.h globals.h $(config_h) 147vm-limit.o: vm-limit.c lisp.h globals.h $(config_h)
148marker.o: marker.c buffer.h character.h lisp.h globals.h $(config_h) 148marker.o: marker.c buffer.h character.h lisp.h globals.h $(config_h)
149minibuf.o: minibuf.c syntax.h frame.h window.h keyboard.h systime.h \ 149minibuf.o: minibuf.c syntax.h frame.h window.h keyboard.h systime.h \
150 buffer.h commands.h character.h msdos.h $(INTERVALS_H) keymap.h \ 150 buffer.h commands.h character.h msdos.h $(INTERVALS_H) keymap.h \
diff --git a/src/emacs.c b/src/emacs.c
index c494dff8cac..b96076b1340 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -521,32 +521,6 @@ DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory,
521static char const dump_tz[] = "UtC0"; 521static char const dump_tz[] = "UtC0";
522#endif 522#endif
523 523
524#ifndef ORDINARY_LINK
525/* We don't include crtbegin.o and crtend.o in the link,
526 so these functions and variables might be missed.
527 Provide dummy definitions to avoid error.
528 (We don't have any real constructors or destructors.) */
529#ifdef __GNUC__
530
531/* Define a dummy function F. Declare F too, to pacify gcc
532 -Wmissing-prototypes. */
533#define DEFINE_DUMMY_FUNCTION(f) \
534 void f (void) ATTRIBUTE_CONST EXTERNALLY_VISIBLE; void f (void) {}
535
536#ifndef GCC_CTORS_IN_LIBC
537DEFINE_DUMMY_FUNCTION (__do_global_ctors)
538DEFINE_DUMMY_FUNCTION (__do_global_ctors_aux)
539DEFINE_DUMMY_FUNCTION (__do_global_dtors)
540/* GNU/Linux has a bug in its library; avoid an error. */
541#ifndef GNU_LINUX
542char * __CTOR_LIST__[2] EXTERNALLY_VISIBLE = { (char *) (-1), 0 };
543#endif
544char * __DTOR_LIST__[2] EXTERNALLY_VISIBLE = { (char *) (-1), 0 };
545#endif /* GCC_CTORS_IN_LIBC */
546DEFINE_DUMMY_FUNCTION (__main)
547#endif /* __GNUC__ */
548#endif /* ORDINARY_LINK */
549
550/* Test whether the next argument in ARGV matches SSTR or a prefix of 524/* Test whether the next argument in ARGV matches SSTR or a prefix of
551 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null 525 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
552 (the argument is supposed to have a value) store in *VALPTR either 526 (the argument is supposed to have a value) store in *VALPTR either
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 6e1873f8e49..d60331198db 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -1492,7 +1492,6 @@ $(BLD)/unexw32.$(O) : \
1492 1492
1493$(BLD)/vm-limit.$(O) : \ 1493$(BLD)/vm-limit.$(O) : \
1494 $(SRC)/vm-limit.c \ 1494 $(SRC)/vm-limit.c \
1495 $(SRC)/mem-limits.h \
1496 $(SRC)/w32heap.h \ 1495 $(SRC)/w32heap.h \
1497 $(NT_INC)/unistd.h \ 1496 $(NT_INC)/unistd.h \
1498 $(CONFIG_H) \ 1497 $(CONFIG_H) \
diff --git a/src/mem-limits.h b/src/mem-limits.h
deleted file mode 100644
index 941ccf5f121..00000000000
--- a/src/mem-limits.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/* Includes for memory limit warnings.
2 Copyright (C) 1990, 1993-1996, 2001-2013 Free Software Foundation,
3 Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifdef MSDOS
21#include <dpmi.h>
22extern int etext;
23#endif
24
25/* Some systems need this before <sys/resource.h>. */
26#include <sys/types.h>
27
28#ifdef HAVE_SYS_RESOURCE_H
29# include <sys/time.h>
30# include <sys/resource.h>
31#else
32# if HAVE_SYS_VLIMIT_H
33# include <sys/vlimit.h> /* Obsolete, says glibc */
34# endif
35#endif
36
37extern char *start_of_data (void) ATTRIBUTE_CONST;
38#if USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX
39#define EXCEEDS_LISP_PTR(ptr) 0
40#else
41#define EXCEEDS_LISP_PTR(ptr) \
42 (((uintptr_t) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
43#endif
diff --git a/src/pre-crt0.c b/src/pre-crt0.c
deleted file mode 100644
index 6b9618c8dc3..00000000000
--- a/src/pre-crt0.c
+++ /dev/null
@@ -1,10 +0,0 @@
1/* This file is loaded before crt0.o on machines where we do not
2 remap part of the data space into text space in unexec.
3 On these machines, there is no problem with standard crt0.o's
4 that make environ an initialized variable. However, we do
5 need to make sure the label data_start exists anyway. */
6
7/* Create a label to appear at the beginning of data space.
8 Its value is nonzero so that it cannot be put into bss. */
9
10int data_start = 1;
diff --git a/src/unexaix.c b/src/unexaix.c
index da44480fdca..44a824b8c12 100644
--- a/src/unexaix.c
+++ b/src/unexaix.c
@@ -59,8 +59,6 @@ what you give them. Help stamp out software-hoarding! */
59#include <unistd.h> 59#include <unistd.h>
60#include <fcntl.h> 60#include <fcntl.h>
61 61
62#include "mem-limits.h"
63
64extern char _data[]; 62extern char _data[];
65extern char _text[]; 63extern char _text[];
66 64
diff --git a/src/unexcoff.c b/src/unexcoff.c
index 466a5c0e491..2e662a34145 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -99,7 +99,7 @@ struct aouthdr
99 99
100#include <sys/file.h> 100#include <sys/file.h>
101 101
102#include "mem-limits.h" 102extern int etext;
103 103
104static long block_copy_start; /* Old executable start point */ 104static long block_copy_start; /* Old executable start point */
105static struct filehdr f_hdr; /* File header */ 105static struct filehdr f_hdr; /* File header */
@@ -168,7 +168,7 @@ make_hdr (int new, int a_out,
168 pagemask = getpagesize () - 1; 168 pagemask = getpagesize () - 1;
169 169
170 /* Adjust text/data boundary. */ 170 /* Adjust text/data boundary. */
171 data_start = (int) start_of_data (); 171 data_start = (int) DATA_START;
172 data_start = ADDR_CORRECT (data_start); 172 data_start = ADDR_CORRECT (data_start);
173 data_start = data_start & ~pagemask; /* (Down) to page boundary. */ 173 data_start = data_start & ~pagemask; /* (Down) to page boundary. */
174 174
diff --git a/src/vm-limit.c b/src/vm-limit.c
index fc7a253325a..3fca8bd26c1 100644
--- a/src/vm-limit.c
+++ b/src/vm-limit.c
@@ -19,7 +19,37 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19#include <config.h> 19#include <config.h>
20#include <unistd.h> /* for 'environ', on AIX */ 20#include <unistd.h> /* for 'environ', on AIX */
21#include "lisp.h" 21#include "lisp.h"
22#include "mem-limits.h" 22
23#ifdef MSDOS
24#include <dpmi.h>
25extern int etext;
26#endif
27
28/* Some systems need this before <sys/resource.h>. */
29#include <sys/types.h>
30
31#ifdef HAVE_SYS_RESOURCE_H
32# include <sys/time.h>
33# include <sys/resource.h>
34#else
35# if HAVE_SYS_VLIMIT_H
36# include <sys/vlimit.h> /* Obsolete, says glibc */
37# endif
38#endif
39
40/* Start of data. It is OK if this is approximate; it's used only as
41 a heuristic. */
42#ifdef DATA_START
43# define data_start ((char *) DATA_START)
44#else
45extern char data_start[];
46# ifndef HAVE_DATA_START
47/* Initialize to nonzero, so that it's put into data and not bss.
48 Link this file's object code first, so that this symbol is near the
49 start of data. */
50char data_start[1] = { 1 };
51# endif
52#endif
23 53
24/* 54/*
25 Level number of warnings already issued. 55 Level number of warnings already issued.
@@ -35,12 +65,20 @@ static enum warnlevel warnlevel;
35 0 means don't issue them. */ 65 0 means don't issue them. */
36static void (*warn_function) (const char *); 66static void (*warn_function) (const char *);
37 67
38/* Start of data space; can be changed by calling malloc_init. */ 68/* Start of data space; can be changed by calling memory_warnings. */
39static void *data_space_start; 69static char *data_space_start;
40 70
41/* Number of bytes of writable memory we can expect to be able to get. */ 71/* Number of bytes of writable memory we can expect to be able to get. */
42static size_t lim_data; 72static size_t lim_data;
43 73
74/* Return true if PTR cannot be represented as an Emacs Lisp object. */
75static bool
76exceeds_lisp_ptr (void *ptr)
77{
78 return (! USE_LSB_TAG
79 && VAL_MAX < UINTPTR_MAX
80 && ((uintptr_t) ptr & ~DATA_SEG_BITS) >> VALBITS != 0);
81}
44 82
45#ifdef HAVE_GETRLIMIT 83#ifdef HAVE_GETRLIMIT
46 84
@@ -122,10 +160,12 @@ check_memory_limits (void)
122{ 160{
123#ifdef REL_ALLOC 161#ifdef REL_ALLOC
124 extern void *(*real_morecore) (ptrdiff_t); 162 extern void *(*real_morecore) (ptrdiff_t);
163#else
164 void *(*real_morecore) (ptrdiff_t) = 0;
125#endif 165#endif
126 extern void *(*__morecore) (ptrdiff_t); 166 extern void *(*__morecore) (ptrdiff_t);
127 167
128 void *cp; 168 char *cp;
129 size_t five_percent; 169 size_t five_percent;
130 size_t data_size; 170 size_t data_size;
131 enum warnlevel new_warnlevel; 171 enum warnlevel new_warnlevel;
@@ -135,13 +175,8 @@ check_memory_limits (void)
135 five_percent = lim_data / 20; 175 five_percent = lim_data / 20;
136 176
137 /* Find current end of memory and issue warning if getting near max */ 177 /* Find current end of memory and issue warning if getting near max */
138#ifdef REL_ALLOC 178 cp = (real_morecore ? real_morecore : __morecore) (0);
139 if (real_morecore) 179 data_size = cp - data_space_start;
140 cp = (char *) (*real_morecore) (0);
141 else
142#endif
143 cp = (char *) (*__morecore) (0);
144 data_size = (char *) cp - (char *) data_space_start;
145 180
146 if (!warn_function) 181 if (!warn_function)
147 return; 182 return;
@@ -188,49 +223,10 @@ check_memory_limits (void)
188 warnlevel = warned_85; 223 warnlevel = warned_85;
189 } 224 }
190 225
191 if (EXCEEDS_LISP_PTR (cp)) 226 if (exceeds_lisp_ptr (cp))
192 (*warn_function) ("Warning: memory in use exceeds lisp pointer size"); 227 (*warn_function) ("Warning: memory in use exceeds lisp pointer size");
193} 228}
194 229
195#if !defined (CANNOT_DUMP) || !defined (SYSTEM_MALLOC)
196/* Some systems that cannot dump also cannot implement these. */
197
198/*
199 * Return the address of the start of the data segment prior to
200 * doing an unexec. After unexec the return value is undefined.
201 * See crt0.c for further information and definition of data_start.
202 *
203 * Apparently, on BSD systems this is etext at startup. On
204 * USG systems (swapping) this is highly mmu dependent and
205 * is also dependent on whether or not the program is running
206 * with shared text. Generally there is a (possibly large)
207 * gap between end of text and start of data with shared text.
208 *
209 */
210
211char *
212start_of_data (void)
213{
214#ifdef BSD_SYSTEM
215 extern char etext;
216 return (void *) &etext;
217#elif defined DATA_START
218 return (void *) DATA_START;
219#elif defined ORDINARY_LINK
220 /*
221 * This is a hack. Since we're not linking crt0.c or pre_crt0.c,
222 * data_start isn't defined. We take the address of environ, which
223 * is known to live at or near the start of the system crt0.c, and
224 * we don't sweat the handful of bytes that might lose.
225 */
226 return (void *) &environ;
227#else
228 extern int data_start;
229 return (void *) &data_start;
230#endif
231}
232#endif /* (not CANNOT_DUMP or not SYSTEM_MALLOC) */
233
234/* Enable memory usage warnings. 230/* Enable memory usage warnings.
235 START says where the end of pure storage is. 231 START says where the end of pure storage is.
236 WARNFUN specifies the function to call to issue a warning. */ 232 WARNFUN specifies the function to call to issue a warning. */
@@ -240,10 +236,7 @@ memory_warnings (void *start, void (*warnfun) (const char *))
240{ 236{
241 extern void (* __after_morecore_hook) (void); /* From gmalloc.c */ 237 extern void (* __after_morecore_hook) (void); /* From gmalloc.c */
242 238
243 if (start) 239 data_space_start = start ? start : data_start;
244 data_space_start = start;
245 else
246 data_space_start = start_of_data ();
247 240
248 warn_function = warnfun; 241 warn_function = warnfun;
249 __after_morecore_hook = check_memory_limits; 242 __after_morecore_hook = check_memory_limits;