diff options
-rw-r--r-- | lib/libelf/Makefile | 17 | ||||
-rw-r--r-- | lib/libelf/elf_types.m4 | 58 | ||||
-rw-r--r-- | lib/libelf/gelf.h | 4 | ||||
-rw-r--r-- | lib/libelf/gelf_cap.c | 5 | ||||
-rw-r--r-- | lib/libelf/gelf_move.c | 5 | ||||
-rw-r--r-- | lib/libelf/gelf_syminfo.c | 5 | ||||
-rw-r--r-- | lib/libelf/libelf_convert.m4 | 21 | ||||
-rw-r--r-- | lib/libelf/libelf_fsize.m4 | 13 | ||||
-rw-r--r-- | lib/libelf/libelf_msize.m4 | 13 |
9 files changed, 74 insertions, 67 deletions
diff --git a/lib/libelf/Makefile b/lib/libelf/Makefile index 7a4a492..ae1ad42 100644 --- a/lib/libelf/Makefile +++ b/lib/libelf/Makefile @@ -24,16 +24,19 @@ SRCS= elf_begin.c \ elf_strptr.c \ elf_update.c \ elf_version.c \ + gelf_cap.c \ gelf_checksum.c \ - gelf_fsize.c \ - gelf_getclass.c \ gelf_dyn.c \ gelf_ehdr.c \ + gelf_getclass.c \ + gelf_fsize.c \ + gelf_move.c \ gelf_phdr.c \ gelf_rel.c \ gelf_rela.c \ gelf_shdr.c \ gelf_sym.c \ + gelf_syminfo.c \ gelf_symshndx.c \ gelf_xlate.c \ libelf.c \ @@ -53,16 +56,8 @@ GENSRCS= libelf_fsize.c libelf_msize.c libelf_convert.c CLEANFILES= ${GENSRCS} CFLAGS+= -I. -I${.CURDIR} -OSRELDATE!= sysctl -n kern.osreldate - SHLIB_MAJOR= 1 -.if ${OSRELDATE} > 700009 -SRCS+= gelf_cap.c \ - gelf_move.c \ - gelf_syminfo.c -.endif - WARNS?= 6 MAN= elf.3 \ @@ -162,4 +157,4 @@ libelf_msize.c: elf_types.m4 libelf_msize.m4 # Keep the .SUFFIXES line after the include of bsd.lib.mk .SUFFIXES: .m4 .c .m4.c: - m4 -D SRCDIR=${.CURDIR} -D OSRELDATE=${OSRELDATE} ${.IMPSRC} > ${.TARGET} + m4 -D SRCDIR=${.CURDIR} ${.IMPSRC} > ${.TARGET} diff --git a/lib/libelf/elf_types.m4 b/lib/libelf/elf_types.m4 index b317184..9abbe71 100644 --- a/lib/libelf/elf_types.m4 +++ b/lib/libelf/elf_types.m4 @@ -28,33 +28,43 @@ /* * ELF types, defined in the "enum Elf_Type" API. + * + * The members of the list form a 3-tuple: (name, C-type-suffix, OSversion). + * + `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. */ define(`ELF_TYPE_LIST', - ``ADDR, Addr', - `BYTE, Byte', - `CAP, Cap', - `DYN, Dyn', - `EHDR, Ehdr', - `HALF, Half', - `LWORD, Lword', - `MOVE, Move', - `MOVEP, MoveP', - `NOTE, Note', - `OFF, Off', - `PHDR, Phdr', - `REL, Rel', - `RELA, Rela', - `SHDR, Shdr', - `SWORD, Sword', - `SXWORD, Sxword', - `SYMINFO, Syminfo', - `SYM, Sym', - `VDEF, Verdef', - `VNEED, Verneed', - `WORD, Word', - `XWORD, Xword', - `NUM, _'') + ``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', + `NUM, _, _'') /* * DEFINE_STRUCT(NAME,MEMBERLIST...) diff --git a/lib/libelf/gelf.h b/lib/libelf/gelf.h index 8a05958..039b8c0 100644 --- a/lib/libelf/gelf.h +++ b/lib/libelf/gelf.h @@ -50,7 +50,7 @@ typedef Elf64_Sym GElf_Sym; /* Symbol table entries */ typedef Elf64_Rel GElf_Rel; /* Relocation entries */ typedef Elf64_Rela GElf_Rela; /* Relocation entries with addend */ -#if __FreeBSD_version > 700009 +#if __FreeBSD_version >= 700025 typedef Elf64_Cap GElf_Cap; /* SW/HW capabilities */ typedef Elf64_Move GElf_Move; /* Move entries */ typedef Elf64_Syminfo GElf_Syminfo; /* Symbol information */ @@ -84,7 +84,7 @@ int gelf_update_symshndx(Elf_Data *_symdst, Elf_Data *_shindexdst, 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 > 700009 +#if __FreeBSD_version >= 700025 GElf_Cap *gelf_getcap(Elf_Data *_data, int _index, GElf_Cap *_cap); GElf_Move *gelf_getmove(Elf_Data *_src, int _index, GElf_Move *_dst); GElf_Syminfo *gelf_getsyminfo(Elf_Data *_src, int _index, GElf_Syminfo *_dst); diff --git a/lib/libelf/gelf_cap.c b/lib/libelf/gelf_cap.c index 6e1a9d9..76338a8 100644 --- a/lib/libelf/gelf_cap.c +++ b/lib/libelf/gelf_cap.c @@ -31,9 +31,12 @@ __FBSDID("$FreeBSD$"); #include <assert.h> #include <gelf.h> +#include <osreldate.h> #include "_libelf.h" +#if __FreeBSD_version >= 700025 + GElf_Cap * gelf_getcap(Elf_Data *d, int ndx, GElf_Cap *dst) { @@ -143,3 +146,5 @@ gelf_update_cap(Elf_Data *d, int ndx, GElf_Cap *gc) return (1); } + +#endif /* __FreeBSD_version >= 700025 */ diff --git a/lib/libelf/gelf_move.c b/lib/libelf/gelf_move.c index 96d0aae..d303b18 100644 --- a/lib/libelf/gelf_move.c +++ b/lib/libelf/gelf_move.c @@ -31,9 +31,12 @@ __FBSDID("$FreeBSD$"); #include <assert.h> #include <gelf.h> +#include <osreldate.h> #include "_libelf.h" +#if __FreeBSD_version >= 700025 + GElf_Move * gelf_getmove(Elf_Data *d, int ndx, GElf_Move *dst) { @@ -149,3 +152,5 @@ gelf_update_move(Elf_Data *d, int ndx, GElf_Move *gm) return (1); } + +#endif /* __FreeBSD_version >= 700025 */ diff --git a/lib/libelf/gelf_syminfo.c b/lib/libelf/gelf_syminfo.c index 4d0adfe..90c1ed9 100644 --- a/lib/libelf/gelf_syminfo.c +++ b/lib/libelf/gelf_syminfo.c @@ -31,9 +31,12 @@ __FBSDID("$FreeBSD$"); #include <assert.h> #include <gelf.h> +#include <osreldate.h> #include "_libelf.h" +#if __FreeBSD_version >= 700025 + GElf_Syminfo * gelf_getsyminfo(Elf_Data *d, int ndx, GElf_Syminfo *dst) { @@ -144,3 +147,5 @@ gelf_update_syminfo(Elf_Data *d, int ndx, GElf_Syminfo *gs) return (1); } + +#endif /* __FreeBSD_version >= 700025 */ diff --git a/lib/libelf/libelf_convert.m4 b/lib/libelf/libelf_convert.m4 index 0eb0b70..5027ef9 100644 --- a/lib/libelf/libelf_convert.m4 +++ b/lib/libelf/libelf_convert.m4 @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <assert.h> #include <libelf.h> +#include <osreldate.h> #include <string.h> #include "_libelf.h" @@ -234,15 +235,6 @@ define(`IGNORE', IGNORE(MOVEP) IGNORE(NOTE) -ifelse(eval(OSRELDATE < 700009),1, - `IGNORE(CAP) - IGNORE(MOVE) - IGNORE(SYMINFO) - IGNORE(VDEF) - IGNORE(VNEED) - define(`IGNORE_LWORD', 1)', - `') - define(IGNORE_BYTE, 1) /* 'lator, leave 'em bytes alone */ define(IGNORE_NOTE, 1) define(IGNORE_SXWORD32, 1) @@ -455,7 +447,8 @@ libelf_cvt$3_$1_tom(char *dst, char *src, size_t count, int byteswap) */ define(`MAKE_TYPE_CONVERTER', - `ifdef(`BASE'_$1, + `#if __FreeBSD_version >= $3 /* $1 */ +ifdef(`BASE'_$1, `ifdef(`IGNORE_'$1,`', `MAKEPRIM_TO_F($1,$2,`',64) MAKEPRIM_TO_M($1,$2,`',64)')', @@ -467,7 +460,9 @@ define(`MAKE_TYPE_CONVERTER', `MAKE_TO_F($1,$2,32)dnl MAKE_TO_F($1,$2,64)dnl MAKE_TO_M($1,$2,32)dnl - MAKE_TO_M($1,$2,64)')')') + MAKE_TO_M($1,$2,64)')') +#endif /* $1 */ +') define(`MAKE_TYPE_CONVERTERS', `ifelse($#,1,`', @@ -618,9 +613,11 @@ define(`CONV', `.$3$2 = libelf_cvt$2_$1_$3')')')') define(`CONVERTER_NAME', - `[ELF_T_$1] = { + `#if __FreeBSD_version >= $3 + [ELF_T_$1] = { CONV($1,32,tof), CONV($1,32,tom), CONV($1,64,tof), CONV($1,64,tom) }, +#endif ')') define(`CONVERTER_NAMES', diff --git a/lib/libelf/libelf_fsize.m4 b/lib/libelf/libelf_fsize.m4 index 93d1d92..d9b11ec 100644 --- a/lib/libelf/libelf_fsize.m4 +++ b/lib/libelf/libelf_fsize.m4 @@ -27,6 +27,7 @@ */ #include <libelf.h> +#include <osreldate.h> #include "_libelf.h" @@ -54,14 +55,6 @@ define(`MOVEP_SIZE', 0) define(`XWORD_SIZE32', 0) define(`SXWORD_SIZE32', 0) -ifelse(eval(OSRELDATE < 700009),1, - `define(`CAP_SIZE', 0) - define(`LWORD_SIZE', 0) - define(`MOVE_SIZE', 0) - define(`SYMINFO_SIZE', 0) - define(`VDEF_SIZE', 0) - define(`VNEED_SIZE', 0)',`') - /* * FSZ{32,64} define the sizes of 32 and 64 bit file structures respectively. */ @@ -122,7 +115,9 @@ DEFINE_ELF_FSIZES(ELF_TYPE_LIST) DEFINE_ELF_FSIZE(`IDENT',`') # `IDENT' is a pseudo type define(`FSIZE', - `[ELF_T_$1] = { .fsz32 = $1_SIZE32, .fsz64 = $1_SIZE64 },') + `#if __FreeBSD_version >= $3 + [ELF_T_$1] = { .fsz32 = $1_SIZE32, .fsz64 = $1_SIZE64 }, +#endif') define(`FSIZES', `ifelse($#,1,`', `FSIZE($1) diff --git a/lib/libelf/libelf_msize.m4 b/lib/libelf/libelf_msize.m4 index cb0e2bb..3e73591 100644 --- a/lib/libelf/libelf_msize.m4 +++ b/lib/libelf/libelf_msize.m4 @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <assert.h> #include <libelf.h> +#include <osreldate.h> #include <string.h> #include "_libelf.h" @@ -57,14 +58,6 @@ define(MOVEP_SIZE, 0) define(SXWORD_SIZE32, 0) define(XWORD_SIZE32, 0) -ifelse(eval(OSRELDATE < 700009),1, - `define(`CAP_SIZE', 0) - define(`LWORD_SIZE', 0) - define(`MOVE_SIZE', 0) - define(`SYMINFO_SIZE', 0) - define(`VDEF_SIZE', 0) - define(`VNEED_SIZE', 0)',`') - define(`DEFINE_ELF_MSIZE', `ifdef($1`_SIZE', `define($1_SIZE32,$1_SIZE) @@ -81,7 +74,9 @@ define(`DEFINE_ELF_MSIZES', DEFINE_ELF_MSIZES(ELF_TYPE_LIST) define(`MSIZE', - `[ELF_T_$1] = { .msz32 = $1_SIZE32, .msz64 = $1_SIZE64 },') + `#if __FreeBSD_version >= $3 + [ELF_T_$1] = { .msz32 = $1_SIZE32, .msz64 = $1_SIZE64 }, +#endif') define(`MSIZES', `ifelse($#,1,`', `MSIZE($1) |