mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 06:20:23 +02:00
bump objcode version to 2.0; introduce minor-version compatibility
* libguile/_scm.h (SCM_OBJCODE_MAJOR_VERSION): Bump to 2. (SCM_OBJCODE_MINOR_VERSION): Reset to 0. (SCM_OBJCODE_MACHINE_VERSION_STRING, SCM_OBJCODE_COOKIE): Reorder so the minor version is the last byte. * libguile/objcodes.c (make_objcode_by_mmap): Accept objcodes whose minor version is less than SCM_OBJCODE_MINOR_VERSION, not just equal to.
This commit is contained in:
parent
333a81ccba
commit
e8ab529d57
2 changed files with 22 additions and 6 deletions
|
@ -3,7 +3,7 @@
|
|||
#ifndef SCM__SCM_H
|
||||
#define SCM__SCM_H
|
||||
|
||||
/* Copyright (C) 1995,1996,2000,2001, 2002, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995,1996,2000,2001, 2002, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
|
@ -205,8 +205,8 @@
|
|||
#define SCM_OBJCODE_WORD_SIZE SCM_CPP_STRINGIFY (SIZEOF_VOID_P)
|
||||
|
||||
/* Major and minor versions must be single characters. */
|
||||
#define SCM_OBJCODE_MAJOR_VERSION 0
|
||||
#define SCM_OBJCODE_MINOR_VERSION T
|
||||
#define SCM_OBJCODE_MAJOR_VERSION 2
|
||||
#define SCM_OBJCODE_MINOR_VERSION 0
|
||||
#define SCM_OBJCODE_MAJOR_VERSION_STRING \
|
||||
SCM_CPP_STRINGIFY(SCM_OBJCODE_MAJOR_VERSION)
|
||||
#define SCM_OBJCODE_MINOR_VERSION_STRING \
|
||||
|
@ -214,11 +214,11 @@
|
|||
#define SCM_OBJCODE_VERSION_STRING \
|
||||
SCM_OBJCODE_MAJOR_VERSION_STRING "." SCM_OBJCODE_MINOR_VERSION_STRING
|
||||
#define SCM_OBJCODE_MACHINE_VERSION_STRING \
|
||||
SCM_OBJCODE_VERSION_STRING "-" SCM_OBJCODE_ENDIANNESS "-" SCM_OBJCODE_WORD_SIZE
|
||||
SCM_OBJCODE_ENDIANNESS "-" SCM_OBJCODE_WORD_SIZE "-" SCM_OBJCODE_VERSION_STRING
|
||||
|
||||
/* The objcode magic header. */
|
||||
#define SCM_OBJCODE_COOKIE \
|
||||
"GOOF-" SCM_OBJCODE_MACHINE_VERSION_STRING "---"
|
||||
"GOOF----" SCM_OBJCODE_MACHINE_VERSION_STRING
|
||||
|
||||
#endif /* SCM__SCM_H */
|
||||
|
||||
|
|
|
@ -77,7 +77,13 @@ make_objcode_by_mmap (int fd)
|
|||
SCM_SYSERROR;
|
||||
}
|
||||
|
||||
if (memcmp (addr, SCM_OBJCODE_COOKIE, strlen (SCM_OBJCODE_COOKIE)))
|
||||
/* The cookie ends with a version of the form M.N, where M is the
|
||||
major version and N is the minor version. For this Guile to be
|
||||
able to load an objcode, M must be SCM_OBJCODE_MAJOR_VERSION, and N
|
||||
must be less than or equal to SCM_OBJCODE_MINOR_VERSION. Since N
|
||||
is the last character, we do a strict comparison on all but the
|
||||
last, then a <= on the last one. */
|
||||
if (memcmp (addr, SCM_OBJCODE_COOKIE, strlen (SCM_OBJCODE_COOKIE) - 1))
|
||||
{
|
||||
SCM args = scm_list_1 (scm_from_latin1_stringn
|
||||
(addr, strlen (SCM_OBJCODE_COOKIE)));
|
||||
|
@ -86,6 +92,16 @@ make_objcode_by_mmap (int fd)
|
|||
scm_misc_error (FUNC_NAME, "bad header on object file: ~s", args);
|
||||
}
|
||||
|
||||
{
|
||||
char minor_version = addr[strlen (SCM_OBJCODE_COOKIE) - 1];
|
||||
|
||||
if (minor_version > SCM_OBJCODE_MINOR_VERSION_STRING[0])
|
||||
scm_misc_error (FUNC_NAME, "objcode minor version too new (~a > ~a)",
|
||||
scm_list_2 (scm_from_latin1_stringn (&minor_version, 1),
|
||||
scm_from_latin1_string
|
||||
(SCM_OBJCODE_MINOR_VERSION_STRING)));
|
||||
}
|
||||
|
||||
data = (struct scm_objcode*)(addr + strlen (SCM_OBJCODE_COOKIE));
|
||||
|
||||
if (data->len + data->metalen != (st.st_size - sizeof (*data) - strlen (SCM_OBJCODE_COOKIE)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue