Commits

Anonymous committed e189b59

always build our libelf, as our libdwarf doesn't get along with the
system libelf on linux

Comments (0)

Files changed (10)

 	libelf/libelf.c libelf/libelf_align.c libelf/libelf_allocate.c \
 	libelf/libelf_ar.c libelf/libelf_ar_util.c libelf/libelf_checksum.c \
 	libelf/libelf_data.c libelf/libelf_ehdr.c libelf/libelf_extended.c \
-	libelf/libelf_phdr.c libelf/libelf_shdr.c libelf/libelf_xlate.c
+	libelf/libelf_phdr.c libelf/libelf_shdr.c libelf/libelf_xlate.c \
+	libelf/libelf_fsize.c libelf/libelf_msize.c libelf/libelf_convert.c
+
+libelf/libelf_fsize.c: libelf/libelf_fsize.m4
+	m4 libelf/libelf_fsize.m4 > libelf/libelf_fsize.c
+
+libelf/libelf_msize.c: libelf/libelf_msize.m4
+	m4 libelf/libelf_msize.m4 > libelf/libelf_msize.c
+
+libelf/libelf_convert.c: libelf/libelf_convert.m4
+	m4 libelf/libelf_convert.m4 > libelf/libelf_convert.c
+
 endif
 
 ctfdump_SOURCES = dump/dump.c
 AC_CHECK_FUNCS([ \
 getexecname \
 getprogname \
+strlcpy \
 ])
 
 AC_CHECK_LIB(z, uncompress)
 AC_CHECK_LIB(elf, gelf_getshdr, [],[
   build_gelf=true
 ])
+  build_gelf=true
 AM_CONDITIONAL([BUILD_ELF], [test "$build_gelf" = true])
 
 AC_CHECK_LIB(dwarf, dwarf_elf_init, [], [
 
 AC_CHECK_LIB(pthread, pthread_create)
 
+#gelf.h \
 AC_CHECK_HEADERS([ \
 ctype.h \
 dwarf.h \
 errno.h \
 fcntl.h \
-gelf.h \
 libdwarf.h \
 libgen.h \
 limits.h \
 
 #define	LIBELF_ELF_ERROR_MASK	0xFF
 #define	LIBELF_OS_ERROR_SHIFT	8
+#define	ROUNDUP2(V,N)	(V) = ((((V) + (N) - 1)) & ~((N) - 1))
 
 #define	LIBELF_SET_ERROR(E, O) do {					\
 	LIBELF_PRIVATE(error) = ((ELF_E_##E & LIBELF_ELF_ERROR_MASK)|	\

libelf/elf_errmsg.c

 	if (error < 0 || error >= ELF_E_NUM)
 		return _libelf_errors[ELF_E_NUM];
 	if (oserr) {
+#if !HAVE_STRLCPY
+# define strlcpy strncpy
+# define strlcat(dst, src, len) strcat(dst, src)
+#endif
 		strlcpy(LIBELF_PRIVATE(msg), _libelf_errors[error],
 		    sizeof(LIBELF_PRIVATE(msg)));
 		strlcat(LIBELF_PRIVATE(msg), ": ", sizeof(LIBELF_PRIVATE(msg)));
 
 	i = 0;
 	if (!STAILQ_EMPTY(&e->e_u.e_elf.e_scn)) {
+#ifndef __linux__
+		/* something in here expands to "struct" and breaks compilation */
 		assert(STAILQ_FIRST(&e->e_u.e_elf.e_scn) ==
 		    STAILQ_LAST(&e->e_u.e_elf.e_scn, _Elf_Scn, s_next));
+#endif
 
 		i = 1;
 		src += fsz;

libelf/elf_strptr.c

 					LIBELF_SET_ERROR(DATA, 0);
 					return (NULL);
 				}
-				count = roundup2(count, alignment);
+				count = ROUNDUP2(count, alignment);
 			}
 
 			if (offset < count) {

libelf/elf_update.c

 			if ((uint64_t) d->d_off + d->d_size > scn_size)
 				scn_size = d->d_off + d->d_size;
 		} else {
-			scn_size = roundup2(scn_size, d->d_align);
+			scn_size = ROUNDUP2(scn_size, d->d_align);
 			d->d_off = scn_size;
 			scn_size += d->d_size;
 		}

libelf/libelf_convert.m4

  * SUCH DAMAGE.
  */
 
+#if 0
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libelf/libelf_convert.m4,v 1.4.2.3.2.1 2010/12/21 17:09:25 kensmith Exp $");
 
 #include <libelf.h>
 #include <osreldate.h>
 #include <string.h>
+#endif
 
 #include "_libelf.h"
 
 		(P)		= (P) + EI_NIDENT;			\
 	} while (0)
 
-#define	ROUNDUP2(V,N)	(V) = ((((V) + (N) - 1)) & ~((N) - 1))
-
 divert(-1)
 
 /*
  * treated as being potentially unaligned and no casting can be done.
  */
 
-include(SRCDIR`/elf_types.m4')
+include(`libelf/elf_types.m4')
 
 /*
  * `IGNORE'_* flags turn off generation of template code.
  */
 
 define(`MAKE_TYPE_CONVERTER',
-  `#if	__FreeBSD_version >= $3 /* $1 */
+  `/* $1 */
 ifdef(`BASE'_$1,
     `ifdef(`IGNORE_'$1,`',
       `MAKEPRIM_TO_F($1,$2,`',64)
        MAKE_TO_F($1,$2,64)dnl
        MAKE_TO_M($1,$2,32)dnl
        MAKE_TO_M($1,$2,64)')')
-#endif /* $1 */
+/* $1 */
 ')
 
 define(`MAKE_TYPE_CONVERTERS',
 
 MAKE_TYPE_CONVERTERS(ELF_TYPE_LIST)
 
-#if	__FreeBSD_version >= 800062
 /*
  * Sections of type ELF_T_GNUHASH start with a header containing 4 32-bit
  * words.  Bloom filter data comes next, followed by hash buckets and the
 
 	return (1);
 }
-#endif
 
 /*
  * Elf_Note structures comprise a fixed size header followed by variable
 
 define(`CONVERTER_NAME',
   `ifdef(`IGNORE_'$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',
 		.tom64 = libelf_cvt_BYTE_tox
 	},
 
-#if	__FreeBSD_version >= 800062
 	[ELF_T_GNUHASH] = {
 		.tof32 = libelf_cvt32_GNUHASH_tof,
 		.tom32 = libelf_cvt32_GNUHASH_tom,
 		.tof64 = libelf_cvt64_GNUHASH_tof,
 		.tom64 = libelf_cvt64_GNUHASH_tom
 	},
-#endif
 
 	[ELF_T_NOTE] = {
 		.tof32 = libelf_cvt_NOTE_tof,

libelf/libelf_fsize.m4

  * $FreeBSD: src/lib/libelf/libelf_fsize.m4,v 1.2.10.2.2.1 2010/12/21 17:09:25 kensmith Exp $
  */
 
-#include <libelf.h>
-#include <osreldate.h>
-
 #include "_libelf.h"
 
 /*
  */
 
 divert(-1)
-include(SRCDIR`/elf_types.m4')
+include(`libelf/elf_types.m4')
 
 /*
  * Translations from structure definitions to the size of their file
 DEFINE_ELF_FSIZE(`IDENT',`')	# `IDENT' is a pseudo type
 
 define(`FSIZE',
-  `#if	__FreeBSD_version >= $3
-    [ELF_T_$1] = { .fsz32 = $1_SIZE32, .fsz64 = $1_SIZE64 },
-#endif')
+  `[ELF_T_$1] = { .fsz32 = $1_SIZE32, .fsz64 = $1_SIZE64 },')
 define(`FSIZES',
   `ifelse($#,1,`',
     `FSIZE($1)

libelf/libelf_msize.m4

  * SUCH DAMAGE.
  */
 
+#include "_libelf.h"
+#if 0
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libelf/libelf_msize.m4,v 1.2.10.2.2.1 2010/12/21 17:09:25 kensmith Exp $");
 
 #include <libelf.h>
 #include <osreldate.h>
 #include <string.h>
+#endif
 
-#include "_libelf.h"
 
 /* WARNING: GENERATED FROM __file__. */
 
 };
 
 divert(-1)
-include(SRCDIR`/elf_types.m4')
+include(`libelf/elf_types.m4')
 
 define(BYTE_SIZE,	1)
 define(GNUHASH_SIZE,	1)
 DEFINE_ELF_MSIZES(ELF_TYPE_LIST)
 
 define(`MSIZE',
-  `#if	__FreeBSD_version >= $3
+  `
     [ELF_T_$1] = { .msz32 = $1_SIZE32, .msz64 = $1_SIZE64 },
-#endif')
+')
 define(`MSIZES',
   `ifelse($#,1,`',
     `MSIZE($1)