Here is the new version that takes in account your comments.
I took note of 'git send-email'; I will have a look to use it in a near future.
________________________________________
From: Jordan Justen [jljus...@gmail.com]
Sent: 17 June 2013 22:37
To: Olivier Martin
Cc: edk2-buildtools-de...@lists.sourceforge.net;
edk2-devel@lists.sourceforge.net
Subject: Re: [edk2-buildtools] [PATCH] Fixed calculation of BaseOfCode in GenFw
when the first code section is aligned
Since you use git, maybe you could use git send-email, since it makes
it easier to code-review, and then reply and reference particular code
in the patch?
Sent twice, but they look the same. Is that right?
Maybe an ASSERT (FoundText) at the end of the routine?
For comments, we usually like to waste 2 extra lines with empty // comments. :)
FoundText == FALSE => !FoundText
Reviewed-by: Jordan Justen <jordan.l.jus...@intel.com>
On Tue, Jun 11, 2013 at 3:04 AM, Olivier Martin <olivier.mar...@arm.com> wrote:
> Dear EDK2 BaseTools maintainers,
>
> Please find this patch that fixes the calculation of the PE/COFF header
> attribute ‘BaseOfCode’ when the first ‘.text’ section is aligned.
>
> In the current code base, the alignment of the first code section is not
> taken into account for the calculation of BaseOfCode.
>
> Regards,
>
> Olivier
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> edk2-buildtools-devel mailing list
> edk2-buildtools-de...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-buildtools-devel
>
-- IMPORTANT NOTICE: The contents of this email and any attachments are
confidential and may also be privileged. If you are not the intended recipient,
please notify the sender immediately and do not disclose the contents to any
other person, use it for any purpose, or store or copy the information in any
medium. Thank you.
From ee1ef9e693a364beb2620338a5448dbd473ffb9e Mon Sep 17 00:00:00 2001
From: Olivier Martin <olivier.mar...@arm.com>
Date: Tue, 11 Jun 2013 10:56:12 +0100
Subject: BaseTools/GenFw: Set the PE/COFF attribute BaseOfCode with the address of the first '.text' section
Before this change the alignment of the first code section was not taken into account.
Change-Id: I6e6b07edb2f7e7179c9467b43857c44a8309cb68
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.mar...@arm.com>
---
BaseTools/Source/C/GenFw/Elf32Convert.c | 20 +++++++++++++++++++-
BaseTools/Source/C/GenFw/Elf64Convert.c | 21 +++++++++++++++++++--
2 files changed, 38 insertions(+), 3 deletions(-)
mode change 100644 => 100755 BaseTools/Source/C/GenFw/Elf32Convert.c
mode change 100644 => 100755 BaseTools/Source/C/GenFw/Elf64Convert.c
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c
old mode 100644
new mode 100755
index ddb45ac..58ac333
--- a/BaseTools/Source/C/GenFw/Elf32Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf32Convert.c
@@ -1,6 +1,7 @@
/** @file
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+Portions copyright (c) 2013, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
@@ -18,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <windows.h>
#include <io.h>
#endif
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -264,9 +266,12 @@ ScanSections32 (
EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;
UINT32 CoffEntry;
UINT32 SectionCount;
+ BOOLEAN FoundText;
CoffEntry = 0;
mCoffOffset = 0;
+ mTextOffset = 0;
+ FoundText = FALSE;
//
// Coff file start with a DOS header.
@@ -291,7 +296,6 @@ ScanSections32 (
// First text sections.
//
mCoffOffset = CoffAlign(mCoffOffset);
- mTextOffset = mCoffOffset;
SectionCount = 0;
for (i = 0; i < mEhdr->e_shnum; i++) {
Elf_Shdr *shdr = GetShdrByIndex(i);
@@ -315,12 +319,26 @@ ScanSections32 (
(mEhdr->e_entry < shdr->sh_addr + shdr->sh_size)) {
CoffEntry = mCoffOffset + mEhdr->e_entry - shdr->sh_addr;
}
+
+ //
+ // Set mTextOffset with the offset of the first '.text' section
+ //
+ if (!FoundText) {
+ mTextOffset = mCoffOffset;
+ FoundText = TRUE;
+ }
+
mCoffSectionsOffset[i] = mCoffOffset;
mCoffOffset += shdr->sh_size;
SectionCount ++;
}
}
+ if (!FoundText) {
+ Error (NULL, 0, 3000, "Invalid", "Did not find any '.text' section.");
+ assert (FALSE);
+ }
+
if (mEhdr->e_machine != EM_ARM) {
mCoffOffset = CoffAlign(mCoffOffset);
}
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c
old mode 100644
new mode 100755
index e7298fd..713f8f7
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -1,7 +1,7 @@
/** @file
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
-Portions copyright (c) 2011, 2012, ARM Ltd. All rights reserved.<BR>
+Portions copyright (c) 2013, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
@@ -19,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <windows.h>
#include <io.h>
#endif
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -258,9 +259,12 @@ ScanSections64 (
EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;
UINT32 CoffEntry;
UINT32 SectionCount;
+ BOOLEAN FoundText;
CoffEntry = 0;
mCoffOffset = 0;
+ mTextOffset = 0;
+ FoundText = FALSE;
//
// Coff file start with a DOS header.
@@ -286,7 +290,6 @@ ScanSections64 (
// First text sections.
//
mCoffOffset = CoffAlign(mCoffOffset);
- mTextOffset = mCoffOffset;
SectionCount = 0;
for (i = 0; i < mEhdr->e_shnum; i++) {
Elf_Shdr *shdr = GetShdrByIndex(i);
@@ -310,12 +313,26 @@ ScanSections64 (
(mEhdr->e_entry < shdr->sh_addr + shdr->sh_size)) {
CoffEntry = (UINT32) (mCoffOffset + mEhdr->e_entry - shdr->sh_addr);
}
+
+ //
+ // Set mTextOffset with the offset of the first '.text' section
+ //
+ if (!FoundText) {
+ mTextOffset = mCoffOffset;
+ FoundText = TRUE;
+ }
+
mCoffSectionsOffset[i] = mCoffOffset;
mCoffOffset += (UINT32) shdr->sh_size;
SectionCount ++;
}
}
+ if (!FoundText) {
+ Error (NULL, 0, 3000, "Invalid", "Did not find any '.text' section.");
+ assert (FALSE);
+ }
+
if (mEhdr->e_machine != EM_ARM) {
mCoffOffset = CoffAlign(mCoffOffset);
}
--
1.7.4.1
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel