Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/libelf/dist Centralize dependency on __FreeBSD_...



details:   https://anonhg.NetBSD.org/src/rev/fa57ef00047d
branches:  trunk
changeset: 750156:fa57ef00047d
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Dec 19 07:31:04 2009 +0000

description:
Centralize dependency on __FreeBSD_version into libelf.h, and generalize
the conditional inclusion of API/ELF features so that it works with NetBSD
as well.

diffstat:

 external/bsd/libelf/dist/elf_types.m4      |  57 +++++++++++++----------------
 external/bsd/libelf/dist/gelf.h            |  24 ++++++++---
 external/bsd/libelf/dist/gelf_cap.c        |   9 ++--
 external/bsd/libelf/dist/gelf_move.c       |   9 ++--
 external/bsd/libelf/dist/gelf_syminfo.c    |   9 ++--
 external/bsd/libelf/dist/libelf.h          |  28 +++++++++++++-
 external/bsd/libelf/dist/libelf_align.c    |  26 ++++++-------
 external/bsd/libelf/dist/libelf_convert.m4 |   8 ++--
 external/bsd/libelf/dist/libelf_data.c     |  13 ++++--
 external/bsd/libelf/dist/libelf_fsize.m4   |   4 +-
 external/bsd/libelf/dist/libelf_msize.m4   |   6 +-
 11 files changed, 109 insertions(+), 84 deletions(-)

diffs (truncated from 503 to 300 lines):

diff -r ee11ed25c828 -r fa57ef00047d external/bsd/libelf/dist/elf_types.m4
--- a/external/bsd/libelf/dist/elf_types.m4     Sat Dec 19 07:09:28 2009 +0000
+++ b/external/bsd/libelf/dist/elf_types.m4     Sat Dec 19 07:31:04 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elf_types.m4,v 1.1.1.1 2009/12/19 05:43:40 thorpej Exp $       */
+/*     $NetBSD: elf_types.m4,v 1.2 2009/12/19 07:31:04 thorpej Exp $   */
 
 /*-
  * Copyright (c) 2006 Joseph Koshy
@@ -31,41 +31,36 @@
 /*
  * ELF types, defined in the "enum Elf_Type" API.
  *
- * The members of the list form a 3-tuple: (name, C-type-suffix, OSversion).
+ * The members of the list form a 3-tuple: (name, C-type-suffix, condition).
  * + `name' is an Elf_Type symbol without the `ELF_T_' prefix.
  * + `C-type-suffix' is the suffix for Elf32_ and Elf64_ type names.
- * + `version' is the OS version the symbol first appeared in.
- *
- * OS revisions of note are:
- * 600102 - The earliest (6.0-STABLE) version supported by this code.
- * 700009 - Symbol versioning and ELF64 type changes.
- * 700025 - More ELF types and the introduction of libelf.
+ * + `condition' is the conditional check for this type.
  */
 
 define(`ELF_TYPE_LIST',
-       ``ADDR,         Addr,   600102',
-       `BYTE,          Byte,   600102',
-       `CAP,           Cap,    700025',
-       `DYN,           Dyn,    600102',
-       `EHDR,          Ehdr,   600102',
-       `HALF,          Half,   600102',
-       `LWORD,         Lword,  700025',
-       `MOVE,          Move,   700025',
-       `MOVEP,         MoveP,  700025',
-       `NOTE,          Note,   600102',
-       `OFF,           Off,    600102',
-       `PHDR,          Phdr,   600102',
-       `REL,           Rel,    600102',
-       `RELA,          Rela,   600102',
-       `SHDR,          Shdr,   600102',
-       `SWORD,         Sword,  600102',
-       `SXWORD,        Sxword, 700009',
-       `SYMINFO,       Syminfo, 700025',
-       `SYM,           Sym,    600102',
-       `VDEF,          Verdef, 700009',
-       `VNEED,         Verneed, 700009',
-       `WORD,          Word,   600102',
-       `XWORD,         Xword,  700009',
+       ``ADDR,         Addr,   1',
+       `BYTE,          Byte,   1',
+       `CAP,           Cap,    __LIBELF_HAVE_ELF_CAP',
+       `DYN,           Dyn,    1',
+       `EHDR,          Ehdr,   1',
+       `HALF,          Half,   1',
+       `LWORD,         Lword,  __LIBELF_HAVE_ELF_MOVE',
+       `MOVE,          Move,   __LIBELF_HAVE_ELF_MOVE',
+       `MOVEP,         MoveP,  __LIBELF_HAVE_ELF_MOVE',
+       `NOTE,          Note,   1',
+       `OFF,           Off,    1',
+       `PHDR,          Phdr,   1',
+       `REL,           Rel,    1',
+       `RELA,          Rela,   1',
+       `SHDR,          Shdr,   1',
+       `SWORD,         Sword,  1',
+       `SXWORD,        Sxword, __LIBELF_HAVE_ELF_VERS',
+       `SYMINFO,       Syminfo, __LIBELF_HAVE_ELF_SYMINFO',
+       `SYM,           Sym,    1',
+       `VDEF,          Verdef, __LIBELF_HAVE_ELF_VERS',
+       `VNEED,         Verneed, __LIBELF_HAVE_ELF_VERS',
+       `WORD,          Word,   1',
+       `XWORD,         Xword,  __LIBELF_HAVE_ELF_VERS',
        `NUM,           _,      _'')
 
 /*
diff -r ee11ed25c828 -r fa57ef00047d external/bsd/libelf/dist/gelf.h
--- a/external/bsd/libelf/dist/gelf.h   Sat Dec 19 07:09:28 2009 +0000
+++ b/external/bsd/libelf/dist/gelf.h   Sat Dec 19 07:31:04 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gelf.h,v 1.1.1.1 2009/12/19 05:43:40 thorpej Exp $     */
+/*     $NetBSD: gelf.h,v 1.2 2009/12/19 07:31:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Joseph Koshy
@@ -34,7 +34,6 @@
 #include <sys/cdefs.h>
 
 #include <libelf.h>
-#include <osreldate.h>
 
 typedef Elf64_Addr     GElf_Addr;      /* Addresses */
 typedef Elf64_Half     GElf_Half;      /* Half words (16 bit) */
@@ -52,9 +51,13 @@
 typedef Elf64_Rel      GElf_Rel;       /* Relocation entries */
 typedef Elf64_Rela     GElf_Rela;      /* Relocation entries with addend */
 
-#if    __FreeBSD_version >= 700025
+#if defined(__LIBELF_HAVE_ELF_CAP)
 typedef        Elf64_Cap       GElf_Cap;       /* SW/HW capabilities */
+#endif
+#if defined(__LIBELF_HAVE_ELF_MOVE)
 typedef Elf64_Move     GElf_Move;      /* Move entries */
+#endif
+#if defined(__LIBELF_HAVE_ELF_SYMINFO)
 typedef Elf64_Syminfo  GElf_Syminfo;   /* Symbol information */
 #endif
 
@@ -102,14 +105,21 @@
 Elf_Data       *gelf_xlatetof(Elf *_elf, Elf_Data *_dst, const Elf_Data *_src, unsigned int _encode);
 Elf_Data       *gelf_xlatetom(Elf *_elf, Elf_Data *_dst, const Elf_Data *_src, unsigned int _encode);
 
-#if    __FreeBSD_version >= 700025
+#if defined(__LIBELF_HAVE_ELF_CAP)
 GElf_Cap       *gelf_getcap(Elf_Data *_data, int _index, GElf_Cap *_cap);
+int            gelf_update_cap(Elf_Data *_dst, int _index, GElf_Cap *_src);
+#endif /* __LIBELF_HAVE_ELF_CAP */
+
+#if defined(__LIBELF_HAVE_ELF_MOVE)
 GElf_Move      *gelf_getmove(Elf_Data *_src, int _index, GElf_Move *_dst);
+int            gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+#endif /* __LIBELF_HAVE_ELF_MOVE */
+
+#if defined(__LIBELF_HAVE_ELF_SYMINFO)
 GElf_Syminfo   *gelf_getsyminfo(Elf_Data *_src, int _index, GElf_Syminfo *_dst);
-int            gelf_update_cap(Elf_Data *_dst, int _index, GElf_Cap *_src);
-int            gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
 int            gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
-#endif
+#endif /* __LIBELF_HAVE_ELF_SYMINFO */
+
 __END_DECLS
 
 #endif /* _GELF_H_ */
diff -r ee11ed25c828 -r fa57ef00047d external/bsd/libelf/dist/gelf_cap.c
--- a/external/bsd/libelf/dist/gelf_cap.c       Sat Dec 19 07:09:28 2009 +0000
+++ b/external/bsd/libelf/dist/gelf_cap.c       Sat Dec 19 07:31:04 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gelf_cap.c,v 1.2 2009/12/19 06:39:29 thorpej Exp $     */
+/*     $NetBSD: gelf_cap.c,v 1.3 2009/12/19 07:31:04 thorpej Exp $     */
 
 /*-
  * Copyright (c) 2006 Joseph Koshy
@@ -28,16 +28,15 @@
 
 #include <sys/cdefs.h>
 /* __FBSDID("$FreeBSD: src/lib/libelf/gelf_cap.c,v 1.2.10.1.2.1 2009/10/25 01:10:29 kensmith Exp $"); */
-__RCSID("$NetBSD: gelf_cap.c,v 1.2 2009/12/19 06:39:29 thorpej Exp $");
+__RCSID("$NetBSD: gelf_cap.c,v 1.3 2009/12/19 07:31:04 thorpej Exp $");
 
 #include <assert.h>
 #include <limits.h>
 #include <gelf.h>
-#include <osreldate.h>
 
 #include "_libelf.h"
 
-#if    __FreeBSD_version >= 700025
+#if defined(__LIBELF_HAVE_ELF_CAP)
 
 GElf_Cap *
 gelf_getcap(Elf_Data *d, int ndx, GElf_Cap *dst)
@@ -149,4 +148,4 @@
        return (1);
 }
 
-#endif /* __FreeBSD_version >= 700025 */
+#endif /* __LIBELF_HAVE_ELF_CAP */
diff -r ee11ed25c828 -r fa57ef00047d external/bsd/libelf/dist/gelf_move.c
--- a/external/bsd/libelf/dist/gelf_move.c      Sat Dec 19 07:09:28 2009 +0000
+++ b/external/bsd/libelf/dist/gelf_move.c      Sat Dec 19 07:31:04 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gelf_move.c,v 1.2 2009/12/19 06:39:29 thorpej Exp $    */
+/*     $NetBSD: gelf_move.c,v 1.3 2009/12/19 07:31:04 thorpej Exp $    */
 
 /*-
  * Copyright (c) 2006 Joseph Koshy
@@ -28,16 +28,15 @@
 
 #include <sys/cdefs.h>
 /* __FBSDID("$FreeBSD: src/lib/libelf/gelf_move.c,v 1.2.10.1.2.1 2009/10/25 01:10:29 kensmith Exp $"); */
-__RCSID("$NetBSD: gelf_move.c,v 1.2 2009/12/19 06:39:29 thorpej Exp $");
+__RCSID("$NetBSD: gelf_move.c,v 1.3 2009/12/19 07:31:04 thorpej Exp $");
 
 #include <assert.h>
 #include <limits.h>
 #include <gelf.h>
-#include <osreldate.h>
 
 #include "_libelf.h"
 
-#if    __FreeBSD_version >= 700025
+#if defined(__LIBELF_HAVE_ELF_MOVE)
 
 GElf_Move *
 gelf_getmove(Elf_Data *d, int ndx, GElf_Move *dst)
@@ -155,4 +154,4 @@
        return (1);
 }
 
-#endif /* __FreeBSD_version >= 700025 */
+#endif /* __LIBELF_HAVE_ELF_MOVE */
diff -r ee11ed25c828 -r fa57ef00047d external/bsd/libelf/dist/gelf_syminfo.c
--- a/external/bsd/libelf/dist/gelf_syminfo.c   Sat Dec 19 07:09:28 2009 +0000
+++ b/external/bsd/libelf/dist/gelf_syminfo.c   Sat Dec 19 07:31:04 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gelf_syminfo.c,v 1.2 2009/12/19 06:39:29 thorpej Exp $ */
+/*     $NetBSD: gelf_syminfo.c,v 1.3 2009/12/19 07:31:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Joseph Koshy
@@ -28,16 +28,15 @@
 
 #include <sys/cdefs.h>
 /* __FBSDID("$FreeBSD: src/lib/libelf/gelf_syminfo.c,v 1.2.10.1.2.1 2009/10/25 01:10:29 kensmith Exp $"); */
-__RCSID("$NetBSD: gelf_syminfo.c,v 1.2 2009/12/19 06:39:29 thorpej Exp $");
+__RCSID("$NetBSD: gelf_syminfo.c,v 1.3 2009/12/19 07:31:04 thorpej Exp $");
 
 #include <assert.h>
 #include <limits.h>
 #include <gelf.h>
-#include <osreldate.h>
 
 #include "_libelf.h"
 
-#if    __FreeBSD_version >= 700025
+#if defined(__LIBELF_HAVE_ELF_SYMINFO)
 
 GElf_Syminfo *
 gelf_getsyminfo(Elf_Data *d, int ndx, GElf_Syminfo *dst)
@@ -150,4 +149,4 @@
        return (1);
 }
 
-#endif /* __FreeBSD_version >= 700025 */
+#endif /* __LIBELF_HAVE_ELF_SYMINFO */
diff -r ee11ed25c828 -r fa57ef00047d external/bsd/libelf/dist/libelf.h
--- a/external/bsd/libelf/dist/libelf.h Sat Dec 19 07:09:28 2009 +0000
+++ b/external/bsd/libelf/dist/libelf.h Sat Dec 19 07:31:04 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libelf.h,v 1.1.1.1 2009/12/19 05:43:40 thorpej Exp $   */
+/*     $NetBSD: libelf.h,v 1.2 2009/12/19 07:31:04 thorpej Exp $       */
 
 /*-
  * Copyright (c) 2006 Joseph Koshy
@@ -32,10 +32,32 @@
 #define        _LIBELF_H_
 
 #include <sys/types.h>
-#include <sys/elf32.h>
-#include <sys/elf64.h>
 #include <sys/queue.h>
 
+#if defined(__NetBSD__)
+# include <sys/exec_elf.h>
+# define __LIBELF_HAVE_ELF_CAP         1
+# define __LIBELF_HAVE_ELF_MOVE                1
+# define __LIBELF_HAVE_ELF_NOTE                1
+/* # define __LIBELF_HAVE_ELF_SYMINFO  1 */
+# define __LIBELF_HAVE_ELF_VERS                1
+#endif /* __NetBSD__ */
+
+#if defined(__FreeBSD__)
+# include <sys/elf32.h>
+# include <sys/elf64.h>
+# include <osreldate.h>
+# if __FreeBSD_version >= 700025
+#  define __LIBELF_HAVE_ELF_CAP                1
+#  define __LIBELF_HAVE_ELF_MOVE       1
+#  define __LIBELF_HAVE_ELF_NOTE       1
+#  define __LIBELF_HAVE_ELF_SYMINFO    1
+# endif /* __FreeBSD_version >= 700025 */
+# if __FreeBSD_version >= 700009
+#  define __LIBELF_HAVE_ELF_VERS       1
+# endif /* __FreeBSD_version >= 700009 */
+#endif /* __FreeBSD__ */
+
 /* Library private data structures */
 typedef struct _Elf Elf;
 typedef struct _Elf_Scn Elf_Scn;
diff -r ee11ed25c828 -r fa57ef00047d external/bsd/libelf/dist/libelf_align.c
--- a/external/bsd/libelf/dist/libelf_align.c   Sat Dec 19 07:09:28 2009 +0000
+++ b/external/bsd/libelf/dist/libelf_align.c   Sat Dec 19 07:31:04 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libelf_align.c,v 1.1.1.1 2009/12/19 05:43:40 thorpej Exp $     */
+/*     $NetBSD: libelf_align.c,v 1.2 2009/12/19 07:31:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Joseph Koshy
@@ -28,15 +28,13 @@
 
 #include <sys/cdefs.h>
 /* __FBSDID("$FreeBSD: src/lib/libelf/libelf_align.c,v 1.3.2.1.2.1 2009/10/25 01:10:29 kensmith Exp $"); */
-__RCSID("$NetBSD: libelf_align.c,v 1.1.1.1 2009/12/19 05:43:40 thorpej Exp $");
+__RCSID("$NetBSD: libelf_align.c,v 1.2 2009/12/19 07:31:04 thorpej Exp $");
 
 #include <sys/types.h>
 
-#include <machine/elf.h>
 #include <machine/endian.h>



Home | Main Index | Thread Index | Old Index