1 | /* $Id: PeCoffLoaderEx.c 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PeCoffLoaderEx.c
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2024 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 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | /*
|
---|
38 | This code is based on:
|
---|
39 |
|
---|
40 | Specific relocation fixups for none Itanium architecture.
|
---|
41 |
|
---|
42 | Copyright (c) 2006 - 2008, Intel Corporation<BR>
|
---|
43 | All rights reserved. This program and the accompanying materials
|
---|
44 | are licensed and made available under the terms and conditions of the BSD License
|
---|
45 | which accompanies this distribution. The full text of the license may be found at
|
---|
46 | http://opensource.org/licenses/bsd-license.php
|
---|
47 |
|
---|
48 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
49 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
50 |
|
---|
51 | */
|
---|
52 |
|
---|
53 | #include "BasePeCoffLibInternals.h"
|
---|
54 |
|
---|
55 |
|
---|
56 | /**
|
---|
57 | Performs an Itanium-based specific relocation fixup and is a no-op on other
|
---|
58 | instruction sets.
|
---|
59 |
|
---|
60 | @param Reloc Pointer to the relocation record.
|
---|
61 | @param Fixup Pointer to the address to fix up.
|
---|
62 | @param FixupData Pointer to a buffer to log the fixups.
|
---|
63 | @param Adjust The offset to adjust the fixup.
|
---|
64 |
|
---|
65 | @return Status code.
|
---|
66 |
|
---|
67 | **/
|
---|
68 | RETURN_STATUS
|
---|
69 | PeCoffLoaderRelocateImageEx (
|
---|
70 | IN UINT16 *Reloc,
|
---|
71 | IN OUT CHAR8 *Fixup,
|
---|
72 | IN OUT CHAR8 **FixupData,
|
---|
73 | IN UINT64 Adjust
|
---|
74 | )
|
---|
75 | {
|
---|
76 | return RETURN_UNSUPPORTED;
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | Returns TRUE if the machine type of PE/COFF image is supported. Supported
|
---|
81 | does not mean the image can be executed it means the PE/COFF loader supports
|
---|
82 | loading and relocating of the image type. It's up to the caller to support
|
---|
83 | the entry point.
|
---|
84 |
|
---|
85 | The IA32/X64 version PE/COFF loader/relocater both support IA32, X64 and EBC images.
|
---|
86 |
|
---|
87 | @param Machine Machine type from the PE Header.
|
---|
88 |
|
---|
89 | @return TRUE if this PE/COFF loader can load the image
|
---|
90 |
|
---|
91 | **/
|
---|
92 | BOOLEAN
|
---|
93 | PeCoffLoaderImageFormatSupported (
|
---|
94 | IN UINT16 Machine
|
---|
95 | )
|
---|
96 | {
|
---|
97 | if ((Machine == IMAGE_FILE_MACHINE_I386) || (Machine == IMAGE_FILE_MACHINE_X64) ||
|
---|
98 | (Machine == IMAGE_FILE_MACHINE_EBC)) {
|
---|
99 | return TRUE;
|
---|
100 | }
|
---|
101 |
|
---|
102 | return FALSE;
|
---|
103 | }
|
---|
104 |
|
---|
105 | /**
|
---|
106 | Performs an Itanium-based specific re-relocation fixup and is a no-op on other
|
---|
107 | instruction sets. This is used to re-relocated the image into the EFI virtual
|
---|
108 | space for runtime calls.
|
---|
109 |
|
---|
110 | @param Reloc Pointer to the relocation record.
|
---|
111 | @param Fixup Pointer to the address to fix up.
|
---|
112 | @param FixupData Pointer to a buffer to log the fixups.
|
---|
113 | @param Adjust The offset to adjust the fixup.
|
---|
114 |
|
---|
115 | @return Status code.
|
---|
116 |
|
---|
117 | **/
|
---|
118 | RETURN_STATUS
|
---|
119 | PeHotRelocateImageEx (
|
---|
120 | IN UINT16 *Reloc,
|
---|
121 | IN OUT CHAR8 *Fixup,
|
---|
122 | IN OUT CHAR8 **FixupData,
|
---|
123 | IN UINT64 Adjust
|
---|
124 | )
|
---|
125 | {
|
---|
126 | return RETURN_UNSUPPORTED;
|
---|
127 | }
|
---|
128 |
|
---|