riscv: Fix incorrect gnu property alignment on rv32

Codegen is incorrectly emitting a ".p2align 3" that coerces the
alignment of the .note.gnu.property section from 4 to 8 on rv32.

2025-04-11  Jesse Huang  <jesse.huang@sifive.com>

gcc/ChangeLog

	* config/riscv/riscv.cc (riscv_file_end): Fix .p2align value.

gcc/testsuite/ChangeLog

	* gcc.target/riscv/gnu-property-align-rv32.c: New file.
	* gcc.target/riscv/gnu-property-align-rv64.c: New file.
This commit is contained in:
Jesse Huang 2025-04-10 21:25:21 -07:00 committed by Kito Cheng
parent 1d9e02bb7e
commit fc4099a484
3 changed files with 15 additions and 1 deletions

View file

@ -10382,7 +10382,7 @@ riscv_file_end ()
fprintf (asm_out_file, "1:\n");
/* pr_type. */
fprintf (asm_out_file, "\t.p2align\t3\n");
fprintf (asm_out_file, "\t.p2align\t%u\n", p2align);
fprintf (asm_out_file, "2:\n");
fprintf (asm_out_file, "\t.long\t0xc0000000\n");
/* pr_datasz. */

View file

@ -0,0 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-march=rv32g_zicfiss -fcf-protection=return -mabi=ilp32d " } */
void foo() {}
/* { dg-final { scan-assembler-times ".p2align\t2" 3 } } */
/* { dg-final { scan-assembler-not ".p2align\t3" } } */

View file

@ -0,0 +1,7 @@
/* { dg-do compile } */
/* { dg-options "-march=rv64g_zicfiss -fcf-protection=return -mabi=lp64d " } */
void foo() {}
/* { dg-final { scan-assembler-times ".p2align\t3" 3 } } */
/* { dg-final { scan-assembler-not ".p2align\t2" } } */