This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [Bug target/14041] H8300-elf unaligned word/longword access of zero initialized variables
- From: "Dhananjay R. Deshpande" <dhananjayd at KPITCummins dot com>
- To: <gcc-bugzilla at gcc dot gnu dot org>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 16 Feb 2004 15:02:40 +0530
- Subject: RE: [Bug target/14041] H8300-elf unaligned word/longword access of zero initialized variables
>
>
> Why not h8300-*? We should care for the COFF target as long as it's
> there.
Initially the bug occurred only for elf target. Looking at generated code, it was due to linker script alignment. So I have now enabled test for h8300-*-*
>
> Would the same problem exist on the plain H8/300 then? IIRC, H8 is
> pretty lenient about alignment, but I don't know how lenient it is.
> Or is it the case that no plain H8/300 supports 16-bit data bus or
> something?
>
Yes, the problem exists on plain H8/300 too. As I mentioned earlier, the compiler will generate ".align 1" for plain H8/300. I couldn't find how to check for ".align 1" when target is plain H8/300 and ".align 2" for -mh and -ms. So I had added -mh in options and checked for ".align 2"
I think it is better to scan only for ".align". Without this patch, .align is not generated.
> By the way, which version of GCC did you run the testsuite for?
>
> Currently, h8300-elf on mainline doesn't build, so I'll apply your
> patch after the build is restored. Meanwhile, you might want to post
> a complete patch with the testcase and ChangeLog entries to
> gcc-patches for the record.
I tested it with 3.4 snapshot. Currently I am facing problems accessing sources using cvs so can't use mainline.
Please find updated patch below -
-Dhananjay
gcc/Changelog -
2004-02-16 Dhananjay Deshpande <dhananjayd@kpitcummins.com>
PR target/14041
* config/h8300/h8300.h (ASM_OUTPUT_ALIGNED_BSS): Define.
==========================================================================
--- config/h8300/h8300.h.old Tue Feb 10 15:51:47 2004
+++ config/h8300/h8300.h Tue Feb 10 15:52:31 2004
@@ -1157,6 +1157,9 @@ struct cum_arg
#define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED) \
asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED))
+#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
+ asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
+
/* This says how to output an assembler line
to define a local common symbol. */
==========================================================================
testsuite/Changelog
2004-02-16 Dhananjay Deshpande <dhananjayd@kpitcummins.com>
PR target/14041
* gcc.dg/h8300-bss-align-1.c : New.
==========================================================================
--- /dev/null Wed May 6 02:02:27 1998
+++ gcc.dg/h8300-bss-align-1.c Fri Feb 13 18:10:01 2004
@@ -0,0 +1,13 @@
+/* Make sure that the H8 backend does align zero initialized variables. */
+/* { dg-do compile { target h8300-*-* } } */
+/* { dg-options "" } */
+
+struct s {
+ char a, b;
+ long c;
+};
+
+struct s s = {0};
+
+/* { dg-final { scan-assembler ".align" } } */
+
==========================================================================