Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 9fb270c

Browse files
libefiwrapper/pe: support 64-bits images
Change-Id: I5b153fcbdf436a519179880b0e1823f686c108c4 Signed-off-by: Jeremy Compostella <[email protected]>
1 parent 3d8cc46 commit 9fb270c

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

libefiwrapper/pe.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ typedef struct {
103103
} std_coff_t;
104104

105105
typedef struct {
106-
UINT32 image_base;
106+
unsigned long image_base;
107107
UINT32 section_alignment;
108108
UINT32 file_alignment;
109109
UINT16 major_operating_system_version;
@@ -118,10 +118,10 @@ typedef struct {
118118
UINT32 checksum;
119119
UINT16 subsystem;
120120
UINT16 dll_characteristics;
121-
UINT32 size_of_stack_reserve;
122-
UINT32 size_of_stack_commit;
123-
UINT32 size_of_heap_reserve;
124-
UINT32 size_of_heap_commit;
121+
unsigned long size_of_stack_reserve;
122+
unsigned long size_of_stack_commit;
123+
unsigned long size_of_heap_reserve;
124+
unsigned long size_of_heap_commit;
125125
UINT32 loader_flags;
126126
UINT32 number_of_rva_and_sizes;
127127
} win_t;
@@ -257,8 +257,8 @@ static EFI_STATUS load_sections(section_header_t *section, UINT16 nb,
257257
return EFI_SUCCESS;
258258
}
259259

260-
static void relocate(loaded_section_t *data, UINT32 base, relocation_t *table,
261-
UINT32 size)
260+
static void relocate(loaded_section_t *data, unsigned long base,
261+
relocation_t *table, UINT32 size)
262262
{
263263
relocation_t *table_end = (relocation_t *)((UINT8 *)table + size);
264264
unsigned long diff = (unsigned long)data->addr - base - data->start;
@@ -272,9 +272,17 @@ static void relocate(loaded_section_t *data, UINT32 base, relocation_t *table,
272272
for (; fixup < fixup_end; fixup++) {
273273
if (*(UINT16 *)fixup == 0)
274274
break;
275-
if (fixup->type != HIGHLOW)
276-
continue;
277-
*(UINT32 *)&mem[fixup->offset] += diff;
275+
switch (fixup->type) {
276+
case HIGHLOW:
277+
*(UINT32 *)&mem[fixup->offset] += diff;
278+
break;
279+
case DIR64:
280+
*(UINT64 *)&mem[fixup->offset] += diff;
281+
break;
282+
default:
283+
ewerr("Unsupported relocation type %d",
284+
fixup->type);
285+
}
278286
}
279287
table = (relocation_t *)fixup_end;
280288
}

0 commit comments

Comments
 (0)