[v5,2/2] IBM zSystems: Define CODE_LABEL_BOUNDARY
Checks
Commit Message
Currently s390 emits the following sequence to store a frame_pc:
a:
.LASANPC0:
lg %r1,.L5-.L4(%r13)
la %r1,0(%r1,%r12)
stg %r1,176(%r11)
.L5:
.quad .LASANPC0@GOTOFF
The reason GOT indirection is used instead of larl is that gcc does not
know that .LASANPC0, being a code label, is aligned on a 2-byte
boundary, and larl can load only even addresses.
Define CODE_LABEL_BOUNDARY in order to get rid of GOT indirection:
larl %r1,.LASANPC0
stg %r1,176(%r11)
gcc/ChangeLog:
2020-06-30 Ilya Leoshkevich <iii@linux.ibm.com>
* config/s390/s390.h (CODE_LABEL_BOUNDARY): Specify that s390
requires code labels to be aligned on a 2-byte boundary.
gcc/testsuite/ChangeLog:
2019-06-30 Ilya Leoshkevich <iii@linux.ibm.com>
* gcc.target/s390/asan-no-gotoff.c: New test.
---
gcc/config/s390/s390.h | 3 +++
gcc/testsuite/gcc.target/s390/asan-no-gotoff.c | 15 +++++++++++++++
2 files changed, 18 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/s390/asan-no-gotoff.c
@@ -368,6 +368,9 @@ extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
/* Allocation boundary (in *bits*) for the code of a function. */
#define FUNCTION_BOUNDARY 64
+/* Alignment required for a code label, in bits. */
+#define CODE_LABEL_BOUNDARY 16
+
/* There is no point aligning anything to a rounder boundary than this. */
#define BIGGEST_ALIGNMENT 64
new file mode 100644
@@ -0,0 +1,15 @@
+/* Test that ASAN labels are referenced without unnecessary indirections. */
+
+/* { dg-do compile } */
+/* { dg-options "-fPIE -O2 -fsanitize=kernel-address --param asan-stack=1" } */
+
+extern void c (int *);
+
+void a ()
+{
+ int b;
+ c (&b);
+}
+
+/* { dg-final { scan-assembler {\tlarl\t%r\d+,\.LASANPC\d+} } } */
+/* { dg-final { scan-assembler-not {\.LASANPC\d+@GOTOFF} } } */