From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Wolfgang Jenkner Newsgroups: gmane.emacs.bugs Subject: bug#22086: 25.1.50; [PATCH] Integrate the musl hybrid malloc patch for elf systems Date: Thu, 03 Dec 2015 18:57:47 +0100 Message-ID: <85poynxvgy.fsf@iznogoud.viz> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1449165761 5089 80.91.229.3 (3 Dec 2015 18:02:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 3 Dec 2015 18:02:41 +0000 (UTC) Cc: Rich Felker To: 22086@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 03 19:02:27 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a4YCx-0006k6-42 for geb-bug-gnu-emacs@m.gmane.org; Thu, 03 Dec 2015 19:02:19 +0100 Original-Received: from localhost ([::1]:36770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4YCw-0005em-Ex for geb-bug-gnu-emacs@m.gmane.org; Thu, 03 Dec 2015 13:02:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4YCk-0005dO-BL for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2015 13:02:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4YCg-0001Vv-QU for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2015 13:02:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48029) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4YCg-0001Vo-Ni for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2015 13:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1a4YCg-0001vl-CP; Thu, 03 Dec 2015 13:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Wolfgang Jenkner Original-Sender: "Debbugs-submit" Resent-CC: dalias@libc.org, bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Dec 2015 18:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22086 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Rich Felker Original-Received: via spool by submit@debbugs.gnu.org id=B.14491656987388 (code B ref -1); Thu, 03 Dec 2015 18:02:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Dec 2015 18:01:38 +0000 Original-Received: from localhost ([127.0.0.1]:37737 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a4YCG-0001v3-RL for submit@debbugs.gnu.org; Thu, 03 Dec 2015 13:01:38 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:34697) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a4YCD-0001us-KT for submit@debbugs.gnu.org; Thu, 03 Dec 2015 13:01:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4YC9-00018u-Sz for submit@debbugs.gnu.org; Thu, 03 Dec 2015 13:01:33 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:48449) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4YC9-00018m-QL for submit@debbugs.gnu.org; Thu, 03 Dec 2015 13:01:29 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4YC4-0005Ry-BI for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2015 13:01:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4YC0-00010m-TM for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2015 13:01:24 -0500 Original-Received: from b2bfep14.mx.upcmail.net ([62.179.121.59]:34659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4YC0-0000zl-9N for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2015 13:01:20 -0500 Original-Received: from edge12.upcmail.net ([192.168.13.82]) by b2bfep14.mx.upcmail.net (InterMail vM.8.01.05.18 201-2260-151-151-20140610) with ESMTP id <20151203180118.LTIZ18499.b2bfep14-int.chello.at@edge12.upcmail.net> for ; Thu, 3 Dec 2015 19:01:18 +0100 Original-Received: from iznogoud.viz ([91.119.234.240]) by edge12.upcmail.net with edge id p61H1r00j5BsVPf0C61J8V; Thu, 03 Dec 2015 19:01:18 +0100 X-SourceIP: 91.119.234.240 Original-Received: from wolfgang by iznogoud.viz with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1a4YBx-0000W0-MF for bug-gnu-emacs@gnu.org; Thu, 03 Dec 2015 19:01:17 +0100 User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.1.50 (berkeley-unix) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:109564 Archived-At: --=-=-= Content-Type: text/plain In the thread around http://permalink.gmane.org/gmane.emacs.devel/182469 Rich Felker announced that he had found that a small addition to unexelf.c allowed emacs to extend its hybrid malloc implementation (previously only used for cygwin) to musl libc, but without using features specific to that malloc implementation. A corresponding patch was tested in the "Alpine Linux" distribution, see http://git.alpinelinux.org/cgit/aports/plain/testing/emacs/musl.patch?id=d6f211ec868df4657c745b8ba2bae77b2a7fb7f6 This patch series proposes the relevant part of that change and adds some (rather trivial) groundwork to make it reliably work on all systems which use unexelf.c for dumping. Personally, I've been using hybrid malloc on top of the libc malloc (jemalloc) on FreeBSD 10 for several months now without problems. I also tested it with other malloc libraries, in particular some of those derived from Doug Lea's malloc. It also works on GNU/Linux, on top of glibc. This might be of some interest as, IIRC, some glibc people were not too happy about keeping malloc_get_state and stuff. If you get an error about exceeding "static heap size" during dumping just bump STATIC_HEAP_SIZE in src/sheap.c a bit. If the commit messages in the following patches don't explain enough, please ask. Also, please apply the patch from http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22085 beforehand. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-For-HYBRID_MALLOC-give-most-gmalloc-symbols-internal.patch Content-Description: Keep gmalloc symbols internal >From 0ee89d5aa9eae1bf72e5cc715d8b2e3afce37703 Mon Sep 17 00:00:00 2001 From: Wolfgang Jenkner Date: Sun, 29 Nov 2015 17:39:56 +0100 Subject: [PATCH 2/5] For HYBRID_MALLOC, give most gmalloc symbols internal linkage. This avoids clashes with symbols if the after-dump malloc is derived from Doug Lea's implementation. * src/gmalloc.c (emacs_abort, __morecore, __default_morecore): Move declarations up. For HYBRID_MALLOC, turn all `extern' declarations below to `static' ones. (aligned_alloc): Declare for !MSDOS as well. (heapsize, _fraghead): Move resp. copy declaration downwards. For HYBRID_MALLOC, conditionalize out the other definitions, since the previous `static' declarations double as tentative definitions, anyway. (_malloc, _free, _realloc, __free_hook, _aligned_blocks) (__realloc_hook, __memalign_hook): Conditionalize out. (cfree, memalign, valloc): Ditto. --- src/gmalloc.c | 58 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/src/gmalloc.c b/src/gmalloc.c index 90a52a1..240408e 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -87,6 +87,20 @@ extern "C" #include +#ifdef emacs +extern void emacs_abort (void); +#endif + +/* Underlying allocation function; successive calls should + return contiguous pieces of memory. */ +extern void *(*__morecore) (ptrdiff_t size); + +/* Default value of `__morecore'. */ +extern void *__default_morecore (ptrdiff_t size); + +#ifdef HYBRID_MALLOC +#define extern static +#endif /* Allocate SIZE bytes of memory. */ extern void *malloc (size_t size) ATTRIBUTE_MALLOC_SIZE ((1)); @@ -99,8 +113,8 @@ extern void *calloc (size_t nmemb, size_t size) ATTRIBUTE_MALLOC_SIZE ((1,2)); extern void free (void *ptr); /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ -#ifdef MSDOS extern void *aligned_alloc (size_t, size_t); +#ifdef MSDOS extern void *memalign (size_t, size_t); extern int posix_memalign (void **, size_t, size_t); #endif @@ -110,10 +124,6 @@ extern int posix_memalign (void **, size_t, size_t); extern void malloc_enable_thread (void); #endif -#ifdef emacs -extern void emacs_abort (void); -#endif - /* The allocator divides the heap into blocks of fixed size; large requests receive one or more whole blocks, and small requests receive a fragment of a block. Fragment sizes are powers of two, @@ -249,13 +259,6 @@ extern int _malloc_thread_enabled_p; return the address of the beginning of the object. */ extern void *malloc_find_object_address (void *ptr); -/* Underlying allocation function; successive calls should - return contiguous pieces of memory. */ -extern void *(*__morecore) (ptrdiff_t size); - -/* Default value of `__morecore'. */ -extern void *__default_morecore (ptrdiff_t size); - /* If not NULL, this function is called after each time `__morecore' is called to increase the data size. */ extern void (*__after_morecore_hook) (void); @@ -318,6 +321,8 @@ extern struct mstats mstats (void); /* Call WARNFUN with a warning message when memory usage is high. */ extern void memory_warnings (void *start, void (*warnfun) (const char *)); +#undef extern + #ifdef __cplusplus } #endif @@ -346,6 +351,8 @@ License along with this library. If not, see . void *(*__morecore) (ptrdiff_t size) = __default_morecore; +#ifndef HYBRID_MALLOC + /* Debugging hook for `malloc'. */ void *(*__malloc_hook) (size_t size); @@ -355,9 +362,6 @@ char *_heapbase; /* Block information table. Allocated with align/__free (not malloc/free). */ malloc_info *_heapinfo; -/* Number of info entries. */ -static size_t heapsize; - /* Search index in the info table. */ size_t _heapindex; @@ -381,6 +385,15 @@ size_t __malloc_extra_blocks; void (*__malloc_initialize_hook) (void); void (*__after_morecore_hook) (void); +#else + +static struct list _fraghead[BLOCKLOG]; + +#endif /* HYBRID_MALLOC */ + +/* Number of info entries. */ +static size_t heapsize; + #if defined GC_MALLOC_CHECK && defined GC_PROTECT_MALLOC_STATE /* Some code for hunting a bug writing into _heapinfo. @@ -946,7 +959,7 @@ malloc (size_t size) return (hook != NULL ? *hook : _malloc_internal) (size); } -#ifndef _LIBC +#if !(defined (_LIBC) || defined (HYBRID_MALLOC)) /* On some ANSI C systems, some libc functions call _malloc, _free and _realloc. Make them use the GNU functions. */ @@ -995,11 +1008,13 @@ License along with this library. If not, see . or (US mail) as Mike Haertel c/o Free Software Foundation. */ +#ifndef HYBRID_MALLOC /* Debugging hook for free. */ void (*__free_hook) (void *__ptr); /* List of blocks allocated by aligned_alloc. */ struct alignlist *_aligned_blocks = NULL; +#endif /* Return memory to the heap. Like `_free_internal' but don't lock mutex. */ @@ -1270,6 +1285,7 @@ free (void *ptr) _free_internal (ptr); } +#ifndef HYBRID_MALLOC /* Define the `cfree' alias for `free'. */ #ifdef weak_alias weak_alias (free, cfree) @@ -1280,6 +1296,7 @@ cfree (void *ptr) free (ptr); } #endif +#endif /* Change the size of a block allocated by `malloc'. Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. @@ -1304,8 +1321,10 @@ License along with this library. If not, see . #define min(a, b) ((a) < (b) ? (a) : (b)) #endif +#ifndef HYBRID_MALLOC /* Debugging hook for realloc. */ void *(*__realloc_hook) (void *ptr, size_t size); +#endif /* Resize the given region to the new size, returning a pointer to the (possibly moved) region. This is optimized for speed; @@ -1549,7 +1568,9 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this library. If not, see . */ +#ifndef HYBRID_MALLOC void *(*__memalign_hook) (size_t size, size_t alignment); +#endif void * aligned_alloc (size_t alignment, size_t size) @@ -1638,6 +1659,8 @@ aligned_alloc (size_t alignment, size_t size) return result; } +/* Note that memalign and posix_memalign are not used in Emacs. */ +#ifndef HYBRID_MALLOC /* An obsolete alias for aligned_alloc, for any old libraries that use this alias. */ @@ -1649,7 +1672,6 @@ memalign (size_t alignment, size_t size) /* If HYBRID_MALLOC is defined, we may want to use the system posix_memalign below. */ -#ifndef HYBRID_MALLOC int posix_memalign (void **memptr, size_t alignment, size_t size) { @@ -1689,6 +1711,7 @@ License along with this library. If not, see . The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ +#ifndef HYBRID_MALLOC /* Allocate SIZE bytes on a page boundary. */ extern void *valloc (size_t); @@ -1708,6 +1731,7 @@ valloc (size_t size) return aligned_alloc (pagesize, size); } +#endif /* HYBRID_MALLOC */ #undef malloc #undef realloc -- 2.6.3 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-Link-temacs-with-gnulib-objects-compiled-with-Demacs.patch Content-Description: Compile separate gnulib.a for emacs with -Demacs >From 9610f313480b8e0da810c38aee0fbc07c88b0904 Mon Sep 17 00:00:00 2001 From: Wolfgang Jenkner Date: Sun, 22 Feb 2015 04:15:34 +0100 Subject: [PATCH 3/5] Link temacs with gnulib objects compiled with -Demacs. * lib/Makefile.am: Add incantation to install libegnu.a. * src/Makefile.in ($(lib)/libgnu.a): Replace with libegnu.a (temacs$(EXEEXT)): Use it. This is done to support HYBRID_MALLOC, since some static variables (e.g., last_environ in putenv.c) hold pointers to memory malloced before dumping. --- lib/Makefile.am | 9 +++++++++ src/Makefile.in | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Makefile.am b/lib/Makefile.am index cda9681..a1dd6a4 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -17,6 +17,15 @@ include gnulib.mk libgnu_a_SOURCES += openat-die.c save-cwd.c endif +noinst_LIBRARIES += libegnu.a + +libegnu_a_SOURCES = $(libgnu_a_SOURCES) +libegnu_a_LIBADD = $(patsubst %.o,e-%.o,$(libgnu_a_LIBADD)) +EXTRA_libegnu_a_SOURCES = $(EXTRA_libgnu_a_SOURCES) +libegnu_a_SHORTNAME = e + +libegnu_a_CPPFLAGS = $(AM_CPPFLAGS) -Demacs + .PHONY: bootstrap-clean bootstrap-clean: maintainer-clean diff --git a/src/Makefile.in b/src/Makefile.in index d7ad395..f1d780f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -557,7 +557,7 @@ globals.h: gl-stamp; @true $(ALLOBJS): globals.h -$(lib)/libgnu.a: $(config_h) +$(lib)/libegnu.a: $(config_h) $(MAKE) -C $(lib) all ## We have to create $(etc) here because init_cmdargs tests its @@ -565,9 +565,9 @@ $(lib)/libgnu.a: $(config_h) ## This goes on to affect various things, and the emacs binary fails ## to start if Vinstallation_directory has the wrong value. temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) \ - $(lib)/libgnu.a $(EMACSRES) ${charsets} ${charscript} + $(lib)/libegnu.a $(EMACSRES) ${charsets} ${charscript} $(AM_V_CCLD)$(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \ - -o temacs $(ALLOBJS) $(lib)/libgnu.a $(W32_RES_LINK) $(LIBES) + -o temacs $(ALLOBJS) $(lib)/libegnu.a $(W32_RES_LINK) $(LIBES) $(MKDIR_P) $(etc) ifneq ($(CANNOT_DUMP),yes) $(PAXCTL_if_present) -r $@ -- 2.6.3 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0004-Add-musl-patch-to-support-HYBRID_MALLOC-on-elf-syste.patch Content-Description: The patch from musl, essentially >From f65fff5bb5f2f2eee3b258538f1abb70eeb911c6 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 22 Feb 2015 04:25:03 +0100 Subject: [PATCH 4/5] Add musl patch to support HYBRID_MALLOC on elf systems. * src/unexelf.c (unexec): Define bss_sbrk_did_unexec. * src/gmalloc.c: Adjust for HYBRID_MALLOC in the non CYGWIN case. (__default_morecore): Here, in particular. * configure.ac: Define HYBRID_MALLOC when unexelf.o is used. New variable SHEAP_OBJ. * src/Makefile.in: Use it. Except for build system fixes this is essentially the same as http://git.alpinelinux.org/cgit/aports/tree/testing/emacs/musl.patch?id=d6f211ec868df4657c745b8ba2bae77b2a7fb7f6 The original patch contains one unrelated hunk, which will be committed separately. --- configure.ac | 12 ++++++++++-- src/Makefile.in | 6 +++++- src/gmalloc.c | 4 ++-- src/unexelf.c | 5 +++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 63e354e..56e2f12 100644 --- a/configure.ac +++ b/configure.ac @@ -2117,7 +2117,13 @@ case "$opsys" in cygwin) hybrid_malloc=yes;; esac +if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \ + && test "${UNEXEC_OBJ}" = unexelf.o && test "${hybrid_malloc}" != no; then + hybrid_malloc=yes +fi + GMALLOC_OBJ= +SHEAP_OBJ= if test "${system_malloc}" = "yes"; then AC_DEFINE([SYSTEM_MALLOC], 1, [Define to 1 to use the system memory allocator, even if it is not @@ -2132,6 +2138,7 @@ elif test "$hybrid_malloc" = yes; then GNU_MALLOC= GNU_MALLOC_reason="only before dumping" GMALLOC_OBJ=gmalloc.o + SHEAP_OBJ=sheap.o VMLIMIT_OBJ= else test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o @@ -2152,9 +2159,10 @@ else fi fi AC_SUBST(GMALLOC_OBJ) +AC_SUBST(SHEAP_OBJ) AC_SUBST(VMLIMIT_OBJ) -if test "$doug_lea_malloc" = "yes" ; then +if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then if test "$GNU_MALLOC" = yes ; then GNU_MALLOC_reason=" (Using Doug Lea's new malloc from the GNU C Library.)" @@ -4970,7 +4978,7 @@ fi AC_SUBST(RALLOC_OBJ) if test "$opsys" = "cygwin"; then - CYGWIN_OBJ="sheap.o cygw32.o" + CYGWIN_OBJ="cygw32.o" ## Cygwin differs because of its unexec(). PRE_ALLOC_OBJ= POST_ALLOC_OBJ=lastfile.o diff --git a/src/Makefile.in b/src/Makefile.in index f1d780f..ece8858 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -243,7 +243,10 @@ XFIXES_CFLAGS = @XFIXES_CFLAGS@ ## widget.o if USE_X_TOOLKIT, otherwise empty. WIDGET_OBJ=@WIDGET_OBJ@ -## sheap.o if CYGWIN, otherwise empty. +## sheap.o if HYBRID_MALLOC, otherwise empty. +SHEAP_OBJ=@SHEAP_OBJ@ + +## cygw32.o if CYGWIN, otherwise empty. CYGWIN_OBJ=@CYGWIN_OBJ@ ## fontset.o fringe.o image.o if we have any window system @@ -384,6 +387,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ region-cache.o sound.o atimer.o \ doprnt.o intervals.o textprop.o composite.o xml.o $(NOTIFY_OBJ) \ profiler.o decompress.o \ + $(SHEAP_OBJ) \ $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) obj = $(base_obj) $(NS_OBJC_OBJ) diff --git a/src/gmalloc.c b/src/gmalloc.c index 240408e..530b3b2 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -70,7 +70,7 @@ extern void emacs_abort (void); #define aligned_alloc galigned_alloc #define free gfree -#ifdef CYGWIN +#ifdef HYBRID_MALLOC extern void *bss_sbrk (ptrdiff_t size); extern int bss_sbrk_did_unexec; extern char bss_sbrk_buffer[]; @@ -1542,7 +1542,7 @@ void * __default_morecore (ptrdiff_t increment) { void *result; -#if defined (CYGWIN) +#ifdef HYBRID_MALLOC if (!DUMPED) { return bss_sbrk (increment); diff --git a/src/unexelf.c b/src/unexelf.c index c10c7f2..3d10aa0 100644 --- a/src/unexelf.c +++ b/src/unexelf.c @@ -227,6 +227,11 @@ unexec (const char *new_name, const char *old_name) off_t new_file_size; void *new_break; +#ifdef HYBRID_MALLOC + extern int bss_sbrk_did_unexec; + bss_sbrk_did_unexec = 1; +#endif + /* Pointers to the base of the image of the two files. */ caddr_t old_base, new_base; -- 2.6.3 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0005-configure.ac-Stop-using-mmap-for-buffers-for-FreeBSD.patch Content-Description: No special case for FreeBSD wrt mmap >From d042d56201d1ab00fcc405976954d0d0585c70bd Mon Sep 17 00:00:00 2001 From: Wolfgang Jenkner Date: Sun, 22 Feb 2015 04:26:36 +0100 Subject: [PATCH 5/5] * configure.ac: Stop using mmap for buffers for FreeBSD. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 56e2f12..af8de47 100644 --- a/configure.ac +++ b/configure.ac @@ -2186,7 +2186,7 @@ fi use_mmap_for_buffers=no case "$opsys" in - cygwin|mingw32|freebsd|irix6-5) use_mmap_for_buffers=yes ;; + cygwin|mingw32|irix6-5) use_mmap_for_buffers=yes ;; esac AC_FUNC_MMAP -- 2.6.3 --=-=-=--