]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Add a test case for PR110729 [PR110729]
authorKewen Lin <linkw@linux.ibm.com>
Fri, 21 Jul 2023 05:16:29 +0000 (00:16 -0500)
committerKewen Lin <linkw@linux.ibm.com>
Fri, 21 Jul 2023 05:16:29 +0000 (00:16 -0500)
As PR110729 reported, there was one issue for .section
__patchable_function_entries with -ffunction-sections, that
is we put the same symbol as link_to section symbol for all
functions wrongly.  The commit r13-4294 for PR99889 has
fixed this with the corresponding label LPFE* which sits in
the function_section.

As Fangrui suggested [1], this patch is to add a bit more
test coverage.  I didn't find a good way to check all
linked_to symbols are different, so I checked for LPFE[012].

[1] https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624866.html

PR testsuite/110729

gcc/testsuite/ChangeLog:

* gcc.dg/pr110729.c: New test.

gcc/testsuite/gcc.dg/pr110729.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/pr110729.c b/gcc/testsuite/gcc.dg/pr110729.c
new file mode 100644 (file)
index 0000000..29b8c1c
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */
+/* { dg-require-effective-target o_flag_in_section } */
+/* { dg-options "-ffunction-sections -fpatchable-function-entry=2" } */
+/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */
+
+/* Verify there are three different link_to symbols for three
+   .section __patchable_function_entries respectively.  */
+
+int
+f ()
+{
+  return 1;
+}
+
+int
+g ()
+{
+  return 2;
+}
+
+int
+h ()
+{
+  return 3;
+}
+
+/* { dg-final { scan-assembler-times {.section[\t ]*__patchable_function_entries,.*,\.LPFE0} 1 } }  */
+/* { dg-final { scan-assembler-times {.section[\t ]*__patchable_function_entries,.*,\.LPFE1} 1 } }  */
+/* { dg-final { scan-assembler-times {.section[\t ]*__patchable_function_entries,.*,\.LPFE2} 1 } }  */