* [PATCH/PE-COFF] Translate required alignment into IMAGE_SCN_ALIGN bits of object s_flags - Take 2
@ 2007-10-24 12:25 Danny Smith
2007-11-07 16:40 ` Nick Clifton
0 siblings, 1 reply; 3+ messages in thread
From: Danny Smith @ 2007-10-24 12:25 UTC (permalink / raw)
To: Binutils
This is a revised version of the patch I submitted earlier.
http://sourceware.org/ml/binutils/2007-10/msg00294.html
The prior patch failed to check if the alignment power fell within valid
range for PE-COFF target,
To recap the earlier message:
Given an alignment >16-bytes, eg
.file "foo.c"
.data
.globl _x
.align 32
_x:
.long 1065353216
.space 28
gas for PE-COFF targets fails to set section alignment flags correctly,
but always uses default. So
as foo.s | objdump -x gives
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000000 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000020 00000000 00000000 0000008c 2**4
ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000000 2**4
ALLOC
The attached fixs by encoding the section alignment_power into the
appropriate bits of the IMAGE_SCN_ALIGN s_flags using the macro
COFF_ENCODE_ALIGNMENT, defined in coff/pe.h.
After this patch we get
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000000 2**4
ALLOC, LOAD, READONLY, CODE
1 .data 00000020 00000000 00000000 0000008c 2**5
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000000 2**4
ALLOC
In addition, it modifies gas/read.c to enable non-default alignment
limits to be checked. The appropriate p2align limit for i386-pe is
defined for TE_PE in config/tc-i386.h as 13, corresponding to the
largest documented PE section alignment flag,IMAGE_SCN_ALIGN_8192BYTE.
No regressions after in-tree combined build of mingw-targeted
binutils/gcc.
include/ChangeLog
2007-10-24 Danny Smith <dannysmith@users.sourceforge.net>
* coff/pe.h (COFF_ENCODE_ALIGNMENT) Define.
gas/ChangeLog
* read.c (ALIGN_LIMIT): Rename to ...
(TC_ALIGN_LIMIT): Guard against prior definition.
* config/tc-i386.h (TC_ALIGN_LIMIT)[TE_PE]: Define.
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.133
diff -c -3 -p -r1.133 read.c
*** gas/read.c 17 Oct 2007 16:45:54 -0000 1.133
--- gas/read.c 23 Oct 2007 02:41:34 -0000
*************** do_align (int n, char *fill, int len, in
*** 1276,1288 ****
(in bytes). A negative ARG is the negative of the length of the
fill pattern. BYTES_P is non-zero if the alignment value should be
interpreted as the byte boundary, rather than the power of 2. */
!
! #define ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
static void
s_align (int arg, int bytes_p)
{
! unsigned int align_limit = ALIGN_LIMIT;
unsigned int align;
char *stop = NULL;
char stopc = 0;
--- 1276,1289 ----
(in bytes). A negative ARG is the negative of the length of the
fill pattern. BYTES_P is non-zero if the alignment value should be
interpreted as the byte boundary, rather than the power of 2. */
! #ifndef TC_ALIGN_LIMIT
! #define TC_ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
! #endif
static void
s_align (int arg, int bytes_p)
{
! unsigned int align_limit = TC_ALIGN_LIMIT;
unsigned int align;
char *stop = NULL;
char stopc = 0;
Index: gas/config/tc-i386.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.h,v
retrieving revision 1.92
diff -c -3 -p -r1.92 tc-i386.h
*** gas/config/tc-i386.h 26 Sep 2007 08:34:24 -0000 1.92
--- gas/config/tc-i386.h 23 Oct 2007 02:41:35 -0000
*************** extern int x86_64_section_letter (int, c
*** 343,348 ****
--- 343,349 ----
#define TC_DWARF2_EMIT_OFFSET tc_pe_dwarf2_emit_offset
void tc_pe_dwarf2_emit_offset (symbolS *, unsigned int);
+ #define TC_ALIGN_LIMIT 13 /* corresponding to
IMAGE_SCN_ALIGN_8192BYTES */
#endif /* TE_PE */
Index: include/coff/pe.h
===================================================================
RCS file: /cvs/src/src/include/coff/pe.h,v
retrieving revision 1.17
diff -c -3 -p -r1.17 pe.h
*** include/coff/pe.h 2 Aug 2007 16:02:01 -0000 1.17
--- include/coff/pe.h 23 Oct 2007 02:41:45 -0000
***************
*** 90,95 ****
--- 90,99 ----
#define IMAGE_SCN_ALIGN_4096BYTES IMAGE_SCN_ALIGN_POWER_CONST
(12)
#define IMAGE_SCN_ALIGN_8192BYTES IMAGE_SCN_ALIGN_POWER_CONST
(13)
+ /* Encode alignment power into IMAGE_SCN_ALIGN bits of s_flags */
+ #define COFF_ENCODE_ALIGNMENT(SECTION, ALIGNMENT_POWER) \
+ ((SECTION).s_flags |= IMAGE_SCN_ALIGN_POWER_CONST
((ALIGNMENT_POWER)))
+
#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 /* Section
contains extended relocations. */
#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 /* Section is
not cachable. */
#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 /* Section is
not pageable. *
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH/PE-COFF] Translate required alignment into IMAGE_SCN_ALIGN bits of object s_flags - Take 2
2007-10-24 12:25 [PATCH/PE-COFF] Translate required alignment into IMAGE_SCN_ALIGN bits of object s_flags - Take 2 Danny Smith
@ 2007-11-07 16:40 ` Nick Clifton
[not found] ` <9c03c2dd0711071232g1ee1c3d1q323ff45a120cfeb1@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2007-11-07 16:40 UTC (permalink / raw)
To: Danny Smith; +Cc: Binutils
Hi Danny,
> include/ChangeLog
> 2007-10-24 Danny Smith <dannysmith@users.sourceforge.net>
>
> * coff/pe.h (COFF_ENCODE_ALIGNMENT) Define.
>
> gas/ChangeLog
> * read.c (ALIGN_LIMIT): Rename to ...
> (TC_ALIGN_LIMIT): Guard against prior definition.
> * config/tc-i386.h (TC_ALIGN_LIMIT)[TE_PE]: Define.
Approved - please apply.
Cheers
Nick
PS. Maybe a gas testsuite entry would be appropriate as well ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Fwd: [PATCH/PE-COFF] Translate required alignment into IMAGE_SCN_ALIGN bits of object s_flags - Take 2
[not found] ` <9c03c2dd0711071232g1ee1c3d1q323ff45a120cfeb1@mail.gmail.com>
@ 2007-11-07 20:34 ` Danny Smith
0 siblings, 0 replies; 3+ messages in thread
From: Danny Smith @ 2007-11-07 20:34 UTC (permalink / raw)
To: binutils
I missed the reply all button when replying to Nick
---------- Forwarded message ----------
From: Danny Smith <dansmister@gmail.com>
Date: Nov 8, 2007 9:32 AM
Subject: Re: [PATCH/PE-COFF] Translate required alignment into
IMAGE_SCN_ALIGN bits of object s_flags - Take 2
To: Nick Clifton
On 11/8/07, Nick Clifton
> Hi Danny,
>
> > include/ChangeLog
> > 2007-10-24 Danny Smith <dannysmith@users.sourceforge.net>
> >
> > * coff/pe.h (COFF_ENCODE_ALIGNMENT) Define.
> >
> > gas/ChangeLog
> > * read.c (ALIGN_LIMIT): Rename to ...
> > (TC_ALIGN_LIMIT): Guard against prior definition.
> > * config/tc-i386.h (TC_ALIGN_LIMIT)[TE_PE]: Define.
>
> Approved - please apply.
>
> Cheers
> Nick
>
> PS. Maybe a gas testsuite entry would be appropriate as well ?
The updated patch
http://sourceware.org/ml/binutils/2007-11/msg00027.html
that Alan approved did enable two ld testsuite entries for PE-COFF.
I'll try to work up a gas entry too.
Danny
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-11-07 20:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-24 12:25 [PATCH/PE-COFF] Translate required alignment into IMAGE_SCN_ALIGN bits of object s_flags - Take 2 Danny Smith
2007-11-07 16:40 ` Nick Clifton
[not found] ` <9c03c2dd0711071232g1ee1c3d1q323ff45a120cfeb1@mail.gmail.com>
2007-11-07 20:34 ` Fwd: " Danny Smith
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).