summaryrefslogtreecommitdiff
path: root/cpukit/libdl/rtl-unwind-dw2.c
blob: 29525db2131d9deaf07c0d74d405ac71ec457207 (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
/*
 *  COPYRIGHT (c) 2012-2016, 2018 Chris Johns <chrisj@rtems.org>
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */
/**
 * @file
 *
 * @ingroup rtems_rtld
 *
 * @brief RTEMS Run-Time Link Editor
 *
 * This is the RTL implementation.
 */

#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <string.h>
#include <stdio.h>

#include <rtems/rtl/rtl.h>
#include "rtl-elf.h"
#include "rtl-error.h"
#include "rtl-unwind.h"
#include "rtl-unwind-dw2.h"

/*
 * These interfaces are not exported outside the GCC source.
 */
void __register_frame (void *begin);
void __deregister_frame (void *begin);

bool
rtems_rtl_elf_unwind_dw2_parse (const rtems_rtl_obj* obj,
                                const char*          name,
                                uint32_t             flags)
{
  return
    ((flags & RTEMS_RTL_OBJ_SECT_CONST) != 0) &&
    ((strcmp(name, ".eh_frame") == 0) ||
     (strncmp(name, ".gcc_except_table.", sizeof (".gcc_except_table.") - 1) == 0));
}

bool
rtems_rtl_elf_unwind_dw2_register (const rtems_rtl_obj* obj)
{
  rtems_rtl_obj_sect* sect = rtems_rtl_obj_find_section (obj, ".eh_frame");

  if (sect != NULL && sect->size > 0 && sect->base != NULL)
  {
    __register_frame (sect->base);
  }

  return true;
}

bool rtems_rtl_elf_unwind_dw2_deregister (const rtems_rtl_obj* obj)
{
  rtems_rtl_obj_sect* sect = rtems_rtl_obj_find_section (obj, ".eh_frame");

  if (sect != NULL && sect->size > 0 && sect->base != NULL)
  {
    __deregister_frame (sect->base);
  }

  return true;
}