Thanks to Anton Kovalenko for implementation suggestions.
;;;; -*- coding: utf-8; fill-column: 78 -*-
changes relative to sbcl-1.0.50:
* enhancement: ASDF has been updated to version 2.017.
+ * enhancement: the --core command line option now accepts binaries with
+ an embedded core.
* optimization: SLEEP no longer conses.
* optimization: *PRINT-PRETTY* no longer slows down printing of strings
or bit-vectors when using the standard pretty-print dispatch table.
if ((fd = open_binary(filename, O_RDONLY)) < 0)
goto lose;
+
+ if (read(fd, &header, (size_t)lispobj_size) < lispobj_size)
+ goto lose;
+ if (header == CORE_MAGIC) {
+ /* This file is a real core, not an embedded core. Return 0 to
+ * indicate where the core starts, and do not look for runtime
+ * options in this case. */
+ return 0;
+ }
+
if (lseek(fd, -lispobj_size, SEEK_END) < 0)
goto lose;
if (read(fd, &header, (size_t)lispobj_size) < lispobj_size)
fflush(stdout);
}
+ if (embedded_core_offset == 0) {
+ /* Here we make a last attempt at recognizing an embedded core,
+ * so that a file with an embedded core is a valid argument to
+ * --core. We take care that any decisions on special behaviour
+ * (suppressed banner, embedded options) have already been made
+ * before we reach this block, so that there is no observable
+ * difference between "embedded" and "bare" images given to
+ * --core. */
+ os_vm_offset_t offset = search_for_embedded_core(core);
+ if (offset != -1)
+ embedded_core_offset = offset;
+ }
+
#if defined(SVR4) || defined(__linux__) || defined(__NetBSD__)
tzset();
#endif