This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][LTO] Fix unaligned WPA sections, PR40754
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Diego Novillo <dnovillo at google dot com>
- Date: Tue, 29 Sep 2009 14:16:41 +0200 (CEST)
- Subject: [PATCH][LTO] Fix unaligned WPA sections, PR40754
This fixes the fact that we output WPA sections unaligned and thus
create many unaligned accesses which makes STRICT_ALIGNMENT targets
fail for -fwhopr.
Quickly tested on ia64, bootstrap and regtest running there.
Richard.
2009-09-29 Richard Guenther <rguenther@suse.de>
PR lto/40754
lto/
* lto-elf.c (init_shdr##BITS): Properly specify alignment
in bytes.
(first_data_block): New static variable.
(lto_elf_append_data): Align the first data block in each
section.
Index: gcc/lto/lto-elf.c
===================================================================
*** gcc/lto/lto-elf.c (revision 152269)
--- gcc/lto/lto-elf.c (working copy)
*************** init_shdr##BITS (Elf_Scn *scn, size_t sh
*** 236,242 ****
\
shdr->sh_name = sh_name; \
shdr->sh_type = sh_type; \
! shdr->sh_addralign = POINTER_SIZE; \
shdr->sh_flags = 0; \
shdr->sh_entsize = 0; \
}
--- 236,242 ----
\
shdr->sh_name = sh_name; \
shdr->sh_type = sh_type; \
! shdr->sh_addralign = POINTER_SIZE / BITS_PER_UNIT; \
shdr->sh_flags = 0; \
shdr->sh_entsize = 0; \
}
*************** init_shdr##BITS (Elf_Scn *scn, size_t sh
*** 244,249 ****
--- 244,250 ----
DEFINE_INIT_SHDR (32)
DEFINE_INIT_SHDR (64)
+ static bool first_data_block;
/* Begin a new ELF section named NAME with type TYPE in the current output
file. TYPE is an SHT_* macro from the libelf headers. */
*************** lto_elf_begin_section_with_type (const c
*** 286,291 ****
--- 287,294 ----
default:
gcc_unreachable ();
}
+
+ first_data_block = true;
}
*************** lto_elf_append_data (const void *data, s
*** 318,324 ****
if (!elf_data)
fatal_error ("elf_newdata() failed: %s.", elf_errmsg(-1));
! elf_data->d_align = 1;
elf_data->d_buf = CONST_CAST (void *, data);
elf_data->d_off = 0LL;
elf_data->d_size = len;
--- 321,333 ----
if (!elf_data)
fatal_error ("elf_newdata() failed: %s.", elf_errmsg(-1));
! if (first_data_block)
! {
! elf_data->d_align = POINTER_SIZE / BITS_PER_UNIT;
! first_data_block = false;
! }
! else
! elf_data->d_align = 1;
elf_data->d_buf = CONST_CAST (void *, data);
elf_data->d_off = 0LL;
elf_data->d_size = len;