Browse Source

libbacktrace: add preliminary Mach-O support

lib
Ian Lance Taylor 2 years ago
parent
commit
4e548e735f
  1. 68
      Makefile.am
  2. 123
      Makefile.in
  3. 3
      config.h.in
  4. 78
      configure
  5. 10
      configure.ac
  6. 19
      filetype.awk
  7. 1309
      macho.c

68
Makefile.am

@ -57,6 +57,7 @@ BACKTRACE_FILES = \ @@ -57,6 +57,7 @@ BACKTRACE_FILES = \
FORMAT_FILES = \
elf.c \
macho.c \
pecoff.c \
unknown.c \
xcoff.c
@ -85,18 +86,28 @@ libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD) @@ -85,18 +86,28 @@ libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
# Testsuite.
# Add test to this variable, if you want it to be build.
# Add a test to this variable if you want it to be built.
check_PROGRAMS =
# Add test to this variable, if you want it to be run.
# Add a test to this variable if you want it to be run.
TESTS =
# Add test to this variable, if you want it to be build and run.
# Add a test to this variable if you want it to be built and run.
BUILDTESTS =
# Add a file to this variable if you want it to be built for testing.
check_DATA =
# Flags to use when compiling test programs.
libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
if HAVE_DSYMUTIL
%.dSYM: %
$(DSYMUTIL) $<
endif HAVE_DSYMUTIL
if NATIVE
check_LTLIBRARIES = libbacktrace_alloc.la
@ -164,6 +175,12 @@ test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo @@ -164,6 +175,12 @@ test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo
BUILDTESTS += test_elf_64
test_macho_SOURCES = test_format.c testlib.c
test_macho_CFLAGS = $(libbacktrace_TEST_CFLAGS)
test_macho_LDADD = libbacktrace_noformat.la macho.lo
BUILDTESTS += test_macho
test_xcoff_32_SOURCES = test_format.c testlib.c
test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
@ -221,6 +238,10 @@ allocfail.sh: allocfail @@ -221,6 +238,10 @@ allocfail.sh: allocfail
TESTS += allocfail.sh
if HAVE_DSYMUTIL
check_DATA += allocfail.dSYM
endif HAVE_DSYMUTIL
if HAVE_ELF
if HAVE_OBJCOPY_DEBUGLINK
@ -253,6 +274,10 @@ btest_LDADD = libbacktrace.la @@ -253,6 +274,10 @@ btest_LDADD = libbacktrace.la
BUILDTESTS += btest
if HAVE_DSYMUTIL
check_DATA += btest.dSYM
endif HAVE_DSYMUTIL
if HAVE_ELF
btest_lto_SOURCES = btest.c testlib.c
@ -269,6 +294,10 @@ btest_alloc_LDADD = libbacktrace_alloc.la @@ -269,6 +294,10 @@ btest_alloc_LDADD = libbacktrace_alloc.la
BUILDTESTS += btest_alloc
if HAVE_DSYMUTIL
check_DATA += btest_alloc.dSYM
endif HAVE_DSYMUTIL
if HAVE_DWZ
%_dwz: %
@ -295,12 +324,20 @@ stest_LDADD = libbacktrace.la @@ -295,12 +324,20 @@ stest_LDADD = libbacktrace.la
BUILDTESTS += stest
if HAVE_DSYMUTIL
check_DATA += stest.dSYM
endif HAVE_DSYMUTIL
stest_alloc_SOURCES = $(stest_SOURCES)
stest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
stest_alloc_LDADD = libbacktrace_alloc.la
BUILDTESTS += stest_alloc
if HAVE_DSYMUTIL
check_DATA += stest_alloc.dSYM
endif HAVE_DSYMUTIL
if HAVE_ELF
ztest_SOURCES = ztest.c testlib.c
@ -330,10 +367,18 @@ edtest_LDADD = libbacktrace.la @@ -330,10 +367,18 @@ edtest_LDADD = libbacktrace.la
BUILDTESTS += edtest
if HAVE_DSYMUTIL
check_DATA += edtest.dSYM
endif HAVE_DSYMUTIL
edtest_alloc_SOURCES = $(edtest_SOURCES)
edtest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
edtest_alloc_LDADD = libbacktrace_alloc.la
if HAVE_DSYMUTIL
check_DATA += edtest_alloc.dSYM
endif HAVE_DSYMUTIL
BUILDTESTS += edtest_alloc
edtest2_build.c: gen_edtest2_build; @true
@ -350,12 +395,20 @@ ttest_SOURCES = ttest.c testlib.c @@ -350,12 +395,20 @@ ttest_SOURCES = ttest.c testlib.c
ttest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -pthread
ttest_LDADD = libbacktrace.la
if HAVE_DSYMUTIL
check_DATA += ttest.dSYM
endif HAVE_DSYMUTIL
BUILDTESTS += ttest_alloc
ttest_alloc_SOURCES = $(ttest_SOURCES)
ttest_alloc_CFLAGS = $(ttest_CFLAGS)
ttest_alloc_LDADD = libbacktrace_alloc.la
if HAVE_DSYMUTIL
check_DATA += ttest_alloc.dSYM
endif HAVE_DSYMUTIL
endif HAVE_PTHREAD
if HAVE_OBJCOPY_DEBUGLINK
@ -410,12 +463,20 @@ dwarf5_LDADD = libbacktrace.la @@ -410,12 +463,20 @@ dwarf5_LDADD = libbacktrace.la
BUILDTESTS += dwarf5
if HAVE_DSYMUTIL
check_DATA += dwarf5.dSYM
endif HAVE_DSYMUTIL
dwarf5_alloc_SOURCES = $(dwarf5_SOURCES)
dwarf5_alloc_CFLAGS = $(dwarf5_CFLAGS)
dwarf5_alloc_LDADD = libbacktrace_alloc.la
BUILDTESTS += dwarf5_alloc
if HAVE_DSYMUTIL
check_DATA += dwarf5_alloc.dSYM
endif HAVE_DSYMUTIL
endif
endif NATIVE
@ -447,6 +508,7 @@ btest.lo: filenames.h backtrace.h backtrace-supported.h @@ -447,6 +508,7 @@ btest.lo: filenames.h backtrace.h backtrace-supported.h
dwarf.lo: config.h filenames.h backtrace.h internal.h
elf.lo: config.h backtrace.h internal.h
fileline.lo: config.h backtrace.h internal.h
macho.lo: config.h backtrace.h internal.h
mmap.lo: config.h backtrace.h internal.h
mmapio.lo: config.h backtrace.h internal.h
nounwind.lo: config.h internal.h

123
Makefile.in

@ -123,33 +123,41 @@ host_triplet = @host@ @@ -123,33 +123,41 @@ host_triplet = @host@
target_triplet = @target@
check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
$(am__EXEEXT_12)
TESTS = $(am__append_4) $(am__append_6) $(am__append_8) \
$(am__append_11) $(am__append_12) $(am__append_18) \
TESTS = $(am__append_4) $(am__append_7) $(am__append_9) \
$(am__append_12) $(am__append_13) $(am__append_20) \
$(am__EXEEXT_12)
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_1 = libbacktrace_elf_for_test.la
@NATIVE_TRUE@am__append_2 = test_elf_32 test_elf_64 test_xcoff_32 \
@NATIVE_TRUE@ test_xcoff_64 test_pecoff test_unknown unittest \
@NATIVE_TRUE@ unittest_alloc btest
@NATIVE_TRUE@am__append_2 = test_elf_32 test_elf_64 test_macho \
@NATIVE_TRUE@ test_xcoff_32 test_xcoff_64 test_pecoff \
@NATIVE_TRUE@ test_unknown unittest unittest_alloc btest
@NATIVE_TRUE@am__append_3 = allocfail
@NATIVE_TRUE@am__append_4 = allocfail.sh
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_5 = b2test
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_6 = b2test_buildid
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_7 = b3test
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_8 = b3test_dwz_buildid
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_9 = btest_lto
@NATIVE_TRUE@am__append_10 = btest_alloc stest stest_alloc
@HAVE_DWZ_TRUE@@NATIVE_TRUE@am__append_11 = btest_dwz
@HAVE_DWZ_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_12 = btest_dwz_gnudebuglink
@HAVE_ELF_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_13 = -lz
@HAVE_DSYMUTIL_TRUE@@NATIVE_TRUE@am__append_5 = allocfail.dSYM \
@HAVE_DSYMUTIL_TRUE@@NATIVE_TRUE@ btest.dSYM btest_alloc.dSYM \
@HAVE_DSYMUTIL_TRUE@@NATIVE_TRUE@ stest.dSYM stest_alloc.dSYM \
@HAVE_DSYMUTIL_TRUE@@NATIVE_TRUE@ edtest.dSYM edtest_alloc.dSYM
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_6 = b2test
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_7 = b2test_buildid
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_8 = b3test
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_9 = b3test_dwz_buildid
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_10 = btest_lto
@NATIVE_TRUE@am__append_11 = btest_alloc stest stest_alloc
@HAVE_DWZ_TRUE@@NATIVE_TRUE@am__append_12 = btest_dwz
@HAVE_DWZ_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_13 = btest_dwz_gnudebuglink
@HAVE_ELF_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_14 = -lz
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_15 = ztest ztest_alloc
@NATIVE_TRUE@am__append_16 = edtest edtest_alloc
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_17 = ttest ttest_alloc
@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_18 = btest_gnudebuglink
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_19 = ctestg ctesta \
@HAVE_ELF_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_15 = -lz
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_16 = ztest ztest_alloc
@NATIVE_TRUE@am__append_17 = edtest edtest_alloc
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_18 = ttest ttest_alloc
@HAVE_DSYMUTIL_TRUE@@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_19 = ttest.dSYM \
@HAVE_DSYMUTIL_TRUE@@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ ttest_alloc.dSYM
@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_20 = btest_gnudebuglink
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_21 = ctestg ctesta \
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctestg_alloc \
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctesta_alloc
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__append_20 = dwarf5 dwarf5_alloc
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__append_22 = dwarf5 dwarf5_alloc
@HAVE_DSYMUTIL_TRUE@@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__append_23 = dwarf5.dSYM \
@HAVE_DSYMUTIL_TRUE@@HAVE_DWARF5_TRUE@@NATIVE_TRUE@ dwarf5_alloc.dSYM
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/config/lead-dot.m4 \
@ -235,10 +243,10 @@ libbacktrace_noformat_la_OBJECTS = \ @@ -235,10 +243,10 @@ libbacktrace_noformat_la_OBJECTS = \
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = b2test$(EXEEXT)
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_3 = b3test$(EXEEXT)
@NATIVE_TRUE@am__EXEEXT_4 = test_elf_32$(EXEEXT) test_elf_64$(EXEEXT) \
@NATIVE_TRUE@ test_xcoff_32$(EXEEXT) test_xcoff_64$(EXEEXT) \
@NATIVE_TRUE@ test_pecoff$(EXEEXT) test_unknown$(EXEEXT) \
@NATIVE_TRUE@ unittest$(EXEEXT) unittest_alloc$(EXEEXT) \
@NATIVE_TRUE@ btest$(EXEEXT)
@NATIVE_TRUE@ test_macho$(EXEEXT) test_xcoff_32$(EXEEXT) \
@NATIVE_TRUE@ test_xcoff_64$(EXEEXT) test_pecoff$(EXEEXT) \
@NATIVE_TRUE@ test_unknown$(EXEEXT) unittest$(EXEEXT) \
@NATIVE_TRUE@ unittest_alloc$(EXEEXT) btest$(EXEEXT)
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__EXEEXT_5 = btest_lto$(EXEEXT)
@NATIVE_TRUE@am__EXEEXT_6 = btest_alloc$(EXEEXT) stest$(EXEEXT) \
@NATIVE_TRUE@ stest_alloc$(EXEEXT)
@ -405,6 +413,14 @@ test_elf_64_OBJECTS = $(am_test_elf_64_OBJECTS) @@ -405,6 +413,14 @@ test_elf_64_OBJECTS = $(am_test_elf_64_OBJECTS)
test_elf_64_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_elf_64_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
@NATIVE_TRUE@am_test_macho_OBJECTS = test_macho-test_format.$(OBJEXT) \
@NATIVE_TRUE@ test_macho-testlib.$(OBJEXT)
test_macho_OBJECTS = $(am_test_macho_OBJECTS)
@NATIVE_TRUE@test_macho_DEPENDENCIES = libbacktrace_noformat.la \
@NATIVE_TRUE@ macho.lo
test_macho_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_macho_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
@NATIVE_TRUE@am_test_pecoff_OBJECTS = \
@NATIVE_TRUE@ test_pecoff-test_format.$(OBJEXT) \
@NATIVE_TRUE@ test_pecoff-testlib.$(OBJEXT)
@ -543,10 +559,10 @@ SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \ @@ -543,10 +559,10 @@ SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
$(dwarf5_alloc_SOURCES) $(edtest_SOURCES) \
$(edtest_alloc_SOURCES) $(stest_SOURCES) \
$(stest_alloc_SOURCES) $(test_elf_32_SOURCES) \
$(test_elf_64_SOURCES) $(test_pecoff_SOURCES) \
$(test_unknown_SOURCES) $(test_xcoff_32_SOURCES) \
$(test_xcoff_64_SOURCES) $(ttest_SOURCES) \
$(ttest_alloc_SOURCES) $(unittest_SOURCES) \
$(test_elf_64_SOURCES) $(test_macho_SOURCES) \
$(test_pecoff_SOURCES) $(test_unknown_SOURCES) \
$(test_xcoff_32_SOURCES) $(test_xcoff_64_SOURCES) \
$(ttest_SOURCES) $(ttest_alloc_SOURCES) $(unittest_SOURCES) \
$(unittest_alloc_SOURCES) $(ztest_SOURCES) \
$(ztest_alloc_SOURCES)
am__can_run_installinfo = \
@ -906,6 +922,7 @@ BACKTRACE_FILES = \ @@ -906,6 +922,7 @@ BACKTRACE_FILES = \
FORMAT_FILES = \
elf.c \
macho.c \
pecoff.c \
unknown.c \
xcoff.c
@ -932,10 +949,13 @@ libbacktrace_la_LIBADD = \ @@ -932,10 +949,13 @@ libbacktrace_la_LIBADD = \
libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
# Add test to this variable, if you want it to be build and run.
BUILDTESTS = $(am__append_2) $(am__append_9) $(am__append_10) \
$(am__append_15) $(am__append_16) $(am__append_17) \
$(am__append_19) $(am__append_20)
# Add a test to this variable if you want it to be built and run.
BUILDTESTS = $(am__append_2) $(am__append_10) $(am__append_11) \
$(am__append_16) $(am__append_17) $(am__append_18) \
$(am__append_21) $(am__append_22)
# Add a file to this variable if you want it to be built for testing.
check_DATA = $(am__append_5) $(am__append_19) $(am__append_23)
# Flags to use when compiling test programs.
libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
@ -959,6 +979,9 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g @@ -959,6 +979,9 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
@NATIVE_TRUE@test_elf_64_SOURCES = test_format.c testlib.c
@NATIVE_TRUE@test_elf_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
@NATIVE_TRUE@test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo
@NATIVE_TRUE@test_macho_SOURCES = test_format.c testlib.c
@NATIVE_TRUE@test_macho_CFLAGS = $(libbacktrace_TEST_CFLAGS)
@NATIVE_TRUE@test_macho_LDADD = libbacktrace_noformat.la macho.lo
@NATIVE_TRUE@test_xcoff_32_SOURCES = test_format.c testlib.c
@NATIVE_TRUE@test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
@NATIVE_TRUE@test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
@ -1013,10 +1036,10 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g @@ -1013,10 +1036,10 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c
@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_LDADD = libbacktrace.la \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__append_13) \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__append_14) \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(CLOCK_GETTIME_LINK)
@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_LDADD = libbacktrace_alloc.la \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__append_14) \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__append_15) \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(CLOCK_GETTIME_LINK)
@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_SOURCES = $(ztest_SOURCES)
@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_CFLAGS = $(ztest_CFLAGS)
@ -1255,6 +1278,10 @@ test_elf_64$(EXEEXT): $(test_elf_64_OBJECTS) $(test_elf_64_DEPENDENCIES) $(EXTRA @@ -1255,6 +1278,10 @@ test_elf_64$(EXEEXT): $(test_elf_64_OBJECTS) $(test_elf_64_DEPENDENCIES) $(EXTRA
@rm -f test_elf_64$(EXEEXT)
$(AM_V_CCLD)$(test_elf_64_LINK) $(test_elf_64_OBJECTS) $(test_elf_64_LDADD) $(LIBS)
test_macho$(EXEEXT): $(test_macho_OBJECTS) $(test_macho_DEPENDENCIES) $(EXTRA_test_macho_DEPENDENCIES)
@rm -f test_macho$(EXEEXT)
$(AM_V_CCLD)$(test_macho_LINK) $(test_macho_OBJECTS) $(test_macho_LDADD) $(LIBS)
test_pecoff$(EXEEXT): $(test_pecoff_OBJECTS) $(test_pecoff_DEPENDENCIES) $(EXTRA_test_pecoff_DEPENDENCIES)
@rm -f test_pecoff$(EXEEXT)
$(AM_V_CCLD)$(test_pecoff_LINK) $(test_pecoff_OBJECTS) $(test_pecoff_LDADD) $(LIBS)
@ -1526,6 +1553,18 @@ test_elf_64-testlib.o: testlib.c @@ -1526,6 +1553,18 @@ test_elf_64-testlib.o: testlib.c
test_elf_64-testlib.obj: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_elf_64_CFLAGS) $(CFLAGS) -c -o test_elf_64-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
test_macho-test_format.o: test_format.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_macho_CFLAGS) $(CFLAGS) -c -o test_macho-test_format.o `test -f 'test_format.c' || echo '$(srcdir)/'`test_format.c
test_macho-test_format.obj: test_format.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_macho_CFLAGS) $(CFLAGS) -c -o test_macho-test_format.obj `if test -f 'test_format.c'; then $(CYGPATH_W) 'test_format.c'; else $(CYGPATH_W) '$(srcdir)/test_format.c'; fi`
test_macho-testlib.o: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_macho_CFLAGS) $(CFLAGS) -c -o test_macho-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
test_macho-testlib.obj: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_macho_CFLAGS) $(CFLAGS) -c -o test_macho-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
test_pecoff-test_format.o: test_format.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_pecoff_CFLAGS) $(CFLAGS) -c -o test_pecoff-test_format.o `test -f 'test_format.c' || echo '$(srcdir)/'`test_format.c
@ -1865,7 +1904,7 @@ check-TESTS: @@ -1865,7 +1904,7 @@ check-TESTS:
log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
exit $$?;
recheck: all $(check_LTLIBRARIES) $(check_PROGRAMS)
recheck: all $(check_LTLIBRARIES) $(check_PROGRAMS) $(check_DATA)
@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
@set +e; $(am__set_TESTS_bases); \
bases=`for i in $$bases; do echo $$i; done \
@ -1932,6 +1971,13 @@ test_elf_64.log: test_elf_64$(EXEEXT) @@ -1932,6 +1971,13 @@ test_elf_64.log: test_elf_64$(EXEEXT)
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
test_macho.log: test_macho$(EXEEXT)
@p='test_macho$(EXEEXT)'; \
b='test_macho'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
test_xcoff_32.log: test_xcoff_32$(EXEEXT)
@p='test_xcoff_32$(EXEEXT)'; \
b='test_xcoff_32'; \
@ -2108,7 +2154,8 @@ dwarf5_alloc.log: dwarf5_alloc$(EXEEXT) @@ -2108,7 +2154,8 @@ dwarf5_alloc.log: dwarf5_alloc$(EXEEXT)
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS)
$(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS) \
$(check_DATA)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS) config.h
@ -2245,6 +2292,9 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES @@ -2245,6 +2292,9 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
.PRECIOUS: Makefile
@HAVE_DSYMUTIL_TRUE@%.dSYM: %
@HAVE_DSYMUTIL_TRUE@ $(DSYMUTIL) $<
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@elf_for_test.c: elf.c
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ SEARCH='^#define SYSTEM_BUILD_ID_DIR.*$$'; \
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ REPLACE="#define SYSTEM_BUILD_ID_DIR \"$(TEST_BUILD_ID_DIR)\""; \
@ -2320,6 +2370,7 @@ btest.lo: filenames.h backtrace.h backtrace-supported.h @@ -2320,6 +2370,7 @@ btest.lo: filenames.h backtrace.h backtrace-supported.h
dwarf.lo: config.h filenames.h backtrace.h internal.h
elf.lo: config.h backtrace.h internal.h
fileline.lo: config.h backtrace.h internal.h
macho.lo: config.h backtrace.h internal.h
mmap.lo: config.h backtrace.h internal.h
mmapio.lo: config.h backtrace.h internal.h
nounwind.lo: config.h internal.h

3
config.h.in

@ -51,6 +51,9 @@ @@ -51,6 +51,9 @@
/* Define to 1 if you have the `lstat' function. */
#undef HAVE_LSTAT
/* Define to 1 if you have the <mach-o/dyld.h> header file. */
#undef HAVE_MACH_O_DYLD_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

78
configure vendored

@ -635,6 +635,8 @@ LTLIBOBJS @@ -635,6 +635,8 @@ LTLIBOBJS
LIBOBJS
NATIVE_FALSE
NATIVE_TRUE
HAVE_DSYMUTIL_FALSE
HAVE_DSYMUTIL_TRUE
HAVE_OBJCOPY_DEBUGLINK_FALSE
HAVE_OBJCOPY_DEBUGLINK_TRUE
READELF
@ -799,7 +801,8 @@ LDFLAGS @@ -799,7 +801,8 @@ LDFLAGS
LIBS
CPPFLAGS
CPP
OBJCOPY'
OBJCOPY
DSYMUTIL'
# Initialize some variables set by options.
@ -1452,6 +1455,7 @@ Some influential environment variables: @@ -1452,6 +1455,7 @@ Some influential environment variables:
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
OBJCOPY location of objcopy
DSYMUTIL location of dsymutil
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@ -11265,7 +11269,7 @@ else @@ -11265,7 +11269,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11268 "configure"
#line 11272 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -11371,7 +11375,7 @@ else @@ -11371,7 +11375,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11374 "configure"
#line 11378 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -12176,6 +12180,7 @@ FORMAT_FILE= @@ -12176,6 +12180,7 @@ FORMAT_FILE=
backtrace_supports_data=yes
case "$libbacktrace_cv_sys_filetype" in
elf*) FORMAT_FILE="elf.lo" ;;
macho) FORMAT_FILE="macho.lo" ;;
pecoff) FORMAT_FILE="pecoff.lo"
backtrace_supports_data=no
;;
@ -12355,6 +12360,20 @@ $as_echo "#define HAVE_DL_ITERATE_PHDR 1" >>confdefs.h @@ -12355,6 +12360,20 @@ $as_echo "#define HAVE_DL_ITERATE_PHDR 1" >>confdefs.h
fi
# Check for header file for Mach-O image functions.
for ac_header in mach-o/dyld.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "mach-o/dyld.h" "ac_cv_header_mach_o_dyld_h" "$ac_includes_default"
if test "x$ac_cv_header_mach_o_dyld_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MACH_O_DYLD_H 1
_ACEOF
fi
done
# Check for loadquery.
for ac_header in sys/ldr.h
do :
@ -12840,6 +12859,8 @@ if ${libbacktrace_cv_objcopy_debuglink+:} false; then : @@ -12840,6 +12859,8 @@ if ${libbacktrace_cv_objcopy_debuglink+:} false; then :
else
if test -n "${with_target_subdir}"; then
libbacktrace_cv_objcopy_debuglink=no
elif ! test -n "${OBJCOPY}"; then
libbacktrace_cv_objcopy_debuglink=no
elif ${OBJCOPY} --add-gnu-debuglink=x /bin/ls /tmp/ls$$; then
rm -f /tmp/ls$$
libbacktrace_cv_objcopy_debuglink=yes
@ -12858,6 +12879,53 @@ else @@ -12858,6 +12879,53 @@ else
fi
# Extract the first word of "dsymutil", so it can be a program name with args.
set dummy dsymutil; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_DSYMUTIL+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$DSYMUTIL"; then
ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_DSYMUTIL="dsymutil"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
DSYMUTIL=$ac_cv_prog_DSYMUTIL
if test -n "$DSYMUTIL"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
$as_echo "$DSYMUTIL" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test -n "${DSYMUTIL}"; then
HAVE_DSYMUTIL_TRUE=
HAVE_DSYMUTIL_FALSE='#'
else
HAVE_DSYMUTIL_TRUE='#'
HAVE_DSYMUTIL_FALSE=
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether tests can run" >&5
$as_echo_n "checking whether tests can run... " >&6; }
if ${libbacktrace_cv_sys_native+:} false; then :
@ -13070,6 +13138,10 @@ if test -z "${HAVE_OBJCOPY_DEBUGLINK_TRUE}" && test -z "${HAVE_OBJCOPY_DEBUGLINK @@ -13070,6 +13138,10 @@ if test -z "${HAVE_OBJCOPY_DEBUGLINK_TRUE}" && test -z "${HAVE_OBJCOPY_DEBUGLINK
as_fn_error $? "conditional \"HAVE_OBJCOPY_DEBUGLINK\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_DSYMUTIL_TRUE}" && test -z "${HAVE_DSYMUTIL_FALSE}"; then
as_fn_error $? "conditional \"HAVE_DSYMUTIL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NATIVE_TRUE}" && test -z "${NATIVE_FALSE}"; then
as_fn_error $? "conditional \"NATIVE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5

10
configure.ac

@ -238,6 +238,7 @@ FORMAT_FILE= @@ -238,6 +238,7 @@ FORMAT_FILE=
backtrace_supports_data=yes
case "$libbacktrace_cv_sys_filetype" in
elf*) FORMAT_FILE="elf.lo" ;;
macho) FORMAT_FILE="macho.lo" ;;
pecoff) FORMAT_FILE="pecoff.lo"
backtrace_supports_data=no
;;
@ -346,6 +347,9 @@ if test "$have_dl_iterate_phdr" = "yes"; then @@ -346,6 +347,9 @@ if test "$have_dl_iterate_phdr" = "yes"; then
AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
fi
# Check for header file for Mach-O image functions.
AC_CHECK_HEADERS(mach-o/dyld.h)
# Check for loadquery.
AC_CHECK_HEADERS(sys/ldr.h)
if test "$ac_cv_header_sys_ldr_h" = "no"; then
@ -490,6 +494,8 @@ AC_CACHE_CHECK([whether objcopy supports debuglink], @@ -490,6 +494,8 @@ AC_CACHE_CHECK([whether objcopy supports debuglink],
[libbacktrace_cv_objcopy_debuglink],
[if test -n "${with_target_subdir}"; then
libbacktrace_cv_objcopy_debuglink=no
elif ! test -n "${OBJCOPY}"; then
libbacktrace_cv_objcopy_debuglink=no
elif ${OBJCOPY} --add-gnu-debuglink=x /bin/ls /tmp/ls$$; then
rm -f /tmp/ls$$
libbacktrace_cv_objcopy_debuglink=yes
@ -498,6 +504,10 @@ else @@ -498,6 +504,10 @@ else
fi])
AM_CONDITIONAL(HAVE_OBJCOPY_DEBUGLINK, test "$libbacktrace_cv_objcopy_debuglink" = yes)
AC_ARG_VAR(DSYMUTIL, [location of dsymutil])
AC_CHECK_PROG(DSYMUTIL, dsymutil, dsymutil)
AM_CONDITIONAL(HAVE_DSYMUTIL, test -n "${DSYMUTIL}")
AC_CACHE_CHECK([whether tests can run],
[libbacktrace_cv_sys_native],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],

19
filetype.awk

@ -1,8 +1,13 @@ @@ -1,8 +1,13 @@
# An awk script to determine the type of a file.
/\177ELF\001/ { if (NR == 1) { print "elf32"; exit } }
/\177ELF\002/ { if (NR == 1) { print "elf64"; exit } }
/\114\001/ { if (NR == 1) { print "pecoff"; exit } }
/\144\206/ { if (NR == 1) { print "pecoff"; exit } }
/\001\337/ { if (NR == 1) { print "xcoff32"; exit } }
/\001\367/ { if (NR == 1) { print "xcoff64"; exit } }
/\177ELF\001/ { if (NR == 1) { print "elf32"; exit } }
/\177ELF\002/ { if (NR == 1) { print "elf64"; exit } }
/\114\001/ { if (NR == 1) { print "pecoff"; exit } }
/\144\206/ { if (NR == 1) { print "pecoff"; exit } }
/\001\337/ { if (NR == 1) { print "xcoff32"; exit } }
/\001\367/ { if (NR == 1) { print "xcoff64"; exit } }
/\376\355\372\316/ { if (NR == 1) { print "macho"; exit } }
/\316\372\355\376/ { if (NR == 1) { print "macho"; exit } }
/\376\355\372\317/ { if (NR == 1) { print "macho"; exit } }
/\317\372\355\376/ { if (NR == 1) { print "macho"; exit } }
/\312\376\272\276/ { if (NR == 1) { print "macho"; exit } }
/\276\272\376\312/ { if (NR == 1) { print "macho"; exit } }

1309
macho.c

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save