Discussion:
[edk2] [Patch] OvmfPkg: Fix GCC49 build hang in PeiCore
Ruiyu Ni
2015-07-09 07:13:44 UTC
Permalink
PeiCore hang when loads a PEIM whose section alignment requirement is 0x40 but the actual base address is 0x20 aligned.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <***@intel.com>
Reviewed-by: Liming Gao <***@intel.com>
---
OvmfPkg/OvmfPkgIa32.fdf | 4 ++--
OvmfPkg/OvmfPkgIa32X64.fdf | 4 ++--
OvmfPkg/OvmfPkgX64.fdf | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 24ad0bf..d11325e 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {

[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 5f98be8..015aca4 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {

[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 11e74e7..f43d3dd 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {

[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
--
1.9.5.msysgit.1
Laszlo Ersek
2015-07-09 07:25:12 UTC
Permalink
Post by Ruiyu Ni
PeiCore hang when loads a PEIM whose section alignment requirement is
0x40 but the actual base address is 0x20 aligned.
Thank you very much for tracking this down!

However, can you please describe the analysis (that you must have
certainly done to identify the bug!) in the commit message? (If that's
too much of a chore, then please just explain it to me in detail, and
I'll write up the commit message.)

I guess that means that the exact location in the PeiCore source should
be identified that blows up, plus, can you please say where the "section
alignment requirement" comes from?

Thanks!
Laszlo
Post by Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.0
---
OvmfPkg/OvmfPkgIa32.fdf | 4 ++--
OvmfPkg/OvmfPkgIa32X64.fdf | 4 ++--
OvmfPkg/OvmfPkgX64.fdf | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 24ad0bf..d11325e 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 5f98be8..015aca4 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 11e74e7..f43d3dd 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
Ruiyu Ni
2015-07-09 08:06:01 UTC
Permalink
PeiCore hang when loads a PEIM whose section alignment requirement is 0x40 but the actual base address is 0x20 aligned.
The issue is caused by the following facts, in order:
1. GCC49 requires the section alignment of .data to be 0x40. So a new link script gcc4.9-ld-script was added for GCC49 to specify the 0x40 alignment.
2. GenFw tool was enhanced to sync ELF's section alignment to PE header. Before the enhancement, the section alignment of converted PE image always equals to 0x20.

If only with #1 change, GCC49 build image won't hang in PeiCore because the converted PE image still claims 0x20 section alignment which is aligned to the align setting set in FDF file. But later with #2 change, the converted PE image starts to claims 0x40 section alignment, while build tool still puts the PEIM in 0x20 aligned address, resulting the PeCoffLoaderLoadImage() reports IMAGE_ERROR_INVALID_SECTION_ALIGNMENT error.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <***@intel.com>
Reviewed-by: Liming Gao <***@intel.com>
---
OvmfPkg/OvmfPkgIa32.fdf | 4 ++--
OvmfPkg/OvmfPkgIa32X64.fdf | 4 ++--
OvmfPkg/OvmfPkgX64.fdf | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 24ad0bf..d11325e 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {

[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 5f98be8..015aca4 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {

[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 11e74e7..f43d3dd 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {

[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
--
1.9.5.msysgit.1
Laszlo Ersek
2015-07-09 08:47:48 UTC
Permalink
Post by Ruiyu Ni
PeiCore hang when loads a PEIM whose section alignment requirement is
0x40 but the actual base address is 0x20 aligned.
1. GCC49 requires the section alignment of .data to be 0x40. So a new
link script gcc4.9-ld-script was added for GCC49 to specify the 0x40
alignment.
2. GenFw tool was enhanced to sync ELF's section alignment to PE
header. Before the enhancement, the section alignment of converted PE
image always equals to 0x20.
If only with #1 change, GCC49 build image won't hang in PeiCore
because the converted PE image still claims 0x20 section alignment
which is aligned to the align setting set in FDF file. But later with
#2 change, the converted PE image starts to claims 0x40 section
alignment, while build tool still puts the PEIM in 0x20 aligned
address, resulting the PeCoffLoaderLoadImage() reports
IMAGE_ERROR_INVALID_SECTION_ALIGNMENT error.
Perfect!

So, ultimately, the alignment at which the build tool places the PEI
modules, controlled by the Align=... directive, must satisfy the
alignment that the PE header itself states. And currently, the alignment
in the PE header comes from the ELF linker script, because the updated
GenFw tool sets the PE header based on the ELF values.

Therefore the Align=... directive in the FDF rules must match the
alignment in the ELF linker script. And, apparently, the simplest way to
ensure this is to convince the build tool to grab the PEIMs alignment
from the PE header, with Align=Auto.

Now the question emerges if *other* module rules in the OVMF FDF files
should see their Align=... directives updated. However, there are no
other Align=... directives; the patch updates them all (apparently only
PEI_CORE and PEIM rules spell out Align=whatever).

Superb work!

Reviewed-by: Laszlo Ersek <***@redhat.com>

I'm going to commit your patch right away (I'll just rewrap the commit
message to 74 characters first).

Thank you!
Laszlo
Post by Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.0
---
OvmfPkg/OvmfPkgIa32.fdf | 4 ++--
OvmfPkg/OvmfPkgIa32X64.fdf | 4 ++--
OvmfPkg/OvmfPkgX64.fdf | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 24ad0bf..d11325e 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 5f98be8..015aca4 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 11e74e7..f43d3dd 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
Laszlo Ersek
2015-07-09 09:01:00 UTC
Permalink
Committed as SVN r17902.

Thanks!
Laszlo
Post by Ruiyu Ni
PeiCore hang when loads a PEIM whose section alignment requirement is 0x40 but the actual base address is 0x20 aligned.
1. GCC49 requires the section alignment of .data to be 0x40. So a new link script gcc4.9-ld-script was added for GCC49 to specify the 0x40 alignment.
2. GenFw tool was enhanced to sync ELF's section alignment to PE header. Before the enhancement, the section alignment of converted PE image always equals to 0x20.
If only with #1 change, GCC49 build image won't hang in PeiCore because the converted PE image still claims 0x20 section alignment which is aligned to the align setting set in FDF file. But later with #2 change, the converted PE image starts to claims 0x40 section alignment, while build tool still puts the PEIM in 0x20 aligned address, resulting the PeCoffLoaderLoadImage() reports IMAGE_ERROR_INVALID_SECTION_ALIGNMENT error.
Contributed-under: TianoCore Contribution Agreement 1.0
---
OvmfPkg/OvmfPkgIa32.fdf | 4 ++--
OvmfPkg/OvmfPkgIa32X64.fdf | 4 ++--
OvmfPkg/OvmfPkgX64.fdf | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 24ad0bf..d11325e 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 5f98be8..015aca4 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 11e74e7..f43d3dd 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEI_CORE]
FILE PEI_CORE = $(NAMED_GUID) {
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING ="$(MODULE_NAME)" Optional
VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
@@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
[Rule.Common.PEIM]
FILE PEIM = $(NAMED_GUID) {
PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
- PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
}
Loading...