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
|
diff --git a/configure.in b/configure.in
index c643e64..402be56 100644
--- a/configure.in
+++ b/configure.in
@@ -64,6 +64,18 @@ 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])])
+ ])
+
+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
diff --git a/sysdeps/Makefile.am b/sysdeps/Makefile.am
index 017026f..f63c181 100644
--- a/sysdeps/Makefile.am
+++ b/sysdeps/Makefile.am
@@ -1 +1,5 @@
+if !SYSTEM_LIBBFD
SUBDIRS = bfd server
+else
+SUBDIRS = server
+endif
diff --git a/sysdeps/server/Makefile.am b/sysdeps/server/Makefile.am
index dad57ab..8e7ac68 100644
--- a/sysdeps/server/Makefile.am
+++ b/sysdeps/server/Makefile.am
@@ -6,10 +6,9 @@ libmonodebuggerbfdglue_la_SOURCES = \
bfdglue.c \
bfdglue.h
+if !SYSTEM_LIBBFD
libmonodebuggerbfdglue_la_LIBADD = \
../../sysdeps/bfd/opcodes/libopcodes.la ../../sysdeps/bfd/libbfd.la
-libmonodebuggerbfdglue_la_LDFLAGS = \
- -no-undefined -module -export-dynamic -shared
libmonodebuggerbfdglue_la_CPPFLAGS = \
-I$(top_srcdir)/sysdeps/bfd \
@@ -17,6 +16,17 @@ libmonodebuggerbfdglue_la_CPPFLAGS = \
-I$(top_srcdir)/sysdeps/bfd/opcodes \
@SERVER_DEPENDENCIES_CFLAGS@ @server_cflags@
+else
+libmonodebuggerbfdglue_la_LIBADD =
+
+libmonodebuggerbfdglue_la_CPPFLAGS = -lopcodes -lbfd \
+ @SERVER_DEPENDENCIES_CFLAGS@ @server_cflags@
+
+endif
+
+libmonodebuggerbfdglue_la_LDFLAGS = \
+ -no-undefined -module -export-dynamic -shared
+
EXTRA_libmonodebuggerserver_la_SOURCES = \
i386-arch.c \
i386-arch.h \
diff --git a/sysdeps/server/bfdglue.c b/sysdeps/server/bfdglue.c
index 9a741ac..e2138e7 100644
--- a/sysdeps/server/bfdglue.c
+++ b/sysdeps/server/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
+}
|