https://gcc.gnu.org/g:f56b63ddbfe51fa38ccd1ee055e008a5b1d7e307
commit r17-6603-gf56b63ddbfe51fa38ccd1ee055e008a5b1d7e307 Author: Ard Biesheuvel <[email protected]> Date: Sat Nov 21 00:14:15 2026 +0100 s390: Align the entries of __mcount_loc As on x86, -mrecord-mcount emits __mcount_loc without an alignment directive. This stops the linker from using packed relative relocations (RELR) for its entries in position independent output. Align the entries to their size. gcc/ChangeLog: * config/s390/s390.cc (s390_function_profiler): Align the __mcount_loc entries to their size. gcc/testsuite/ChangeLog: * gcc.target/s390/mrecord-mcount.c: Check the alignment. Signed-off-by: Ard Biesheuvel <[email protected]> Diff: --- gcc/config/s390/s390.cc | 4 ++++ gcc/testsuite/gcc.target/s390/mrecord-mcount.c | 1 + 2 files changed, 5 insertions(+) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index de8a83a77679..c6b1444cb3c1 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -14194,6 +14194,10 @@ s390_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) if (flag_record_mcount) { fprintf (file, "\t.section __mcount_loc, \"a\",@progbits\n"); + /* Align the entries to their size: the linker only uses packed + relative relocations (RELR) for them in position independent + output if they are aligned. */ + ASM_OUTPUT_ALIGN (file, 3); fprintf (file, "\t.quad 1b\n"); fprintf (file, "\t.previous\n"); } diff --git a/gcc/testsuite/gcc.target/s390/mrecord-mcount.c b/gcc/testsuite/gcc.target/s390/mrecord-mcount.c index d8a23ffdca43..47614bdf98cc 100644 --- a/gcc/testsuite/gcc.target/s390/mrecord-mcount.c +++ b/gcc/testsuite/gcc.target/s390/mrecord-mcount.c @@ -6,5 +6,6 @@ profileme (void) { /* { dg-final { scan-assembler ".section __mcount_loc, \"a\",@progbits" } } */ /* { dg-final { scan-assembler ".quad 1b" } } */ + /* { dg-final { scan-assembler ".align\t8\n\t.quad 1b" } } */ /* { dg-final { scan-assembler ".previous" } } */ }
