This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[LTO] PATCH: PR lto/38995: lto1 uses unaligned data accesses
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 29 Jan 2009 21:33:17 -0800
- Subject: [LTO] PATCH: PR lto/38995: lto1 uses unaligned data accesses
LTO uses mmap to read LTO sections. Since LTO sections are aligned at
1 byte, we may get unaligned data accesses on data with alignment
> 1 byte. LTO sections shouldn't have any data with alignment >
POINTER_SIZE. This patch aligns LTO sections to POINTER_SIZE. Tested
on Linux/ia64 and Linux/x86-64. OK to install?
Thanks.
H.J.
----
gcc/
2009-01-29 H.J. Lu <hongjiu.lu@intel.com>
PR lto/38995
* langhooks.c (lhd_begin_section): Call assemble_align to
align LTO sections to POINTER_SIZE.
gcc/lto/
2009-01-29 H.J. Lu <hongjiu.lu@intel.com>
PR lto/38995
* lto-elf.c (init_shdr##BITS): Set the sh_addralign field
to POINTER_SIZE.
Index: gcc/langhooks.c
===================================================================
--- gcc/langhooks.c (revision 143777)
+++ gcc/langhooks.c (working copy)
@@ -612,6 +612,7 @@ lhd_begin_section (const char *name)
/* Create a new section and switch to it. */
section = get_section (name, SECTION_DEBUG, NULL);
switch_to_section (section);
+ assemble_align (POINTER_SIZE);
}
Index: gcc/lto/lto-elf.c
===================================================================
--- gcc/lto/lto-elf.c (revision 143777)
+++ gcc/lto/lto-elf.c (working copy)
@@ -245,6 +245,7 @@ init_shdr##BITS (Elf_Scn *scn, size_t sh
\
shdr->sh_name = sh_name; \
shdr->sh_type = sh_type; \
+ shdr->sh_addralign = POINTER_SIZE; \
shdr->sh_flags = 0; \
shdr->sh_entsize = 0; \
}