PATCH: Remove force_minimum_alignment and force_minimum_alignment
H.J. Lu
hjl.tools@gmail.com
Sat Apr 18 00:56:00 GMT 2009
On Fri, Apr 17, 2009 at 3:19 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Since EFI targets are removed, we don't need force_minimum_alignment nor
> force_minimum_alignment anymore. This patch removes them. Also page size
> on Windows ia64 is 8K, not 4K:
>
> http://blogs.msdn.com/oldnewthing/archive/2004/09/08/226797.aspx
>
> Also we can't set D_PAGED, which is set by
>
> /* FIXME: How can we set D_PAGED correctly? */
> if ((internal_f->f_flags & F_EXEC) != 0)
> abfd->flags |= D_PAGED;
>
> in coff_real_object_p, on a PEI target if PE section alignment is
> smaller than COFF_PAGE_SIZE. This patch also fixes it so that the
> section is layout correctly when
>
> --file-alignment=0x20 --section-alignment=0x20
>
> is used with objcopy. OK to install?
Here is the updated patch to remove PEI_TARGET_SUBSYSTEM
and PEI_FORCE_MINIMUM_ALIGNMENT from pei-ia64.c. OK
to install?
Thanks.
--
H.J.
---
2009-04-17 H.J. Lu <hongjiu.lu@intel.com>
* coff-ia64.c (COFF_PAGE_SIZE): Changed to 8K.
* coffcode.h (coff_compute_section_file_positions): Clear
D_PAGED if PE section alignment is smaller than COFF_PAGE_SIZE.
* libcoff-in.h (pe_tdata): Remove force_minimum_alignment and
force_minimum_alignment.
* libcoff.h: Regenerated.
* pei-ia64.c (PEI_TARGET_SUBSYSTEM): Removed.
(PEI_FORCE_MINIMUM_ALIGNMENT): Likewise.
* peicode.h (pe_mkobject): Don't set force_minimum_alignment
nor target_subsystem.
* peXXigen.c (_bfd_XXi_swap_aouthdr_out): Don't check
force_minimum_alignment nor target_subsystem.
-------------- next part --------------
2009-04-17 H.J. Lu <hongjiu.lu@intel.com>
* coff-ia64.c (COFF_PAGE_SIZE): Changed to 8K.
* coffcode.h (coff_compute_section_file_positions): Clear
D_PAGED if PE section alignment is smaller than COFF_PAGE_SIZE.
* libcoff-in.h (pe_tdata): Remove force_minimum_alignment and
force_minimum_alignment.
* libcoff.h: Regenerated.
* pei-ia64.c (PEI_TARGET_SUBSYSTEM): Removed.
(PEI_FORCE_MINIMUM_ALIGNMENT): Likewise.
* peicode.h (pe_mkobject): Don't set force_minimum_alignment
nor target_subsystem.
* peXXigen.c (_bfd_XXi_swap_aouthdr_out): Don't check
force_minimum_alignment nor target_subsystem.
--- bfd/coff-ia64.c.page 2008-07-22 07:19:37.000000000 -0700
+++ bfd/coff-ia64.c 2009-04-17 15:37:55.000000000 -0700
@@ -29,9 +29,9 @@
#include "libcoff.h"
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
-/* The page size is a guess based on ELF. */
-#define COFF_PAGE_SIZE 0x1000
+/* Windows ia64 uses 8K page size. */
+#define COFF_PAGE_SIZE 0x2000
static reloc_howto_type howto_table[] =
{
--- bfd/coffcode.h.page 2009-04-17 12:15:34.000000000 -0700
+++ bfd/coffcode.h 2009-04-17 15:37:55.000000000 -0700
@@ -3186,6 +3186,13 @@ coff_compute_section_file_positions (bfd
int target_index;
bfd_size_type amt;
+#ifdef COFF_PAGE_SIZE
+ /* Clear D_PAGED if section alignment is smaller than
+ COFF_PAGE_SIZE. */
+ if (pe_data (abfd)->pe_opthdr.SectionAlignment < COFF_PAGE_SIZE)
+ abfd->flags &= ~D_PAGED;
+#endif
+
count = 0;
for (current = abfd->sections; current != NULL; current = current->next)
++count;
--- bfd/libcoff-in.h.page 2009-04-17 12:15:35.000000000 -0700
+++ bfd/libcoff-in.h 2009-04-17 15:37:55.000000000 -0700
@@ -117,8 +117,6 @@ typedef struct pe_tdata
int has_reloc_section;
bfd_boolean (*in_reloc_p) (bfd *, reloc_howto_type *);
flagword real_flags;
- int target_subsystem;
- bfd_boolean force_minimum_alignment;
} pe_data_type;
#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
--- bfd/libcoff.h.page 2009-04-17 12:15:35.000000000 -0700
+++ bfd/libcoff.h 2009-04-17 15:37:55.000000000 -0700
@@ -121,8 +121,6 @@ typedef struct pe_tdata
int has_reloc_section;
bfd_boolean (*in_reloc_p) (bfd *, reloc_howto_type *);
flagword real_flags;
- int target_subsystem;
- bfd_boolean force_minimum_alignment;
} pe_data_type;
#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
--- bfd/peXXigen.c.page 2009-04-17 12:15:37.000000000 -0700
+++ bfd/peXXigen.c 2009-04-17 15:37:55.000000000 -0700
@@ -540,17 +540,6 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, v
bfd_vma sa, fa, ib;
IMAGE_DATA_DIRECTORY idata2, idata5, tls;
- if (pe->force_minimum_alignment)
- {
- if (!extra->FileAlignment)
- extra->FileAlignment = PE_DEF_FILE_ALIGNMENT;
- if (!extra->SectionAlignment)
- extra->SectionAlignment = PE_DEF_SECTION_ALIGNMENT;
- }
-
- if (extra->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN)
- extra->Subsystem = pe->target_subsystem;
-
sa = extra->SectionAlignment;
fa = extra->FileAlignment;
ib = extra->ImageBase;
--- bfd/pei-ia64.c.page 2009-04-17 17:50:40.000000000 -0700
+++ bfd/pei-ia64.c 2009-04-17 17:51:39.000000000 -0700
@@ -1,5 +1,6 @@
/* BFD back-end for HP/Intel IA-64 PE IMAGE COFF files.
- Copyright 1999, 2000, 2001, 2002, 2007, 2009 Free Software Foundation, Inc.
+ Copyright 1999, 2000, 2001, 2002, 2007, 2009
+ Free Software Foundation, Inc.
Contributed by David Mosberger <davidm@hpl.hp.com>
This implementation only supports objcopy to ouput IA-64 PE IMAGE COFF
@@ -34,7 +35,5 @@
#define TARGET_UNDERSCORE '_'
/* Long section names not allowed in executable images, only object files. */
#define COFF_LONG_SECTION_NAMES 0
-#define PEI_TARGET_SUBSYSTEM IMAGE_SUBSYSTEM_EFI_APPLICATION
-#define PEI_FORCE_MINIMUM_ALIGNMENT
#include "coff-ia64.c"
--- bfd/peicode.h.page 2009-04-17 12:15:37.000000000 -0700
+++ bfd/peicode.h 2009-04-17 15:37:55.000000000 -0700
@@ -264,13 +264,6 @@ pe_mkobject (bfd * abfd)
/* in_reloc_p is architecture dependent. */
pe->in_reloc_p = in_reloc_p;
-#ifdef PEI_FORCE_MINIMUM_ALIGNMENT
- pe->force_minimum_alignment = 1;
-#endif
-#ifdef PEI_TARGET_SUBSYSTEM
- pe->target_subsystem = PEI_TARGET_SUBSYSTEM;
-#endif
-
return TRUE;
}
More information about the Binutils
mailing list