2019-04-24 18:49:48 +08:00
|
|
|
dnl -*- Autoconf -*-
|
|
|
|
dnl Process this file with autoconf to produce a configure script.
|
|
|
|
dnl
|
2020-01-01 15:57:01 +08:00
|
|
|
dnl Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
2019-04-24 18:49:48 +08:00
|
|
|
dnl
|
|
|
|
dnl This file is free software; you can redistribute it and/or modify
|
|
|
|
dnl it under the terms of the GNU General Public License as published by
|
|
|
|
dnl the Free Software Foundation; either version 2 of the License, or
|
|
|
|
dnl (at your option) any later version.
|
|
|
|
dnl
|
|
|
|
dnl This program is distributed in the hope that it will be useful,
|
|
|
|
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
dnl GNU General Public License for more details.
|
|
|
|
dnl
|
|
|
|
dnl You should have received a copy of the GNU General Public License
|
|
|
|
dnl along with this program; see the file COPYING. If not see
|
|
|
|
dnl <http://www.gnu.org/licenses/>.
|
|
|
|
dnl
|
|
|
|
|
|
|
|
AC_PREREQ(2.64)
|
|
|
|
AC_INIT([libctf library], 1.2.0-pre)
|
|
|
|
AC_CONFIG_SRCDIR(ctf-impl.h)
|
|
|
|
AC_CONFIG_MACRO_DIR(../config)
|
libctf: installable libctf as a shared library
This lets other programs read and write CTF-format data.
Two versioned shared libraries are created: libctf.so and
libctf-nobfd.so. They contain identical content except that
libctf-nobfd.so contains no references to libbfd and does not implement
ctf_open, ctf_fdopen, ctf_bfdopen or ctf_bfdopen_ctfsect, so it can be
used by programs that cannot use BFD, like readelf.
The soname major version is presently .0 until the linker API
stabilizes, when it will flip to .1 and hopefully never change again.
New in v3.
v4: libtoolize and turn into a pair of shared libraries. Drop
--enable-install-ctf: now controlled by --enable-shared and
--enable-install-libbfd, like everything else.
v5: Add ../bfd to ACLOCAL_AMFLAGS and AC_CONFIG_MACRO_DIR. Fix tabdamage.
* Makefile.def (host_modules): libctf is no longer no_install.
* Makefile.in: Regenerated.
libctf/
* configure.ac (AC_DISABLE_SHARED): New, like opcodes/.
(LT_INIT): Likewise.
(AM_INSTALL_LIBBFD): Likewise.
(dlopen): Note why this is necessary in a comment.
(SHARED_LIBADD): Initialize for possibly-PIC libiberty: derived from
opcodes/.
(SHARED_LDFLAGS): Likewise.
(BFD_LIBADD): Likewise, for libbfd.
(BFD_DEPENDENCIES): Likewise.
(VERSION_FLAGS): Initialize, using a version script if ld supports
one, or libtool -export-symbols-regex otherwise.
(AC_CONFIG_MACRO_DIR): Add ../BFD.
* Makefile.am (ACLOCAL_AMFLAGS): Likewise.
(INCDIR): New.
(AM_CPPFLAGS): Use $(srcdir), not $(top_srcdir).
(noinst_LIBRARIES): Replace with...
[INSTALL_LIBBFD] (lib_LTLIBRARIES): This, or...
[!INSTALL_LIBBFD] (noinst_LTLIBRARIES): ... this, mentioning new
libctf-nobfd.la as well.
[INSTALL_LIBCTF] (include_HEADERS): Add the CTF headers.
[!INSTALL_LIBCTF] (include_HEADERS): New, empty.
(libctf_a_SOURCES): Rename to...
(libctf_nobfd_la_SOURCES): ... this, all of libctf other than
ctf-open-bfd.c.
(libctf_la_SOURCES): Now derived from libctf_nobfd_la_SOURCES,
with ctf-open-bfd.c added.
(libctf_nobfd_la_LIBADD): New, using @SHARED_LIBADD@.
(libctf_la_LIBADD): New, using @BFD_LIBADD@ as well.
(libctf_la_DEPENDENCIES): New, using @BFD_DEPENDENCIES@.
* Makefile.am [INSTALL_LIBCTF]: Use it.
* aclocal.m4: Add ../bfd/acinclude.m4, ../config/acx.m4, and the
libtool macros.
* libctf.ver: New, everything is version LIBCTF_1.0 currently (even
the unstable components).
* Makefile.in: Regenerated.
* config.h.in: Likewise.
* configure: Likewise.
binutils/
* Makefile.am (LIBCTF): Mention the .la file.
(LIBCTF_NOBFD): New.
(readelf_DEPENDENCIES): Use it.
(readelf_LDADD): Likewise.
* Makefile.in: Regenerated.
ld/
* configure.ac (TESTCTFLIB): Set to the .so or .a, like TESTBFDLIB.
* Makefile.am (TESTCTFLIB): Use it.
(LIBCTF): Use the .la file.
(check-DEJAGNU): Use it.
* Makefile.in: Regenerated.
* configure: Likewise.
include/
* ctf-api.h: Note the instability of the ctf_link interfaces.
2019-07-20 21:45:12 +08:00
|
|
|
AC_CONFIG_MACRO_DIR(../bfd)
|
2019-04-24 18:49:48 +08:00
|
|
|
AC_USE_SYSTEM_EXTENSIONS
|
|
|
|
AM_INIT_AUTOMAKE
|
|
|
|
|
|
|
|
# Checks for programs.
|
|
|
|
AC_PROG_MAKE_SET
|
|
|
|
AC_PROG_CC
|
|
|
|
AC_PROG_RANLIB
|
|
|
|
AM_PROG_AR
|
2019-12-16 22:17:26 +08:00
|
|
|
ZW_GNU_GETTEXT_SISTER_DIR
|
2019-04-24 18:49:48 +08:00
|
|
|
|
libctf: installable libctf as a shared library
This lets other programs read and write CTF-format data.
Two versioned shared libraries are created: libctf.so and
libctf-nobfd.so. They contain identical content except that
libctf-nobfd.so contains no references to libbfd and does not implement
ctf_open, ctf_fdopen, ctf_bfdopen or ctf_bfdopen_ctfsect, so it can be
used by programs that cannot use BFD, like readelf.
The soname major version is presently .0 until the linker API
stabilizes, when it will flip to .1 and hopefully never change again.
New in v3.
v4: libtoolize and turn into a pair of shared libraries. Drop
--enable-install-ctf: now controlled by --enable-shared and
--enable-install-libbfd, like everything else.
v5: Add ../bfd to ACLOCAL_AMFLAGS and AC_CONFIG_MACRO_DIR. Fix tabdamage.
* Makefile.def (host_modules): libctf is no longer no_install.
* Makefile.in: Regenerated.
libctf/
* configure.ac (AC_DISABLE_SHARED): New, like opcodes/.
(LT_INIT): Likewise.
(AM_INSTALL_LIBBFD): Likewise.
(dlopen): Note why this is necessary in a comment.
(SHARED_LIBADD): Initialize for possibly-PIC libiberty: derived from
opcodes/.
(SHARED_LDFLAGS): Likewise.
(BFD_LIBADD): Likewise, for libbfd.
(BFD_DEPENDENCIES): Likewise.
(VERSION_FLAGS): Initialize, using a version script if ld supports
one, or libtool -export-symbols-regex otherwise.
(AC_CONFIG_MACRO_DIR): Add ../BFD.
* Makefile.am (ACLOCAL_AMFLAGS): Likewise.
(INCDIR): New.
(AM_CPPFLAGS): Use $(srcdir), not $(top_srcdir).
(noinst_LIBRARIES): Replace with...
[INSTALL_LIBBFD] (lib_LTLIBRARIES): This, or...
[!INSTALL_LIBBFD] (noinst_LTLIBRARIES): ... this, mentioning new
libctf-nobfd.la as well.
[INSTALL_LIBCTF] (include_HEADERS): Add the CTF headers.
[!INSTALL_LIBCTF] (include_HEADERS): New, empty.
(libctf_a_SOURCES): Rename to...
(libctf_nobfd_la_SOURCES): ... this, all of libctf other than
ctf-open-bfd.c.
(libctf_la_SOURCES): Now derived from libctf_nobfd_la_SOURCES,
with ctf-open-bfd.c added.
(libctf_nobfd_la_LIBADD): New, using @SHARED_LIBADD@.
(libctf_la_LIBADD): New, using @BFD_LIBADD@ as well.
(libctf_la_DEPENDENCIES): New, using @BFD_DEPENDENCIES@.
* Makefile.am [INSTALL_LIBCTF]: Use it.
* aclocal.m4: Add ../bfd/acinclude.m4, ../config/acx.m4, and the
libtool macros.
* libctf.ver: New, everything is version LIBCTF_1.0 currently (even
the unstable components).
* Makefile.in: Regenerated.
* config.h.in: Likewise.
* configure: Likewise.
binutils/
* Makefile.am (LIBCTF): Mention the .la file.
(LIBCTF_NOBFD): New.
(readelf_DEPENDENCIES): Use it.
(readelf_LDADD): Likewise.
* Makefile.in: Regenerated.
ld/
* configure.ac (TESTCTFLIB): Set to the .so or .a, like TESTBFDLIB.
* Makefile.am (TESTCTFLIB): Use it.
(LIBCTF): Use the .la file.
(check-DEJAGNU): Use it.
* Makefile.in: Regenerated.
* configure: Likewise.
include/
* ctf-api.h: Note the instability of the ctf_link interfaces.
2019-07-20 21:45:12 +08:00
|
|
|
dnl Default to a non shared library. This may be overridden by the
|
|
|
|
dnl configure option --enable-shared.
|
|
|
|
AC_DISABLE_SHARED
|
|
|
|
|
|
|
|
LT_INIT
|
2019-04-24 18:49:48 +08:00
|
|
|
AC_SYS_LARGEFILE
|
|
|
|
|
|
|
|
MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
|
|
|
|
AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal])
|
|
|
|
AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf])
|
|
|
|
AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader])
|
|
|
|
|
|
|
|
# Figure out what compiler warnings we can enable.
|
|
|
|
# See config/warnings.m4 for details.
|
|
|
|
|
|
|
|
ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wno-narrowing -Wwrite-strings \
|
|
|
|
-Wmissing-format-attribute], [warn])
|
|
|
|
ACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \
|
|
|
|
-Wold-style-definition], [c_warn])
|
|
|
|
ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
|
|
|
|
|
|
|
|
# Only enable with --enable-werror-always until existing warnings are
|
|
|
|
# corrected.
|
|
|
|
ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
|
|
|
|
|
|
|
|
AM_MAINTAINER_MODE
|
libctf: installable libctf as a shared library
This lets other programs read and write CTF-format data.
Two versioned shared libraries are created: libctf.so and
libctf-nobfd.so. They contain identical content except that
libctf-nobfd.so contains no references to libbfd and does not implement
ctf_open, ctf_fdopen, ctf_bfdopen or ctf_bfdopen_ctfsect, so it can be
used by programs that cannot use BFD, like readelf.
The soname major version is presently .0 until the linker API
stabilizes, when it will flip to .1 and hopefully never change again.
New in v3.
v4: libtoolize and turn into a pair of shared libraries. Drop
--enable-install-ctf: now controlled by --enable-shared and
--enable-install-libbfd, like everything else.
v5: Add ../bfd to ACLOCAL_AMFLAGS and AC_CONFIG_MACRO_DIR. Fix tabdamage.
* Makefile.def (host_modules): libctf is no longer no_install.
* Makefile.in: Regenerated.
libctf/
* configure.ac (AC_DISABLE_SHARED): New, like opcodes/.
(LT_INIT): Likewise.
(AM_INSTALL_LIBBFD): Likewise.
(dlopen): Note why this is necessary in a comment.
(SHARED_LIBADD): Initialize for possibly-PIC libiberty: derived from
opcodes/.
(SHARED_LDFLAGS): Likewise.
(BFD_LIBADD): Likewise, for libbfd.
(BFD_DEPENDENCIES): Likewise.
(VERSION_FLAGS): Initialize, using a version script if ld supports
one, or libtool -export-symbols-regex otherwise.
(AC_CONFIG_MACRO_DIR): Add ../BFD.
* Makefile.am (ACLOCAL_AMFLAGS): Likewise.
(INCDIR): New.
(AM_CPPFLAGS): Use $(srcdir), not $(top_srcdir).
(noinst_LIBRARIES): Replace with...
[INSTALL_LIBBFD] (lib_LTLIBRARIES): This, or...
[!INSTALL_LIBBFD] (noinst_LTLIBRARIES): ... this, mentioning new
libctf-nobfd.la as well.
[INSTALL_LIBCTF] (include_HEADERS): Add the CTF headers.
[!INSTALL_LIBCTF] (include_HEADERS): New, empty.
(libctf_a_SOURCES): Rename to...
(libctf_nobfd_la_SOURCES): ... this, all of libctf other than
ctf-open-bfd.c.
(libctf_la_SOURCES): Now derived from libctf_nobfd_la_SOURCES,
with ctf-open-bfd.c added.
(libctf_nobfd_la_LIBADD): New, using @SHARED_LIBADD@.
(libctf_la_LIBADD): New, using @BFD_LIBADD@ as well.
(libctf_la_DEPENDENCIES): New, using @BFD_DEPENDENCIES@.
* Makefile.am [INSTALL_LIBCTF]: Use it.
* aclocal.m4: Add ../bfd/acinclude.m4, ../config/acx.m4, and the
libtool macros.
* libctf.ver: New, everything is version LIBCTF_1.0 currently (even
the unstable components).
* Makefile.in: Regenerated.
* config.h.in: Likewise.
* configure: Likewise.
binutils/
* Makefile.am (LIBCTF): Mention the .la file.
(LIBCTF_NOBFD): New.
(readelf_DEPENDENCIES): Use it.
(readelf_LDADD): Likewise.
* Makefile.in: Regenerated.
ld/
* configure.ac (TESTCTFLIB): Set to the .so or .a, like TESTBFDLIB.
* Makefile.am (TESTCTFLIB): Use it.
(LIBCTF): Use the .la file.
(check-DEJAGNU): Use it.
* Makefile.in: Regenerated.
* configure: Likewise.
include/
* ctf-api.h: Note the instability of the ctf_link interfaces.
2019-07-20 21:45:12 +08:00
|
|
|
AM_INSTALL_LIBBFD
|
2019-04-24 18:49:48 +08:00
|
|
|
ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_libctf_warn_cflags])
|
|
|
|
|
|
|
|
AC_FUNC_MMAP
|
libctf: installable libctf as a shared library
This lets other programs read and write CTF-format data.
Two versioned shared libraries are created: libctf.so and
libctf-nobfd.so. They contain identical content except that
libctf-nobfd.so contains no references to libbfd and does not implement
ctf_open, ctf_fdopen, ctf_bfdopen or ctf_bfdopen_ctfsect, so it can be
used by programs that cannot use BFD, like readelf.
The soname major version is presently .0 until the linker API
stabilizes, when it will flip to .1 and hopefully never change again.
New in v3.
v4: libtoolize and turn into a pair of shared libraries. Drop
--enable-install-ctf: now controlled by --enable-shared and
--enable-install-libbfd, like everything else.
v5: Add ../bfd to ACLOCAL_AMFLAGS and AC_CONFIG_MACRO_DIR. Fix tabdamage.
* Makefile.def (host_modules): libctf is no longer no_install.
* Makefile.in: Regenerated.
libctf/
* configure.ac (AC_DISABLE_SHARED): New, like opcodes/.
(LT_INIT): Likewise.
(AM_INSTALL_LIBBFD): Likewise.
(dlopen): Note why this is necessary in a comment.
(SHARED_LIBADD): Initialize for possibly-PIC libiberty: derived from
opcodes/.
(SHARED_LDFLAGS): Likewise.
(BFD_LIBADD): Likewise, for libbfd.
(BFD_DEPENDENCIES): Likewise.
(VERSION_FLAGS): Initialize, using a version script if ld supports
one, or libtool -export-symbols-regex otherwise.
(AC_CONFIG_MACRO_DIR): Add ../BFD.
* Makefile.am (ACLOCAL_AMFLAGS): Likewise.
(INCDIR): New.
(AM_CPPFLAGS): Use $(srcdir), not $(top_srcdir).
(noinst_LIBRARIES): Replace with...
[INSTALL_LIBBFD] (lib_LTLIBRARIES): This, or...
[!INSTALL_LIBBFD] (noinst_LTLIBRARIES): ... this, mentioning new
libctf-nobfd.la as well.
[INSTALL_LIBCTF] (include_HEADERS): Add the CTF headers.
[!INSTALL_LIBCTF] (include_HEADERS): New, empty.
(libctf_a_SOURCES): Rename to...
(libctf_nobfd_la_SOURCES): ... this, all of libctf other than
ctf-open-bfd.c.
(libctf_la_SOURCES): Now derived from libctf_nobfd_la_SOURCES,
with ctf-open-bfd.c added.
(libctf_nobfd_la_LIBADD): New, using @SHARED_LIBADD@.
(libctf_la_LIBADD): New, using @BFD_LIBADD@ as well.
(libctf_la_DEPENDENCIES): New, using @BFD_DEPENDENCIES@.
* Makefile.am [INSTALL_LIBCTF]: Use it.
* aclocal.m4: Add ../bfd/acinclude.m4, ../config/acx.m4, and the
libtool macros.
* libctf.ver: New, everything is version LIBCTF_1.0 currently (even
the unstable components).
* Makefile.in: Regenerated.
* config.h.in: Likewise.
* configure: Likewise.
binutils/
* Makefile.am (LIBCTF): Mention the .la file.
(LIBCTF_NOBFD): New.
(readelf_DEPENDENCIES): Use it.
(readelf_LDADD): Likewise.
* Makefile.in: Regenerated.
ld/
* configure.ac (TESTCTFLIB): Set to the .so or .a, like TESTBFDLIB.
* Makefile.am (TESTCTFLIB): Use it.
(LIBCTF): Use the .la file.
(check-DEJAGNU): Use it.
* Makefile.in: Regenerated.
* configure: Likewise.
include/
* ctf-api.h: Note the instability of the ctf_link interfaces.
2019-07-20 21:45:12 +08:00
|
|
|
# Needed for BFD capability checks.
|
2019-05-29 17:11:37 +08:00
|
|
|
AC_SEARCH_LIBS(dlopen, dl)
|
libctf: fix a number of build problems found on Solaris and NetBSD
- Use of nonportable <endian.h>
- Use of qsort_r
- Use of zlib without appropriate magic to pull in the binutils zlib
- Use of off64_t without checking (fixed by dropping the unused fields
that need off64_t entirely)
- signedness problems due to long being too short a type on 32-bit
platforms: ctf_id_t is now 'unsigned long', and CTF_ERR must be
used only for functions that return ctf_id_t
- One lingering use of bzero() and of <sys/errno.h>
All fixed, using code from gnulib where possible.
Relatedly, set cts_size in a couple of places it was missed
(string table and symbol table loading upon ctf_bfdopen()).
binutils/
* objdump.c (make_ctfsect): Drop cts_type, cts_flags, and
cts_offset.
* readelf.c (shdr_to_ctf_sect): Likewise.
include/
* ctf-api.h (ctf_sect_t): Drop cts_type, cts_flags, and cts_offset.
(ctf_id_t): This is now an unsigned type.
(CTF_ERR): Cast it to ctf_id_t. Note that it should only be used
for ctf_id_t-returning functions.
libctf/
* Makefile.am (ZLIB): New.
(ZLIBINC): Likewise.
(AM_CFLAGS): Use them.
(libctf_a_LIBADD): New, for LIBOBJS.
* configure.ac: Check for zlib, endian.h, and qsort_r.
* ctf-endian.h: New, providing htole64 and le64toh.
* swap.h: Code style fixes.
(bswap_identity_64): New.
* qsort_r.c: New, from gnulib (with one added #include).
* ctf-decls.h: New, providing a conditional qsort_r declaration,
and unconditional definitions of MIN and MAX.
* ctf-impl.h: Use it. Do not use <sys/errno.h>.
(ctf_set_errno): Now returns unsigned long.
* ctf-util.c (ctf_set_errno): Adjust here too.
* ctf-archive.c: Use ctf-endian.h.
(ctf_arc_open_by_offset): Use memset, not bzero. Drop cts_type,
cts_flags and cts_offset.
(ctf_arc_write): Drop debugging dependent on the size of off_t.
* ctf-create.c: Provide a definition of roundup if not defined.
(ctf_create): Drop cts_type, cts_flags and cts_offset.
(ctf_add_reftype): Do not check if type IDs are below zero.
(ctf_add_slice): Likewise.
(ctf_add_typedef): Likewise.
(ctf_add_member_offset): Cast error-returning ssize_t's to size_t
when known error-free. Drop CTF_ERR usage for functions returning
int.
(ctf_add_member_encoded): Drop CTF_ERR usage for functions returning
int.
(ctf_add_variable): Likewise.
(enumcmp): Likewise.
(enumadd): Likewise.
(membcmp): Likewise.
(ctf_add_type): Likewise. Cast error-returning ssize_t's to size_t
when known error-free.
* ctf-dump.c (ctf_is_slice): Drop CTF_ERR usage for functions
returning int: use CTF_ERR for functions returning ctf_type_id.
(ctf_dump_label): Likewise.
(ctf_dump_objts): Likewise.
* ctf-labels.c (ctf_label_topmost): Likewise.
(ctf_label_iter): Likewise.
(ctf_label_info): Likewise.
* ctf-lookup.c (ctf_func_args): Likewise.
* ctf-open.c (upgrade_types): Cast to size_t where appropriate.
(ctf_bufopen): Likewise. Use zlib types as needed.
* ctf-types.c (ctf_member_iter): Drop CTF_ERR usage for functions
returning int.
(ctf_enum_iter): Likewise.
(ctf_type_size): Likewise.
(ctf_type_align): Likewise. Cast to size_t where appropriate.
(ctf_type_kind_unsliced): Likewise.
(ctf_type_kind): Likewise.
(ctf_type_encoding): Likewise.
(ctf_member_info): Likewise.
(ctf_array_info): Likewise.
(ctf_enum_value): Likewise.
(ctf_type_rvisit): Likewise.
* ctf-open-bfd.c (ctf_bfdopen): Drop cts_type, cts_flags and
cts_offset.
(ctf_simple_open): Likewise.
(ctf_bfdopen_ctfsect): Likewise. Set cts_size properly.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* config.h: Likewise.
* configure: Likewise.
2019-05-31 17:10:51 +08:00
|
|
|
AM_ZLIB
|
2019-05-29 17:11:37 +08:00
|
|
|
|
2020-06-06 01:38:03 +08:00
|
|
|
GCC_ENABLE([libctf-hash-debugging], [no], [], [Enable expensive debugging of CTF deduplication type hashing])
|
|
|
|
if test "${enable_libctf_hash_debugging}" = yes; then
|
|
|
|
AC_DEFINE(ENABLE_LIBCTF_HASH_DEBUGGING, 1, [Enable expensive debugging of CTF deduplication type hashing])
|
|
|
|
fi
|
|
|
|
AM_CONDITIONAL(ENABLE_LIBCTF_HASH_DEBUGGING, test "${enable_libctf_hash_debugging}" = yes)
|
|
|
|
|
2019-05-29 17:11:37 +08:00
|
|
|
# Similar to GDB_AC_CHECK_BFD.
|
|
|
|
OLD_CFLAGS=$CFLAGS
|
|
|
|
OLD_LDFLAGS=$LDFLAGS
|
|
|
|
OLD_LIBS=$LIBS
|
|
|
|
# Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS
|
|
|
|
# points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We
|
|
|
|
# always want our bfd.
|
|
|
|
CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
|
|
|
|
ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
|
|
|
|
LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
|
|
|
|
intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
|
|
|
|
LIBS="-lbfd -liberty -lz $intl $LIBS"
|
|
|
|
AC_CACHE_CHECK([for ELF support in BFD], ac_cv_libctf_bfd_elf,
|
|
|
|
[AC_TRY_LINK([#include <stdlib.h>
|
|
|
|
#include "bfd.h"
|
|
|
|
#include "elf-bfd.h"],
|
|
|
|
[(void) bfd_section_from_elf_index (NULL, 0);
|
|
|
|
return 0;],
|
|
|
|
[ac_cv_libctf_bfd_elf=yes],
|
|
|
|
[ac_cv_libctf_bfd_elf=no])])
|
|
|
|
CFLAGS=$OLD_CFLAGS
|
|
|
|
LDFLAGS=$OLD_LDFLAGS
|
|
|
|
LIBS=$OLD_LIBS
|
|
|
|
|
|
|
|
if test $ac_cv_libctf_bfd_elf = yes; then
|
|
|
|
AC_DEFINE([HAVE_BFD_ELF], 1,
|
|
|
|
[Whether libbfd was configured for an ELF target.])
|
|
|
|
fi
|
|
|
|
|
libctf: fix a number of build problems found on Solaris and NetBSD
- Use of nonportable <endian.h>
- Use of qsort_r
- Use of zlib without appropriate magic to pull in the binutils zlib
- Use of off64_t without checking (fixed by dropping the unused fields
that need off64_t entirely)
- signedness problems due to long being too short a type on 32-bit
platforms: ctf_id_t is now 'unsigned long', and CTF_ERR must be
used only for functions that return ctf_id_t
- One lingering use of bzero() and of <sys/errno.h>
All fixed, using code from gnulib where possible.
Relatedly, set cts_size in a couple of places it was missed
(string table and symbol table loading upon ctf_bfdopen()).
binutils/
* objdump.c (make_ctfsect): Drop cts_type, cts_flags, and
cts_offset.
* readelf.c (shdr_to_ctf_sect): Likewise.
include/
* ctf-api.h (ctf_sect_t): Drop cts_type, cts_flags, and cts_offset.
(ctf_id_t): This is now an unsigned type.
(CTF_ERR): Cast it to ctf_id_t. Note that it should only be used
for ctf_id_t-returning functions.
libctf/
* Makefile.am (ZLIB): New.
(ZLIBINC): Likewise.
(AM_CFLAGS): Use them.
(libctf_a_LIBADD): New, for LIBOBJS.
* configure.ac: Check for zlib, endian.h, and qsort_r.
* ctf-endian.h: New, providing htole64 and le64toh.
* swap.h: Code style fixes.
(bswap_identity_64): New.
* qsort_r.c: New, from gnulib (with one added #include).
* ctf-decls.h: New, providing a conditional qsort_r declaration,
and unconditional definitions of MIN and MAX.
* ctf-impl.h: Use it. Do not use <sys/errno.h>.
(ctf_set_errno): Now returns unsigned long.
* ctf-util.c (ctf_set_errno): Adjust here too.
* ctf-archive.c: Use ctf-endian.h.
(ctf_arc_open_by_offset): Use memset, not bzero. Drop cts_type,
cts_flags and cts_offset.
(ctf_arc_write): Drop debugging dependent on the size of off_t.
* ctf-create.c: Provide a definition of roundup if not defined.
(ctf_create): Drop cts_type, cts_flags and cts_offset.
(ctf_add_reftype): Do not check if type IDs are below zero.
(ctf_add_slice): Likewise.
(ctf_add_typedef): Likewise.
(ctf_add_member_offset): Cast error-returning ssize_t's to size_t
when known error-free. Drop CTF_ERR usage for functions returning
int.
(ctf_add_member_encoded): Drop CTF_ERR usage for functions returning
int.
(ctf_add_variable): Likewise.
(enumcmp): Likewise.
(enumadd): Likewise.
(membcmp): Likewise.
(ctf_add_type): Likewise. Cast error-returning ssize_t's to size_t
when known error-free.
* ctf-dump.c (ctf_is_slice): Drop CTF_ERR usage for functions
returning int: use CTF_ERR for functions returning ctf_type_id.
(ctf_dump_label): Likewise.
(ctf_dump_objts): Likewise.
* ctf-labels.c (ctf_label_topmost): Likewise.
(ctf_label_iter): Likewise.
(ctf_label_info): Likewise.
* ctf-lookup.c (ctf_func_args): Likewise.
* ctf-open.c (upgrade_types): Cast to size_t where appropriate.
(ctf_bufopen): Likewise. Use zlib types as needed.
* ctf-types.c (ctf_member_iter): Drop CTF_ERR usage for functions
returning int.
(ctf_enum_iter): Likewise.
(ctf_type_size): Likewise.
(ctf_type_align): Likewise. Cast to size_t where appropriate.
(ctf_type_kind_unsliced): Likewise.
(ctf_type_kind): Likewise.
(ctf_type_encoding): Likewise.
(ctf_member_info): Likewise.
(ctf_array_info): Likewise.
(ctf_enum_value): Likewise.
(ctf_type_rvisit): Likewise.
* ctf-open-bfd.c (ctf_bfdopen): Drop cts_type, cts_flags and
cts_offset.
(ctf_simple_open): Likewise.
(ctf_bfdopen_ctfsect): Likewise. Set cts_size properly.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* config.h: Likewise.
* configure: Likewise.
2019-05-31 17:10:51 +08:00
|
|
|
AC_C_BIGENDIAN
|
|
|
|
AC_CHECK_HEADERS(byteswap.h endian.h)
|
2019-04-24 18:49:48 +08:00
|
|
|
AC_CHECK_FUNCS(pread)
|
2019-06-03 21:02:09 +08:00
|
|
|
|
libctf, elfcpp, gold: do not assume that <byteswap.h> contains bswap_*
At least one C library (uclibc-ng) defines some of these only when
the compiler is GCC. We might as well test for all three cases and
handle any of them being missing.
Very similar code exists in libctf and split between elfcpp and gold:
fix both.
(Also sync up elfcpp with a change made to libctf swap.h a few months
ago: since there is no out-of-line definition of the bswap replacements,
they should be declared static inline, not just inline, to prevent the
linker generating out-of-line references to them.)
PR libctf/25120
libctf/
* configure.ac: Check for bswap_16, bswap_32, and bswap_64 decls.
* swap.h (bswap_16): Do not assume that presence of <byteswap.h>
means this is declared.
(bswap_32): Likewise.
(bswap_64): Likewise.
(bswap_identity_64): Remove, unused.
* configure: Regenerated.
* config.h.in: Likewise.
gold/
* configure.ac: Check for bswap_16, bswap_32, and bswap_64 decls.
* configure: Regenerated.
* config.h.in: Likewise.
elfcpp/
* elfcpp_swap.h (bswap_16): Do not assume that presence of
<byteswap.h> means this is declared. Make static inline, matching
recent change to libctf, since there is no non-inline definition
of these functions.
(bswap_32): Likewise.
(bswap_64): Likewise.
2019-12-13 23:19:17 +08:00
|
|
|
dnl Check for bswap_{16,32,64}
|
|
|
|
AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]])
|
2020-06-05 00:16:09 +08:00
|
|
|
AC_CHECK_DECLS([asprintf, vasprintf])
|
2020-01-05 13:50:27 +08:00
|
|
|
|
2019-06-03 21:02:09 +08:00
|
|
|
dnl Check for qsort_r. (Taken from gnulib.)
|
|
|
|
AC_CHECK_FUNCS_ONCE([qsort_r])
|
|
|
|
if test $ac_cv_func_qsort_r = yes; then
|
|
|
|
AC_CACHE_CHECK([for qsort_r signature], [ac_cv_libctf_qsort_r_signature],
|
|
|
|
[AC_LINK_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([[#undef qsort_r
|
|
|
|
#include <stdlib.h>
|
|
|
|
void qsort_r (void *, size_t, size_t,
|
|
|
|
int (*) (void const *, void const *,
|
|
|
|
void *),
|
|
|
|
void *);
|
|
|
|
void (*p) (void *, size_t, size_t,
|
|
|
|
int (*) (void const *, void const *,
|
|
|
|
void *),
|
|
|
|
void *) = qsort_r;
|
|
|
|
]])],
|
|
|
|
[ac_cv_libctf_qsort_r_signature=GNU],
|
|
|
|
[AC_LINK_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([[#undef qsort_r
|
|
|
|
#include <stdlib.h>
|
|
|
|
void qsort_r (void *, size_t, size_t, void *,
|
|
|
|
int (*) (void *,
|
|
|
|
void const *,
|
|
|
|
void const *));
|
|
|
|
void (*p) (void *, size_t, size_t, void *,
|
|
|
|
int (*) (void *, void const *,
|
|
|
|
void const *)) = qsort_r;
|
|
|
|
]])],
|
|
|
|
[ac_cv_libctf_qsort_r_signature=BSD],
|
|
|
|
[ac_cv_libctf_qsort_r_signature=unknown])])])
|
|
|
|
fi
|
|
|
|
|
|
|
|
case x$ac_cv_libctf_qsort_r_signature in
|
|
|
|
xGNU) AC_DEFINE([HAVE_QSORT_R_ARG_LAST], 1,
|
|
|
|
[Whether a qsort_r exists with a void *arg as its last arg.]);;
|
|
|
|
xBSD) AC_DEFINE([HAVE_QSORT_R_COMPAR_LAST], 1,
|
|
|
|
[Whether a qsort_r exists with the compar function as its last arg.]);;
|
|
|
|
*) ac_cv_libctf_qsort_r_signature=unknown;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
AM_CONDITIONAL(NEED_CTF_QSORT_R, test "${ac_cv_libctf_qsort_r_signature}" = unknown)
|
2019-04-24 18:49:48 +08:00
|
|
|
|
2019-06-04 22:04:49 +08:00
|
|
|
AC_CACHE_CHECK([for O_CLOEXEC], [ac_cv_libctf_macro_O_CLOEXEC],
|
|
|
|
[AC_LINK_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([[#include <fcntl.h>
|
|
|
|
#ifndef O_CLOEXEC
|
|
|
|
choke me;
|
|
|
|
#endif
|
|
|
|
]],
|
|
|
|
[[return O_CLOEXEC;]])],
|
|
|
|
[ac_cv_libctf_macro_O_CLOEXEC=yes],
|
|
|
|
[ac_cv_libctf_macro_O_CLOEXEC=no])])
|
|
|
|
|
|
|
|
if test $ac_cv_libctf_macro_O_CLOEXEC = yes; then
|
|
|
|
AC_DEFINE([HAVE_O_CLOEXEC], 1,
|
|
|
|
[Whether the platform has a definition of O_CLOEXEC.])
|
|
|
|
fi
|
|
|
|
|
libctf: installable libctf as a shared library
This lets other programs read and write CTF-format data.
Two versioned shared libraries are created: libctf.so and
libctf-nobfd.so. They contain identical content except that
libctf-nobfd.so contains no references to libbfd and does not implement
ctf_open, ctf_fdopen, ctf_bfdopen or ctf_bfdopen_ctfsect, so it can be
used by programs that cannot use BFD, like readelf.
The soname major version is presently .0 until the linker API
stabilizes, when it will flip to .1 and hopefully never change again.
New in v3.
v4: libtoolize and turn into a pair of shared libraries. Drop
--enable-install-ctf: now controlled by --enable-shared and
--enable-install-libbfd, like everything else.
v5: Add ../bfd to ACLOCAL_AMFLAGS and AC_CONFIG_MACRO_DIR. Fix tabdamage.
* Makefile.def (host_modules): libctf is no longer no_install.
* Makefile.in: Regenerated.
libctf/
* configure.ac (AC_DISABLE_SHARED): New, like opcodes/.
(LT_INIT): Likewise.
(AM_INSTALL_LIBBFD): Likewise.
(dlopen): Note why this is necessary in a comment.
(SHARED_LIBADD): Initialize for possibly-PIC libiberty: derived from
opcodes/.
(SHARED_LDFLAGS): Likewise.
(BFD_LIBADD): Likewise, for libbfd.
(BFD_DEPENDENCIES): Likewise.
(VERSION_FLAGS): Initialize, using a version script if ld supports
one, or libtool -export-symbols-regex otherwise.
(AC_CONFIG_MACRO_DIR): Add ../BFD.
* Makefile.am (ACLOCAL_AMFLAGS): Likewise.
(INCDIR): New.
(AM_CPPFLAGS): Use $(srcdir), not $(top_srcdir).
(noinst_LIBRARIES): Replace with...
[INSTALL_LIBBFD] (lib_LTLIBRARIES): This, or...
[!INSTALL_LIBBFD] (noinst_LTLIBRARIES): ... this, mentioning new
libctf-nobfd.la as well.
[INSTALL_LIBCTF] (include_HEADERS): Add the CTF headers.
[!INSTALL_LIBCTF] (include_HEADERS): New, empty.
(libctf_a_SOURCES): Rename to...
(libctf_nobfd_la_SOURCES): ... this, all of libctf other than
ctf-open-bfd.c.
(libctf_la_SOURCES): Now derived from libctf_nobfd_la_SOURCES,
with ctf-open-bfd.c added.
(libctf_nobfd_la_LIBADD): New, using @SHARED_LIBADD@.
(libctf_la_LIBADD): New, using @BFD_LIBADD@ as well.
(libctf_la_DEPENDENCIES): New, using @BFD_DEPENDENCIES@.
* Makefile.am [INSTALL_LIBCTF]: Use it.
* aclocal.m4: Add ../bfd/acinclude.m4, ../config/acx.m4, and the
libtool macros.
* libctf.ver: New, everything is version LIBCTF_1.0 currently (even
the unstable components).
* Makefile.in: Regenerated.
* config.h.in: Likewise.
* configure: Likewise.
binutils/
* Makefile.am (LIBCTF): Mention the .la file.
(LIBCTF_NOBFD): New.
(readelf_DEPENDENCIES): Use it.
(readelf_LDADD): Likewise.
* Makefile.in: Regenerated.
ld/
* configure.ac (TESTCTFLIB): Set to the .so or .a, like TESTBFDLIB.
* Makefile.am (TESTCTFLIB): Use it.
(LIBCTF): Use the .la file.
(check-DEJAGNU): Use it.
* Makefile.in: Regenerated.
* configure: Likewise.
include/
* ctf-api.h: Note the instability of the ctf_link interfaces.
2019-07-20 21:45:12 +08:00
|
|
|
# Horrible hacks to build DLLs on Windows and a shared library elsewhere.
|
|
|
|
SHARED_LIBADD=
|
|
|
|
SHARED_LDFLAGS=
|
|
|
|
BFD_LIBADD=
|
|
|
|
BFD_DEPENDENCIES=
|
|
|
|
if test "$enable_shared" = "yes"; then
|
|
|
|
# When building a shared libctf, link against the pic version of libiberty
|
|
|
|
# so that apps that use libctf won't need libiberty just to satisfy any
|
|
|
|
# libctf references.
|
|
|
|
# We can't do that if a pic libiberty is unavailable since including non-pic
|
|
|
|
# code would insert text relocations into libctf.
|
|
|
|
# Note that linking against libbfd as we do here, which is itself linked
|
|
|
|
# against libiberty, may not satisfy all the libctf libiberty references
|
|
|
|
# since libbfd may not pull in the entirety of libiberty.
|
|
|
|
changequote(,)dnl
|
|
|
|
x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'`
|
|
|
|
changequote([,])dnl
|
|
|
|
if test -n "$x"; then
|
|
|
|
SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "${host}" in
|
|
|
|
# More hacks to build DLLs on Windows.
|
|
|
|
*-*-cygwin*)
|
|
|
|
SHARED_LDFLAGS="-no-undefined"
|
|
|
|
SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin"
|
|
|
|
BFD_LIBADD="-L`pwd`/../bfd -lbfd"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*-*-darwin*)
|
|
|
|
BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.dylib"
|
|
|
|
BFD_DEPENDENCIES="../bfd/libbfd.la"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
case "$host_vendor" in
|
|
|
|
hp)
|
|
|
|
BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
BFD_DEPENDENCIES="../bfd/libbfd.la"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
AC_SUBST(SHARED_LDFLAGS)
|
|
|
|
AC_SUBST(SHARED_LIBADD)
|
|
|
|
AC_SUBST(BFD_LIBADD)
|
|
|
|
AC_SUBST(BFD_DEPENDENCIES)
|
|
|
|
|
|
|
|
# Use a version script, if possible, or an -export-symbols-regex otherwise.
|
|
|
|
VERSION_FLAGS='-export-symbols-regex ctf_.*'
|
|
|
|
if $LD --help 2>&1 | grep -- --version-script >/dev/null; then
|
|
|
|
VERSION_FLAGS="-Wl,--version-script='$srcdir/libctf.ver'"
|
|
|
|
fi
|
|
|
|
AC_SUBST(VERSION_FLAGS)
|
|
|
|
|
2019-04-24 18:49:48 +08:00
|
|
|
AC_CONFIG_FILES(Makefile)
|
|
|
|
AC_CONFIG_HEADERS(config.h)
|
|
|
|
AC_OUTPUT
|