blob: 812d554865cf72ffd4c5ca4432070bb5bf945aad (
plain)
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
100
101
102
103
104
105
106
107
|
changeset: 599606:74707e8ecf38
user: Greg V <greg@unrelenting.technology>
date: Wed May 06 17:44:19 2020 +0000
summary: Bug 1634205 - Support Gecko Profiler and Base Profiler on FreeBSD r=mstange
diff --git a/src/common/dwarf/elf_reader.cc b/src/common/dwarf/elf_reader.cc
--- a/src/common/dwarf/elf_reader.cc
+++ b/src/common/dwarf/elf_reader.cc
@@ -52,17 +52,17 @@
// EM_AARCH64 is not defined by elf.h of GRTE v3 on x86.
// TODO(dougkwan): Remove this when v17 is retired.
#if !defined(EM_AARCH64)
#define EM_AARCH64 183 /* ARM AARCH64 */
#endif
// Map Linux macros to their Apple equivalents.
-#if __APPLE__
+#if __APPLE__ || __FreeBSD__
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
#endif // __LITTLE_ENDIAN
#ifndef __BIG_ENDIAN
#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
#endif // __BIG_ENDIAN
#ifndef __BYTE_ORDER
#define __BYTE_ORDER __BYTE_ORDER__
diff --git a/src/common/linux/elfutils.cc b/src/common/linux/elfutils.cc
--- a/src/common/linux/elfutils.cc
+++ b/src/common/linux/elfutils.cc
@@ -30,16 +30,20 @@
#include "common/linux/elfutils.h"
#include <assert.h>
#include <string.h>
#include "common/linux/linux_libc_support.h"
#include "common/linux/elfutils-inl.h"
+#if defined(__FreeBSD__)
+# define ElfW(type) Elf_##type
+#endif
+
namespace google_breakpad {
namespace {
template<typename ElfClass>
void FindElfClassSection(const char *elf_base,
const char *section_name,
typename ElfClass::Word section_type,
diff --git a/src/common/memory_allocator.h b/src/common/memory_allocator.h
--- a/src/common/memory_allocator.h
+++ b/src/common/memory_allocator.h
@@ -37,17 +37,17 @@
#include <memory>
#include <vector>
#if defined(MEMORY_SANITIZER)
#include <sanitizer/msan_interface.h>
#endif
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
#define sys_mmap mmap
#define sys_munmap munmap
#define MAP_ANONYMOUS MAP_ANON
#else
#include "third_party/lss/linux_syscall_support.h"
#endif
namespace google_breakpad {
diff --git a/src/third_party/lss/linux_syscall_support.h b/src/third_party/lss/linux_syscall_support.h
--- a/src/third_party/lss/linux_syscall_support.h
+++ b/src/third_party/lss/linux_syscall_support.h
@@ -4527,10 +4527,27 @@ struct kernel_statfs {
#pragma pop_macro("pread64")
#pragma pop_macro("pwrite64")
#pragma pop_macro("getdents64")
#if defined(__cplusplus) && !defined(SYS_CPLUSPLUS)
}
#endif
-#endif
-#endif
+#elif defined(__FreeBSD__)
+
+#include <unistd.h>
+#include <sys/stat.h>
+
+#define sys_readlink readlink
+
+#define sys_open open
+#define sys_close close
+#define sys_fstat fstat
+#define sys_fstat64 fstat
+#define kernel_stat stat
+#define kernel_stat64 stat
+#define sys_mmap mmap
+#define sys_munmap munmap
+
+#endif
+
+#endif
|