misc_all.cpp
Go to the documentation of this file.
1 //
2 // Bareflank Hypervisor
3 //
4 // Copyright (C) 2015 Assured Information Security, Inc.
5 // Author: Rian Quinn <quinnr@ainfosec.com>
6 // Author: Brendan Kerrigan <kerriganb@ainfosec.com>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22 #include <errno.h>
23 #include <stddef.h>
24 #include <stdint.h>
25 #include <unistd.h>
26 #include <string.h>
27 #include <stdlib.h>
28 
29 #include <constants.h>
30 #include <eh_frame_list.h>
31 
32 void *__dso_handle = 0;
33 uintptr_t __stack_chk_guard = 0x595e9fbd94fda766;
34 
35 auto g_eh_frame_list_num = 0ULL;
37 
38 extern "C" struct eh_frame_t *
40 {
41  return g_eh_frame_list;
42 }
43 
44 extern "C" int64_t
46 {
47  if (addr == nullptr || size == 0)
49 
52 
53  g_eh_frame_list[g_eh_frame_list_num].addr = addr;
54  g_eh_frame_list[g_eh_frame_list_num].size = size;
56 
58 }
59 
60 extern "C" void
62 {
63  auto msg = "__stack_chk_fail: buffer overflow detected!!!\n";
64  write(1, msg, strlen(msg));
65  abort();
66 }
67 
68 extern "C" int
69 ___xpg_strerror_r(int errnum, char *buf, size_t buflen)
70 {
71  (void) errnum;
72 
73  memset(buf, 0, buflen);
74  return 0;
75 }
76 
77 extern "C" void
79 { }
void * memset(void *block, int c, size_t size)
eh_frame_t g_eh_frame_list[MAX_NUM_MODULES]
Definition: misc_all.cpp:36
struct eh_frame_t * get_eh_frame_list() noexcept
Definition: misc_all.cpp:39
void * __dso_handle
Definition: misc_all.cpp:32
#define REGISTER_EH_FRAME_FAILURE
Definition: error_codes.h:67
void * addr
Definition: eh_frame_list.h:45
void _start(void) noexcept
Definition: misc_all.cpp:78
#define MAX_NUM_MODULES
Definition: constants.h:177
int64_t register_eh_frame(void *addr, uint64_t size) noexcept
Definition: misc_all.cpp:45
constexpr const auto size
auto g_eh_frame_list_num
Definition: misc_all.cpp:35
void uint64_t uint64_t uint64_t *rdx noexcept
constexpr const auto addr
Definition: cpuid_x64.h:80
void __stack_chk_fail(void) noexcept
Definition: misc_all.cpp:61
void write(field_type field, value_type value, name_type name="")
uintptr_t __stack_chk_guard
Definition: misc_all.cpp:33
uint64_t size
Definition: eh_frame_list.h:46
int ___xpg_strerror_r(int errnum, char *buf, size_t buflen)
Definition: misc_all.cpp:69
#define REGISTER_EH_FRAME_SUCCESS
Definition: error_codes.h:66