]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Documentation/patches/BaseTools-Pending-Patches.patch
f7dceb62b7430e6225db8086d8d06161a82c829e
[mirror_edk2.git] / ArmPlatformPkg / Documentation / patches / BaseTools-Pending-Patches.patch
1 From c23ebebbcd3ee992017d4aad70e523ea7252c884 Mon Sep 17 00:00:00 2001
2 From: Olivier Martin <olivier.martin@arm.com>
3 Date: Tue, 6 Dec 2011 16:26:30 +0000
4 Subject: [PATCH] BaseTools: Pending patches update
5
6 Add patch:
7 - ARMLINUXGCC: Set the linked base address at 0x0 (0x8000 by default)
8 ---
9 BaseTools/Conf/tools_def.template | 2 +-
10 BaseTools/Source/C/GenFv/GenFv.c | 7 +---
11 BaseTools/Source/C/GenFv/GenFvInternalLib.c | 48 +++++++++++---------------
12 3 files changed, 22 insertions(+), 35 deletions(-)
13 mode change 100644 => 100755 BaseTools/Conf/tools_def.template
14
15 diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
16 old mode 100644
17 new mode 100755
18 index ee7e23e..68caf86
19 --- a/BaseTools/Conf/tools_def.template
20 +++ b/BaseTools/Conf/tools_def.template
21 @@ -4320,7 +4320,7 @@ RELEASE_ARMLINUXGCC_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) -mlittl
22 *_ARMLINUXGCC_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
23
24 *_ARMLINUXGCC_ARM_SLINK_FLAGS = -rc
25 -*_ARMLINUXGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
26 +*_ARMLINUXGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) -Ttext=0x0 --oformat=elf32-littlearm --emit-relocs -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
27
28 DEBUG_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-address -O0
29 RELEASE_ARMLINUXGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_ARMGCC_CC_FLAGS) -Wno-address -Wno-unused-but-set-variable
30 diff --git a/BaseTools/Source/C/GenFv/GenFv.c b/BaseTools/Source/C/GenFv/GenFv.c
31 index fa86d00..27bd2af 100644
32 --- a/BaseTools/Source/C/GenFv/GenFv.c
33 +++ b/BaseTools/Source/C/GenFv/GenFv.c
34 @@ -623,12 +623,7 @@ Returns:
35 );
36 } else {
37 VerboseMsg ("Create Fv image and its map file");
38 - //
39 - // Will take rebase action at below situation:
40 - // 1. ForceRebase Flag specified to TRUE;
41 - // 2. ForceRebase Flag not specified, BaseAddress greater than zero.
42 - //
43 - if (((mFvDataInfo.BaseAddress > 0) && (mFvDataInfo.ForceRebase == -1)) || (mFvDataInfo.ForceRebase == 1)) {
44 + if (mFvDataInfo.BaseAddressSet) {
45 VerboseMsg ("FvImage Rebase Address is 0x%llX", (unsigned long long) mFvDataInfo.BaseAddress);
46 }
47 //
48 diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
49 index 684933f..aabba5b 100644
50 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
51 +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
52 @@ -506,6 +506,7 @@ Returns:
53
54 EFI_STATUS
55 AddPadFile (
56 + IN FV_INFO *FvInfo,
57 IN OUT MEMORY_FILE *FvImage,
58 IN UINT32 DataAlignment,
59 IN VOID *FvEnd,
60 @@ -537,6 +538,8 @@ Returns:
61 {
62 EFI_FFS_FILE_HEADER *PadFile;
63 UINTN PadFileSize;
64 + UINTN PadFileOffset;
65 + UINTN ExtHeaderSize;
66
67 //
68 // Verify input parameters.
69 @@ -559,32 +562,29 @@ Returns:
70 // This is the earliest possible valid offset (current plus pad file header
71 // plus the next file header)
72 //
73 - PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2);
74 + // The padding is added into its own FFS file (which requires a header) added before the aligned file:
75 + // | ... FV data before AlignedFile ... | Pad File FFS Header | Padding | AlignedFile FFS Header (+ ExtHeader) | AlignedData
76
77 //
78 - // Add whatever it takes to get to the next aligned address
79 + // Calculate the Offset of the Pad File from the beginning of the FV file
80 //
81 - while ((PadFileSize % DataAlignment) != 0) {
82 - PadFileSize++;
83 - }
84 - //
85 - // Subtract the next file header size
86 - //
87 - PadFileSize -= sizeof (EFI_FFS_FILE_HEADER);
88 -
89 - //
90 - // Subtract the starting offset to get size
91 - //
92 - PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;
93 + PadFileOffset = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;
94
95 //
96 - // Append extension header size
97 + // Get the size of the extension header if exists
98 //
99 if (ExtHeader != NULL) {
100 - PadFileSize = PadFileSize + ExtHeader->ExtHeaderSize;
101 + ExtHeaderSize = ExtHeader->ExtHeaderSize;
102 + } else {
103 + ExtHeaderSize = 0;
104 }
105
106 //
107 + // Calculate the Size of the Padding to ensure the alignment of the data of the Next file
108 + //
109 + PadFileSize = DataAlignment - ((FvInfo->BaseAddress + PadFileOffset + sizeof (EFI_FFS_FILE_HEADER) + ExtHeaderSize) & (DataAlignment - 1));
110 +
111 + //
112 // Verify that we have enough space for the file header
113 //
114 if (((UINTN) FvImage->CurrentFilePointer + PadFileSize) > (UINTN) FvEnd) {
115 @@ -1115,7 +1115,7 @@ Returns:
116 //
117 // Add pad file if necessary
118 //
119 - Status = AddPadFile (FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL);
120 + Status = AddPadFile (FvInfo, FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL);
121 if (EFI_ERROR (Status)) {
122 Error (NULL, 0, 4002, "Resource", "FV space is full, could not add pad file for data alignment property.");
123 free (FileBuffer);
124 @@ -2304,7 +2304,7 @@ Returns:
125 //
126 // Add FV Extended Header contents to the FV as a PAD file
127 //
128 - AddPadFile (&FvImageMemoryFile, 4, VtfFileImage, FvExtHeader);
129 + AddPadFile (&mFvDataInfo, &FvImageMemoryFile, 4, VtfFileImage, FvExtHeader);
130
131 //
132 // Fv Extension header change update Fv Header Check sum
133 @@ -2825,20 +2825,12 @@ Returns:
134 PeFileBuffer = NULL;
135
136 //
137 - // Don't need to relocate image when BaseAddress is zero and no ForceRebase Flag specified.
138 - //
139 - if ((FvInfo->BaseAddress == 0) && (FvInfo->ForceRebase == -1)) {
140 - return EFI_SUCCESS;
141 - }
142 -
143 - //
144 - // If ForceRebase Flag specified to FALSE, will always not take rebase action.
145 + // Don't need to relocate image when BaseAddress is not set.
146 //
147 - if (FvInfo->ForceRebase == 0) {
148 + if (FvInfo->BaseAddressSet == FALSE) {
149 return EFI_SUCCESS;
150 }
151
152 -
153 XipBase = FvInfo->BaseAddress + XipOffset;
154
155 //
156 --
157 1.7.0.4
158