VirtualBox

source: vbox/trunk/src/VBox/Debugger/DBGPlugInCommonELF.cpp@ 99900

Last change on this file since 99900 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.2 KB
Line 
1/* $Id: DBGPlugInCommonELF.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * DBGPlugInCommonELF - Common code for dealing with ELF images.
4 */
5
6/*
7 * Copyright (C) 2008-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#define LOG_GROUP LOG_GROUP_DBGF /// @todo add new log group.
33#include "DBGPlugInCommonELF.h"
34
35#include <VBox/vmm/vmmr3vtable.h>
36#include <iprt/alloca.h>
37#include <iprt/asm.h>
38#include <iprt/assert.h>
39#include <iprt/dbg.h>
40#include <iprt/err.h>
41#include <iprt/mem.h>
42#include <iprt/string.h>
43
44
45/*********************************************************************************************************************************
46* Structures and Typedefs *
47*********************************************************************************************************************************/
48typedef struct DBGDIGGERELFSEG
49{
50 /** The segment load address. */
51 RTGCPTR uLoadAddr;
52 /** The last address in the segment. */
53 RTGCPTR uLastAddr;
54 /** The segment index. */
55 RTDBGSEGIDX iSeg;
56} DBGDIGGERELFSEG;
57typedef DBGDIGGERELFSEG *PDBGDIGGERELFSEG;
58
59
60/**
61 * Links the segments of the module into the address space.
62 *
63 * @returns VBox status code on failure.
64 *
65 * @param hAs The address space.
66 * @param hMod The module.
67 * @param paSegs Array of segment indexes and load addresses.
68 * @param cSegs The number of segments in the array.
69 */
70static int dbgDiggerCommonLinkElfSegs(RTDBGAS hAs, RTDBGMOD hMod, PDBGDIGGERELFSEG paSegs, uint32_t cSegs)
71{
72 for (uint32_t i = 0; i < cSegs; i++)
73 if (paSegs[i].iSeg != NIL_RTDBGSEGIDX)
74 {
75 int rc = RTDbgAsModuleLinkSeg(hAs, hMod, paSegs[i].iSeg, paSegs[i].uLoadAddr, RTDBGASLINK_FLAGS_REPLACE);
76 if (RT_FAILURE(rc))
77 {
78 RTDbgAsModuleUnlink(hAs, hMod);
79 return rc;
80 }
81 }
82 return VINF_SUCCESS;
83}
84
85
86/*
87 * Instantiate the code templates for dealing with the two ELF versions.
88 */
89
90#define ELF_MODE 32
91#include "DBGPlugInCommonELFTmpl.cpp.h"
92
93#undef ELF_MODE
94#define ELF_MODE 64
95#include "DBGPlugInCommonELFTmpl.cpp.h"
96
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette