This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
mingw/cygwin alignment-problem in executables (ld & as)
- From: "Sergey R. Grigoriev" <Serguei dot Grigoriev at Physik dot Uni-Augsburg dot DE>
- To: binutils at sources dot redhat dot com
- Date: Thu, 13 Jun 2002 14:43:43 +0200
- Subject: mingw/cygwin alignment-problem in executables (ld & as)
- Organization: Uni-Augsburg
- Reply-to: Serguei dot Grigoriev at Physik dot Uni-Augsburg dot DE
Hi BFD and GAS Gurus!
Using gcc's __attribute__((align(16))) functionality (nessesary for sse2
and partially sse, and to have working -malign-doubles in GCC) results
in the compiler correctly generating .align directives.
They are not ignored by the assembler and generated symbols are properly
aligned in single object-file. But the sizes of data-sections in object
files are not 16-byte aligned.
GAS try to rallign sections (for each .align XXX in input) but it seems
to not affects output... at least objdump does shows the same
section-alignement (i.e. 2**2) as without ".align 16" directive.
Linked by ld (not all data sections have 16-byte-aligned size) it will
be no more aligned in resuling data segments.
I think there is 2 possible solutions:
1. Align all data-sections sizes to 16-byte
2. Store alignement information in object-files and ling it properly.
Unfortunately I have no knoledge how BFD works (i.e. what information is
stored in object-file header) and how it interacts with GAS...
As workaround (and probably as fix) I copied the part of coff-go32.c
file into pe-i386.c and pei-i386.c files in BFD-library to force gas to
produce 16-bytes aligned data-segments like it is done for i386-GO32
platform.
I need to know if it is right method to do 16-byte alignment of all
data-segments (i.e. forcing BFD to aling it don't break anything) or how
to do it properly?
/***********************************************/
bfd/pei-i386.c:
bfd/pe-i386.c:
#define COFF_LONG_FILENAMES
#define COFF_SECTION_ALIGNMENT_ENTRIES \
{ COFF_SECTION_NAME_EXACT_MATCH (".bss"), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
{ COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
{ COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }
#include "coff-i386.c"