1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
From d9c203a8680e2e7088b29540fe64de08966bd86d Mon Sep 17 00:00:00 2001
From: Priit Laes <plaes@plaes.org>
Date: Sun, 21 Feb 2010 14:18:43 +0200
Subject: [PATCH 3/3] Add option to use system bfd.
---
backend/os/Makefile.am | 13 +++++++++++--
backend/os/bfdglue.c | 8 +++++++-
configure.in | 14 ++++++++++++++
3 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/backend/os/Makefile.am b/backend/os/Makefile.am
index 2a9f019..b4ca82c 100644
--- a/backend/os/Makefile.am
+++ b/backend/os/Makefile.am
@@ -1,15 +1,24 @@
+if !SYSTEM_LIBBFD
SUBDIRS = bfd
+libbfd_libs = bfd/opcodes/libopcodes.la bfd/libbfd.la
+libbfd_includes = -I$(srcdir)/bfd -I$(srcdir)/bfd/include -I$(srcdir)/bfd/opcodes
+else
+libbfd_libs = -lopcodes -lbfd
+libbfd_includes =
+endif
+
+
noinst_LTLIBRARIES = libmonodebuggerbfdglue.la
libmonodebuggerbfdglue_la_SOURCES = \
bfdglue.c \
bfdglue.h
-libmonodebuggerbfdglue_la_LIBADD = bfd/opcodes/libopcodes.la bfd/libbfd.la @BASE_DEPENDENCIES_LIBS@
+libmonodebuggerbfdglue_la_LIBADD = $(libbfd_libs) @BASE_DEPENDENCIES_LIBS@
libmonodebuggerbfdglue_la_LDFLAGS = -no-undefined -module -export-dynamic -shared
-INCLUDES = -I$(srcdir)/bfd -I$(srcdir)/bfd/include -I$(srcdir)/bfd/opcodes @BASE_DEPENDENCIES_CFLAGS@
+INCLUDES = $(libbfd_includes) @BASE_DEPENDENCIES_CFLAGS@
CLEANFILES = lib*.a lib*.dll
diff --git a/backend/os/bfdglue.c b/backend/os/bfdglue.c
index 9a741ac..e2138e7 100644
--- a/backend/os/bfdglue.c
+++ b/backend/os/bfdglue.c
@@ -1,3 +1,5 @@
+#include <config.h>
+
#include <bfdglue.h>
#include <signal.h>
#include <string.h>
@@ -246,7 +248,11 @@ bfd_glue_get_errormsg (void)
guint32
bfd_glue_get_section_size (asection *p)
{
+#ifdef HAVE_ASECTION_RAWSIZE
+ return p->rawsize ? p->rawsize : p->size;
+#else
return p->_raw_size;
+#endif
}
BfdGlueSectionFlags
@@ -350,4 +356,4 @@ guint64
bfd_glue_get_start_address (bfd *abfd)
{
return bfd_get_start_address (abfd);
-}
\ No newline at end of file
+}
diff --git a/configure.in b/configure.in
index ce0b609..6df7f05 100644
--- a/configure.in
+++ b/configure.in
@@ -64,6 +64,20 @@ case "$host" in
esac
AC_MSG_RESULT(ok)
+AC_ARG_WITH([system-libbfd],
+ AS_HELP_STRING([--with-system-libbfd], [Use the system copy of libbfd and libopcodes.]))
+
+AS_IF([test "x$with_system_libbfd" = "xyes"],
+ [
+ AC_CHECK_HEADERS([bfd.h], [], [AC_MSG_ERROR([Missing bfd.h header])])
+ AC_CHECK_LIB([bfd], [bfd_init], [:], [AC_MSG_ERROR([Missing libbfd library])])
+ AC_CHECK_LIB([opcodes], [init_disassemble_info], [:], [AC_MSG_ERROR([Missing libopcodes library])])
+ AC_CHECK_MEMBERS([asection.rawsize], [], [], [[#include <bfd.h>]])
+ ])
+
+AM_CONDITIONAL([SYSTEM_LIBBFD], [test "x$with_system_libbfd" = "xyes"])
+
+
AC_ARG_WITH(bfd-target,
[ --with-bfd-target Manually override the BFD target],
if test x$with_bfd_target != "x"; then
--
1.7.0
|