VirtualBox

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

Last change on this file since 55628 was 48946, checked in by vboxsync, 11 years ago

Debugger: Whitespace and svn:keyword cleanups by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.6 KB
Line 
1/* $Id: DBGPlugInCommonELF.cpp 48946 2013-10-07 21:34:16Z vboxsync $ */
2/** @file
3 * DBGPlugInCommonELF - Common code for dealing with ELF images.
4 */
5
6/*
7 * Copyright (C) 2008-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#define LOG_GROUP LOG_GROUP_DBGF ///@todo add new log group.
23#include "DBGPlugInCommonELF.h"
24
25#include <VBox/vmm/dbgf.h>
26#include <iprt/alloca.h>
27#include <iprt/asm.h>
28#include <iprt/assert.h>
29#include <iprt/dbg.h>
30#include <iprt/mem.h>
31#include <iprt/string.h>
32
33
34/*******************************************************************************
35* Structures and Typedefs *
36*******************************************************************************/
37typedef struct DBGDIGGERELFSEG
38{
39 /** The segment load address. */
40 RTGCPTR uLoadAddr;
41 /** The last address in the segment. */
42 RTGCPTR uLastAddr;
43 /** The segment index. */
44 RTDBGSEGIDX iSeg;
45} DBGDIGGERELFSEG;
46typedef DBGDIGGERELFSEG *PDBGDIGGERELFSEG;
47
48
49/**
50 * Links the segments of the module into the address space.
51 *
52 * @returns VBox status code on failure.
53 *
54 * @param hAs The address space.
55 * @param hMod The module.
56 * @param paSegs Array of segment indexes and load addresses.
57 * @param cSegs The number of segments in the array.
58 */
59static int dbgDiggerCommonLinkElfSegs(RTDBGAS hAs, RTDBGMOD hMod, PDBGDIGGERELFSEG paSegs, uint32_t cSegs)
60{
61 for (uint32_t i = 0; i < cSegs; i++)
62 if (paSegs[i].iSeg != NIL_RTDBGSEGIDX)
63 {
64 int rc = RTDbgAsModuleLinkSeg(hAs, hMod, paSegs[i].iSeg, paSegs[i].uLoadAddr, RTDBGASLINK_FLAGS_REPLACE);
65 if (RT_FAILURE(rc))
66 {
67 RTDbgAsModuleUnlink(hAs, hMod);
68 return rc;
69 }
70 }
71 return VINF_SUCCESS;
72}
73
74
75/*
76 * Instantiate the code templates for dealing with the two ELF versions.
77 */
78
79#define ELF_MODE 32
80#include "DBGPlugInCommonELFTmpl.cpp.h"
81
82#undef ELF_MODE
83#define ELF_MODE 64
84#include "DBGPlugInCommonELFTmpl.cpp.h"
85
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