Commit 1ddc2bd6 authored by Paul Eggert's avatar Paul Eggert

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
parent 82fcf982
2013-02-25 Paul Eggert <eggert@cs.ucla.edu>
Simplify data_start configuration (Bug#13783).
* 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.
2013-02-18 Aidan Gauland <aidalgol@no8wireless.co.nz>
* lisp/eshell/em-cmpl.el: Corrected "context-related help"
......
......@@ -90,7 +90,6 @@ BROKEN_NON_BLOCKING_CONNECT
BROKEN_PTY_READ_AFTER_EAGAIN
CLASH_DETECTION
DATA_SEG_BITS
DATA_START
DEFAULT_SOUND_DEVICE
DEVICE_SEP
DIRECTORY_SEP
......@@ -408,7 +407,6 @@ NO_EDITRES
NSIG
NSIG_MINIMUM
NULL_DEVICE
ORDINARY_LINK
PAGESIZE
PREFER_VSUSP
PTY_ITERATION
......
2013-02-25 Paul Eggert <eggert@cs.ucla.edu>
Simplify data_start configuration (Bug#13783).
* CPP-DEFINES (DATA_START, ORDINARY_LINK): Remove.
2013-02-11 Paul Eggert <eggert@cs.ucla.edu>
Tune by using memchr and memrchr.
......
This diff is collapsed.
2013-02-25 Paul Eggert <eggert@cs.ucla.edu>
Simplify data_start configuration (Bug#13783).
* PROBLEMS (LIBS_SYSTEM, LIBS_MACHINE, LIBS_STANDARD): Remove.
Remove legacy-systems section, as this stuff is no longer
applicable with current linking strategies.
2013-02-14 Michael Albinus <michael.albinus@gmx.de>
* NEWS: Tramp methods "scpc" and "rsyncc" are discontinued.
......
......@@ -432,21 +432,7 @@ The fix is to install an unshared library that corresponds to what you
installed in the shared library, and then relink Emacs.
If you have already installed the name resolver in the file libresolv.a,
then you need to compile Emacs to use that library. The easiest way to
do this is to add to config.h a definition of LIBS_SYSTEM, LIBS_MACHINE
or LIB_STANDARD which uses -lresolv. Watch out! If you redefine a macro
that is already in use in your configuration to supply some other libraries,
be careful not to lose the others.
Thus, you could start by adding this to config.h:
#define LIBS_SYSTEM -lresolv
Then if this gives you an error for redefining a macro, and you see that
config.h already defines LIBS_SYSTEM as -lfoo -lbar at some other point
(possibly in an included file) you could change it to say this:
#define LIBS_SYSTEM -lresolv -lfoo -lbar
then you need to compile Emacs to use that library.
*** Emacs does not know your host's fully-qualified domain name.
......@@ -3179,25 +3165,6 @@ as a concentrator.
This problem seems to be a matter of configuring the DECserver to use
7 bit characters rather than 8 bit characters.
* Build problems on legacy systems
** SunOS: Emacs gets error message from linker on Sun.
If the error message says that a symbol such as `f68881_used' or
`ffpa_used' or `start_float' is undefined, this probably indicates
that you have compiled some libraries, such as the X libraries,
with a floating point option other than the default.
It's not terribly hard to make this work with small changes in
crt0.c together with linking with Fcrt1.o, Wcrt1.o or Mcrt1.o.
However, the easiest approach is to build Xlib with the default
floating point option: -fsoft.
** HPUX 10.20: Emacs crashes during dumping on the HPPA machine.
This seems to be due to a GCC bug; it is fixed in GCC 2.8.1.
This file is part of GNU Emacs.
......
2013-02-25 Paul Eggert <eggert@cs.ucla.edu>
Simplify data_start configuration (Bug#13783).
This is a followon simplification to the fix for Bug#13650.
* 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).
* autodeps.mk (ALLOBJS): Move to Makefile.in.
* deps.mk (vm-limit.o):
* makefile.w32-in ($(BLD)/vm-limit.$(O)):
Do not depend on mem-limits.h.
* emacs.c (__do_global_ctors, __do_global_ctors_aux)
(__do_global_dtors, __CTOR_LIST__, __DTOR_LIST__)
[__GNUC__ && !ORDINARY_LINK]: Remove.
* mem-limits.h, pre-crt0.c: Remove.
* unexaix.c, unexcoff.c: Don't include mem-limits.h.
* unexcoff.c (etext): New decl.
(make_hdr): Use DATA_START instead of start_of_data.
* 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.
2013-02-24 Andreas Schwab <schwab@linux-m68k.org>
* xdisp.c (set_message): Only check for debug-on-message if STRING
......
......@@ -36,7 +36,6 @@ WINDRES = @WINDRES@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LD_FIRSTFLAG=@LD_FIRSTFLAG@
EXEEXT = @EXEEXT@
version = @version@
# Substitute an assignment for the MAKE variable, because
......@@ -102,10 +101,8 @@ LD_SWITCH_X_SITE_RPATH=@LD_SWITCH_X_SITE_RPATH@
## System-specific LDFLAGS.
LD_SWITCH_SYSTEM=@LD_SWITCH_SYSTEM@
## This holds any special options for linking temacs only (ie, not
## used by configure). Not used elsewhere because it sometimes
## contains options that have to do with using Emacs's crt0,
## which are only good with temacs.
## This holds any special options for linking temacs only (i.e., not
## used by configure).
LD_SWITCH_SYSTEM_TEMACS=@LD_SWITCH_SYSTEM_TEMACS@
## Flags to pass to ld only for temacs.
......@@ -120,14 +117,6 @@ PAXCTL = @PAXCTL@
## Some systems define this to request special libraries.
LIBS_SYSTEM=@LIBS_SYSTEM@
## Where to find libgcc.a, if using gcc and necessary.
LIB_GCC=@LIB_GCC@
CRT_DIR=@CRT_DIR@
## May use $CRT_DIR.
LIB_STANDARD=@LIB_STANDARD@
START_FILES = @START_FILES@
## -lm, or empty.
LIB_MATH=@LIB_MATH@
......@@ -389,17 +378,16 @@ POST_ALLOC_OBJ=@POST_ALLOC_OBJ@
## List of object files that make-docfile should not be told about.
otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
$(POST_ALLOC_OBJ) $(VMLIMIT_OBJ) $(WIDGET_OBJ) $(LIBOBJS)
$(POST_ALLOC_OBJ) $(WIDGET_OBJ) $(LIBOBJS)
## All object files linked into temacs. $(VMLIMIT_OBJ) should be first.
ALLOBJS = $(VMLIMIT_OBJ) $(obj) $(otherobj)
## Configure inserts the file lisp.mk at this point, defining $lisp.
@lisp_frag@
## Construct full set of libraries to be linked.
## Note that SunOS needs -lm to come before -lc; otherwise, you get
## duplicated symbols. If the standard libraries were compiled
## with GCC, we might need LIB_GCC again after them.
LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
$(LIBX_OTHER) $(LIBSOUND) \
$(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \
......@@ -409,7 +397,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
$(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
$(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
$(LIBACL_LIBS) $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \
$(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC)
$(LIB_MATH)
all: emacs$(EXEEXT) $(OTHER_FILES)
.PHONY: all
......@@ -456,7 +444,7 @@ $(libsrc)/make-docfile$(EXEEXT):
cd $(libsrc); $(MAKE) $(MFLAGS) make-docfile$(EXEEXT)
buildobj.h: Makefile
echo "#define BUILDOBJ \"$(obj) $(otherobj) " "\"" > buildobj.h
echo "#define BUILDOBJ \"$(ALLOBJS) " "\"" >$@
globals.h: gl-stamp; @true
......@@ -468,15 +456,15 @@ gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES)
$(srcdir)/../build-aux/move-if-change gl-tmp globals.h
echo timestamp > $@
$(obj) $(otherobj): globals.h
$(ALLOBJS): globals.h
$(lib)/libgnu.a: $(config_h)
cd $(lib) && $(MAKE) libgnu.a
temacs$(EXEEXT): $(START_FILES) stamp-oldxmenu $(obj) $(otherobj) \
temacs$(EXEEXT): stamp-oldxmenu $(ALLOBJS) \
$(lib)/libgnu.a $(W32_RES)
$(CC) $(LD_FIRSTFLAG) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
-o temacs $(START_FILES) $(obj) $(otherobj) $(lib)/libgnu.a $(LIBES) \
$(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
-o temacs $(ALLOBJS) $(lib)/libgnu.a $(LIBES) \
$(W32_RES_LINK)
test "$(CANNOT_DUMP)" = "yes" || \
test "X$(PAXCTL)" = X || $(PAXCTL) -r temacs$(EXEEXT)
......
......@@ -2,5 +2,4 @@
## This is inserted in src/Makefile if AUTO_DEPEND=yes.
ALLOBJS=$(START_FILES) ${obj} ${otherobj}
-include $(ALLOBJS:%.o=${DEPDIR}/%.d)
......@@ -144,7 +144,7 @@ macros.o: macros.c window.h buffer.h commands.h macros.h keyboard.h msdos.h \
dispextern.h lisp.h globals.h $(config_h) systime.h coding.h composite.h
gmalloc.o: gmalloc.c $(config_h)
ralloc.o: ralloc.c lisp.h $(config_h)
vm-limit.o: vm-limit.c mem-limits.h lisp.h globals.h $(config_h)
vm-limit.o: vm-limit.c lisp.h globals.h $(config_h)
marker.o: marker.c buffer.h character.h lisp.h globals.h $(config_h)
minibuf.o: minibuf.c syntax.h frame.h window.h keyboard.h systime.h \
buffer.h commands.h character.h msdos.h $(INTERVALS_H) keymap.h \
......
......@@ -521,32 +521,6 @@ DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory,
static char const dump_tz[] = "UtC0";
#endif
#ifndef ORDINARY_LINK
/* We don't include crtbegin.o and crtend.o in the link,
so these functions and variables might be missed.
Provide dummy definitions to avoid error.
(We don't have any real constructors or destructors.) */
#ifdef __GNUC__
/* Define a dummy function F. Declare F too, to pacify gcc
-Wmissing-prototypes. */
#define DEFINE_DUMMY_FUNCTION(f) \
void f (void) ATTRIBUTE_CONST EXTERNALLY_VISIBLE; void f (void) {}
#ifndef GCC_CTORS_IN_LIBC
DEFINE_DUMMY_FUNCTION (__do_global_ctors)
DEFINE_DUMMY_FUNCTION (__do_global_ctors_aux)
DEFINE_DUMMY_FUNCTION (__do_global_dtors)
/* GNU/Linux has a bug in its library; avoid an error. */
#ifndef GNU_LINUX
char * __CTOR_LIST__[2] EXTERNALLY_VISIBLE = { (char *) (-1), 0 };
#endif
char * __DTOR_LIST__[2] EXTERNALLY_VISIBLE = { (char *) (-1), 0 };
#endif /* GCC_CTORS_IN_LIBC */
DEFINE_DUMMY_FUNCTION (__main)
#endif /* __GNUC__ */
#endif /* ORDINARY_LINK */
/* Test whether the next argument in ARGV matches SSTR or a prefix of
LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
(the argument is supposed to have a value) store in *VALPTR either
......
......@@ -1492,7 +1492,6 @@ $(BLD)/unexw32.$(O) : \
$(BLD)/vm-limit.$(O) : \
$(SRC)/vm-limit.c \
$(SRC)/mem-limits.h \
$(SRC)/w32heap.h \
$(NT_INC)/unistd.h \
$(CONFIG_H) \
......
/* Includes for memory limit warnings.
Copyright (C) 1990, 1993-1996, 2001-2013 Free Software Foundation,
Inc.
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifdef MSDOS
#include <dpmi.h>
extern int etext;
#endif
/* Some systems need this before <sys/resource.h>. */
#include <sys/types.h>
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/time.h>
# include <sys/resource.h>
#else
# if HAVE_SYS_VLIMIT_H
# include <sys/vlimit.h> /* Obsolete, says glibc */
# endif
#endif
extern char *start_of_data (void) ATTRIBUTE_CONST;
#if USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX
#define EXCEEDS_LISP_PTR(ptr) 0
#else
#define EXCEEDS_LISP_PTR(ptr) \
(((uintptr_t) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
#endif
/* This file is loaded before crt0.o on machines where we do not
remap part of the data space into text space in unexec.
On these machines, there is no problem with standard crt0.o's
that make environ an initialized variable. However, we do
need to make sure the label data_start exists anyway. */
/* Create a label to appear at the beginning of data space.
Its value is nonzero so that it cannot be put into bss. */
int data_start = 1;
......@@ -59,8 +59,6 @@ what you give them. Help stamp out software-hoarding! */
#include <unistd.h>
#include <fcntl.h>
#include "mem-limits.h"
extern char _data[];
extern char _text[];
......
......@@ -99,7 +99,7 @@ struct aouthdr
#include <sys/file.h>
#include "mem-limits.h"
extern int etext;
static long block_copy_start; /* Old executable start point */
static struct filehdr f_hdr; /* File header */
......@@ -168,7 +168,7 @@ make_hdr (int new, int a_out,
pagemask = getpagesize () - 1;
/* Adjust text/data boundary. */
data_start = (int) start_of_data ();
data_start = (int) DATA_START;
data_start = ADDR_CORRECT (data_start);
data_start = data_start & ~pagemask; /* (Down) to page boundary. */
......
......@@ -19,7 +19,37 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <unistd.h> /* for 'environ', on AIX */
#include "lisp.h"
#include "mem-limits.h"
#ifdef MSDOS
#include <dpmi.h>
extern int etext;
#endif
/* Some systems need this before <sys/resource.h>. */
#include <sys/types.h>
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/time.h>
# include <sys/resource.h>
#else
# if HAVE_SYS_VLIMIT_H
# include <sys/vlimit.h> /* Obsolete, says glibc */
# endif
#endif
/* Start of data. It is OK if this is approximate; it's used only as
a heuristic. */
#ifdef DATA_START
# define data_start ((char *) DATA_START)
#else
extern char data_start[];
# ifndef HAVE_DATA_START
/* Initialize to nonzero, so that it's put into data and not bss.
Link this file's object code first, so that this symbol is near the
start of data. */
char data_start[1] = { 1 };
# endif
#endif
/*
Level number of warnings already issued.
......@@ -35,12 +65,20 @@ static enum warnlevel warnlevel;
0 means don't issue them. */
static void (*warn_function) (const char *);
/* Start of data space; can be changed by calling malloc_init. */
static void *data_space_start;
/* Start of data space; can be changed by calling memory_warnings. */
static char *data_space_start;
/* Number of bytes of writable memory we can expect to be able to get. */
static size_t lim_data;
/* Return true if PTR cannot be represented as an Emacs Lisp object. */
static bool
exceeds_lisp_ptr (void *ptr)
{
return (! USE_LSB_TAG
&& VAL_MAX < UINTPTR_MAX
&& ((uintptr_t) ptr & ~DATA_SEG_BITS) >> VALBITS != 0);
}
#ifdef HAVE_GETRLIMIT
......@@ -122,10 +160,12 @@ check_memory_limits (void)
{
#ifdef REL_ALLOC
extern void *(*real_morecore) (ptrdiff_t);
#else
void *(*real_morecore) (ptrdiff_t) = 0;
#endif
extern void *(*__morecore) (ptrdiff_t);
void *cp;
char *cp;
size_t five_percent;
size_t data_size;
enum warnlevel new_warnlevel;
......@@ -135,13 +175,8 @@ check_memory_limits (void)
five_percent = lim_data / 20;
/* Find current end of memory and issue warning if getting near max */
#ifdef REL_ALLOC
if (real_morecore)
cp = (char *) (*real_morecore) (0);
else
#endif
cp = (char *) (*__morecore) (0);
data_size = (char *) cp - (char *) data_space_start;
cp = (real_morecore ? real_morecore : __morecore) (0);
data_size = cp - data_space_start;
if (!warn_function)
return;
......@@ -188,49 +223,10 @@ check_memory_limits (void)
warnlevel = warned_85;
}
if (EXCEEDS_LISP_PTR (cp))
if (exceeds_lisp_ptr (cp))
(*warn_function) ("Warning: memory in use exceeds lisp pointer size");
}
#if !defined (CANNOT_DUMP) || !defined (SYSTEM_MALLOC)
/* Some systems that cannot dump also cannot implement these. */
/*
* Return the address of the start of the data segment prior to
* doing an unexec. After unexec the return value is undefined.
* See crt0.c for further information and definition of data_start.
*
* Apparently, on BSD systems this is etext at startup. On
* USG systems (swapping) this is highly mmu dependent and
* is also dependent on whether or not the program is running
* with shared text. Generally there is a (possibly large)
* gap between end of text and start of data with shared text.
*
*/
char *
start_of_data (void)
{
#ifdef BSD_SYSTEM
extern char etext;
return (void *) &etext;
#elif defined DATA_START
return (void *) DATA_START;
#elif defined ORDINARY_LINK
/*
* This is a hack. Since we're not linking crt0.c or pre_crt0.c,
* data_start isn't defined. We take the address of environ, which
* is known to live at or near the start of the system crt0.c, and
* we don't sweat the handful of bytes that might lose.
*/
return (void *) &environ;
#else
extern int data_start;
return (void *) &data_start;
#endif
}
#endif /* (not CANNOT_DUMP or not SYSTEM_MALLOC) */
/* Enable memory usage warnings.
START says where the end of pure storage is.
WARNFUN specifies the function to call to issue a warning. */
......@@ -240,10 +236,7 @@ memory_warnings (void *start, void (*warnfun) (const char *))
{
extern void (* __after_morecore_hook) (void); /* From gmalloc.c */
if (start)
data_space_start = start;
else
data_space_start = start_of_data ();
data_space_start = start ? start : data_start;
warn_function = warnfun;
__after_morecore_hook = check_memory_limits;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment