![]() |
|
|||
File indexing completed on 2025-05-11 08:24:16
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup rtl 0007 * 0008 * @brief RTEMS Module Loading Debugger Interface. 0009 * 0010 * Inspection of run-time linkers in NetBSD and Android show a common type of 0011 * structure that is used to interface to GDB. The NetBSD definition of this 0012 * interface is being used and is defined in <link.h>. It defines a protocol 0013 * that is used by GDB to inspect the state of dynamic libraries. I have not 0014 * checked GDB code at when writing this comment but I suspect GDB sets a break 0015 * point on the r_brk field of _rtld_debug and it has code that detects this 0016 * break point being hit. When this happens it reads the state and performs the 0017 * operation based on the r_state field. 0018 */ 0019 0020 /* 0021 * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org> 0022 * 0023 * Redistribution and use in source and binary forms, with or without 0024 * modification, are permitted provided that the following conditions 0025 * are met: 0026 * 1. Redistributions of source code must retain the above copyright 0027 * notice, this list of conditions and the following disclaimer. 0028 * 2. Redistributions in binary form must reproduce the above copyright 0029 * notice, this list of conditions and the following disclaimer in the 0030 * documentation and/or other materials provided with the distribution. 0031 * 0032 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0033 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0034 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0035 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0036 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0037 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0038 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0039 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0040 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0041 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0042 * POSSIBILITY OF SUCH DAMAGE. 0043 */ 0044 0045 #ifdef HAVE_CONFIG_H 0046 #include "config.h" 0047 #endif 0048 0049 #include <stdio.h> 0050 #include <link.h> 0051 #include <rtems/rtl/rtl.h> 0052 #include <rtems/rtl/rtl-trace.h> 0053 #include <rtems/rtl/rtl-obj-fwd.h> 0054 0055 struct r_debug _rtld_debug; 0056 0057 void 0058 _rtld_debug_state (void) 0059 { 0060 /* 0061 * Empty. GDB only needs to hit this location. 0062 */ 0063 } 0064 0065 int 0066 _rtld_linkmap_add (rtems_rtl_obj* obj) 0067 { 0068 struct link_map* l = obj->linkmap; 0069 struct link_map* prev; 0070 uint32_t obj_num = obj->obj_num; 0071 int i; 0072 0073 if (rtems_rtl_trace (RTEMS_RTL_TRACE_DETAIL)) 0074 printf ("rtl: linkmap_add\n"); 0075 0076 for (i = 0; i < obj_num; ++i) 0077 { 0078 l[i].sec_addr[rap_text] = obj->text_base; 0079 l[i].sec_addr[rap_const] = obj->const_base; 0080 l[i].sec_addr[rap_data] = obj->data_base; 0081 l[i].sec_addr[rap_bss] = obj->bss_base; 0082 } 0083 0084 if (_rtld_debug.r_map == NULL) 0085 { 0086 _rtld_debug.r_map = l; 0087 } 0088 else 0089 { 0090 for (prev = _rtld_debug.r_map; prev->l_next != NULL; prev = prev->l_next); 0091 l->l_prev = prev; 0092 prev->l_next = l; 0093 } 0094 0095 return true; 0096 } 0097 0098 void 0099 _rtld_linkmap_delete (rtems_rtl_obj* obj) 0100 { 0101 struct link_map* l = obj->linkmap; 0102 0103 /* 0104 * link_maps are allocated together if not 1 0105 */ 0106 struct link_map* e = l + obj->obj_num - 1; 0107 0108 if (l->l_prev == NULL) 0109 { 0110 if ((_rtld_debug.r_map = e->l_next) != NULL) 0111 _rtld_debug.r_map->l_prev = NULL; 0112 } 0113 else 0114 { 0115 if ((l->l_prev->l_next = e->l_next) != NULL) 0116 e->l_next->l_prev = l->l_prev; 0117 } 0118 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |