libctf, ld: fix test results for upstream GCC
authorNick Alcock <nick.alcock@oracle.com>
Thu, 6 May 2021 08:30:58 +0000 (09:30 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 6 May 2021 08:31:31 +0000 (09:31 +0100)
The tests currently in binutils are aimed at the original GCC-based
implementation of CTF, which emitted CTF directly from GCC's internal
representation.  The approach now under review emits CTF from DWARF,
with an eye to eventually doing this for all non-DWARF debuginfo-like
formats GCC supports.  It also uses a different flag to enable
CTF emission (-gctf rather than -gt).

Adjust the testsuite accordingly.

Given that the ld testsuite results are dependent on type ordering,
which we do not guarantee at all, it's amazing how little changes. We
see a few type ordering differences, slices change because the old GCC
was buggy (slices were emitted "backwards", from the wrong end of the
machine word) and its expected results were wrong, and GCC now emits the
underlying integral type for enumerated types, though CTF has no way to
record this yet (coming in v4).

GCC also now emits even hidden symbols into the symtab (and thus
symtypetab), so one symtypetab test changes its expected results
slightly to compensate.

Also add tests for the CTF_K_UNKNOWN nonrepresentable type: this
couldn't be done before now since the only GCC that emits CTF_K_UNKNOWN
for nonrepresentable types is the new one.

ld/ChangeLog
2021-05-06  Nick Alcock  <nick.alcock@oracle.com>

* testsuite/ld-ctf/ctf.exp: Use -gctf, not -gt.
* testsuite/lib/ld-lib.exp: Likewise.
* testsuite/ld-ctf/nonrepresentable-1.c: New test for nonrepresentable types.
* testsuite/ld-ctf/nonrepresentable-2.c: Likewise.
* testsuite/ld-ctf/nonrepresentable.d: Likewise.
* testsuite/ld-ctf/array.d: Larger type section.
* testsuite/ld-ctf/data-func-conflicted.d: Likewise.
* testsuite/ld-ctf/enums.d: Likewise.
* testsuite/ld-ctf/conflicting-enums.d: Don't compare types.
* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Changed type order.
* testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
* testsuite/ld-ctf/slice.d: Adjust for improved slice emission.

libctf/ChangeLog
2021-05-06  Nick Alcock  <nick.alcock@oracle.com>

* testsuite/lib/ctf-lib.exp: Use -gctf, not -gt.
* testsuite/libctf-regression/nonstatic-var-section-ld-r.lk:
Hidden symbols now get into the symtypetab anyway.

16 files changed:
ld/ChangeLog
ld/testsuite/ld-ctf/array.d
ld/testsuite/ld-ctf/conflicting-enums.d
ld/testsuite/ld-ctf/cross-tu-cyclic-conflicting.d
ld/testsuite/ld-ctf/cross-tu-noncyclic.d
ld/testsuite/ld-ctf/ctf.exp
ld/testsuite/ld-ctf/data-func-conflicted.d
ld/testsuite/ld-ctf/enums.d
ld/testsuite/ld-ctf/nonrepresentable-1.c [new file with mode: 0644]
ld/testsuite/ld-ctf/nonrepresentable-2.c [new file with mode: 0644]
ld/testsuite/ld-ctf/nonrepresentable.d [new file with mode: 0644]
ld/testsuite/ld-ctf/slice.d
ld/testsuite/lib/ld-lib.exp
libctf/ChangeLog
libctf/testsuite/lib/ctf-lib.exp
libctf/testsuite/libctf-regression/nonstatic-var-section-ld-r.lk

index 0c7c759b42707d0f5343f16a157d33d9b3c3610e..1ddf61d1bd39efe7cebfd4ee5ac83c2359d08872 100644 (file)
@@ -1,3 +1,18 @@
+2021-05-06  Nick Alcock  <nick.alcock@oracle.com>
+
+       * testsuite/ld-ctf/ctf.exp: Use -gctf, not -gt.
+       * testsuite/lib/ld-lib.exp: Likewise.
+       * testsuite/ld-ctf/nonrepresentable-1.c: New test for nonrepresentable types.
+       * testsuite/ld-ctf/nonrepresentable-2.c: Likewise.
+       * testsuite/ld-ctf/nonrepresentable.d: Likewise.
+       * testsuite/ld-ctf/array.d: Larger type section.
+       * testsuite/ld-ctf/data-func-conflicted.d: Likewise.
+       * testsuite/ld-ctf/enums.d: Likewise.
+       * testsuite/ld-ctf/conflicting-enums.d: Don't compare types.
+       * testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Changed type order.
+       * testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
+       * testsuite/ld-ctf/slice.d: Adjust for improved slice emission.
+
 2021-05-05  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/27825
index ab262d915b53f28487e819736bda8f49054e156d..142f9e9fa947d548a85d8409c6ea228fa65941a5 100644 (file)
@@ -14,7 +14,7 @@ Contents of CTF section .ctf:
     Version: 4 \(CTF_VERSION_3\)
 #...
     Data object section:       .* \(0x[1-9a-f][0-9a-f]* bytes\)
-    Type section:      .* \(0x5c bytes\)
+    Type section:      .* \(0x6c bytes\)
     String section:    .*
 
   Labels:
index f90aaef44b1e6020bcdedbb204fc8015d24bca7a..5eeae7a13edc344ec9f552da2fea0c5f7e62cc0a 100644 (file)
@@ -14,7 +14,7 @@ Contents of CTF section .ctf:
     Version: 4 \(CTF_VERSION_3\)
 #...
   Types:
-
+#...
   Strings:
 #...
 CTF archive member: .*enum.*\.c:
index eaf8e79c8adfe24d68c8207ad52b80d8fd6ba6db..6d5e869bfbef65e1491cb4f25fa572793ca6b69e 100644 (file)
@@ -13,12 +13,12 @@ Contents of CTF section \.ctf:
 
 #...
   Types:
-#...
-    0x[0-9a-f]*: \(kind 1\) long int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 #...
     0x[0-9a-f]*: \(kind 6\) struct B .*
 #...
     0x[0-9a-f]*: \(kind 1\) int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+#...
+    0x[0-9a-f]*: \(kind 1\) long int \(format 0x1\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
 #...
     0x[0-9a-f]*: \(kind 9\) struct A
 #...
index e8fc7a49aa54c6ec63ad3f2f0c0acc8eca57b18b..3ebc52dcb3bb9c0b0d9318947e61afed8bf85685 100644 (file)
@@ -28,13 +28,13 @@ Contents of CTF section .ctf:
 #...
 
   Types:
+#...
+    0x[0-9a-f]*: \(kind 6\) struct B .*
+       *\[0x0\] foo: ID 0x[0-9a-f]*: \(kind 1\) int .*
 #...
     0x[0-9a-f]*: \(kind 6\) struct A .*
        *\[0x0\] a: ID 0x[0-9a-f]*: \(kind 1\) long int .*
        *\[0x[0-9a-f]*\] foo: ID 0x[0-9a-f]*: \(kind 3\) struct B \* .*
-#...
-    0x[0-9a-f]*: \(kind 6\) struct B .*
-       *\[0x0\] foo: ID 0x[0-9a-f]*: \(kind 1\) int .*
 #...
     0x[0-9a-f]*: \(kind 3\) struct B \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> 0x[0-9a-f]*: \(kind 6\) struct B .*
 #...
index c5f6d5cec5b299133f41b3b92a5de4d666116527..0e74d6c569c7f48693507ca584239b601737361d 100644 (file)
@@ -42,7 +42,7 @@ foreach ctf_test $ctf_test_list {
        }
     }
     verbose [file rootname $ctf_test]
-    run_dump_test [file rootname $ctf_test] { { cc "-gt -fPIC" } }
+    run_dump_test [file rootname $ctf_test] { { cc "-gctf -fPIC" } }
 }
 
 if {[info exists old_lc_all]} {
index 87dd4b61e3b7d53a4371a2d2c1d0eea8980fa5ca..f4f4fdd0e48c45946cee1c028868f6f5eaa045a7 100644 (file)
@@ -16,7 +16,7 @@ Contents of CTF section \.ctf:
     Data object section:       .* \(0x[1-9a-f][0-9a-f]* bytes\)
     Function info section:     .* \(0x[1-9a-f][0-9a-f]* bytes\)
     Object index section:      .* \(0xc bytes\)
-    Type section:      .* \(0xf4 bytes\)
+    Type section:      .* \(0x118 bytes\)
     String section:    .*
 #...
   Data objects:
index f1cf70de5af0c7e2c441dcd138e1c661b36c8eaa..d36c7e19f7fd457a30851c112ca460190cd02162 100644 (file)
@@ -14,7 +14,7 @@ Contents of CTF section .ctf:
 #...
     Compilation unit name: .*enums.c
 #...
-    Type section:      .*\(0x114 bytes\)
+    Type section:      .*\(0x134 bytes\)
 #...
   Types:
     0x1: \(kind 8\) enum nine_els \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
@@ -27,7 +27,8 @@ Contents of CTF section .ctf:
          NINE_SEVEN: 260
          NINE_EIGHT: 261
          NINE_NINE: 262
-    0x2: \(kind 8\) enum ten_els \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+    0x2: \(kind 1\) .*int \(format 0x[01]\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]\)
+    0x3: \(kind 8\) enum ten_els \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
          TEN_ONE: 10
          TEN_TWO: 11
          TEN_THREE: -256
@@ -38,7 +39,8 @@ Contents of CTF section .ctf:
          TEN_EIGHT: -251
          TEN_NINE: -250
          TEN_TEN: -249
-    0x3: \(kind 8\) enum eleven_els \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+    0x4: \(kind 1\) .*int \(format 0x[01]\) \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
+    0x5: \(kind 8\) enum eleven_els \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
          ELEVEN_ONE: 10
          ELEVEN_TWO: 11
          ELEVEN_THREE: -256
diff --git a/ld/testsuite/ld-ctf/nonrepresentable-1.c b/ld/testsuite/ld-ctf/nonrepresentable-1.c
new file mode 100644 (file)
index 0000000..3135347
--- /dev/null
@@ -0,0 +1,7 @@
+#include <complex.h>
+
+int foo (complex int a)
+{
+  return 3;
+}
+
diff --git a/ld/testsuite/ld-ctf/nonrepresentable-2.c b/ld/testsuite/ld-ctf/nonrepresentable-2.c
new file mode 100644 (file)
index 0000000..c008c11
--- /dev/null
@@ -0,0 +1,11 @@
+#include <complex.h>
+
+extern int foo (complex int);
+
+int main (void)
+{
+  complex int a = 33.4;
+  foo (a);
+
+  return 1;
+}
diff --git a/ld/testsuite/ld-ctf/nonrepresentable.d b/ld/testsuite/ld-ctf/nonrepresentable.d
new file mode 100644 (file)
index 0000000..8461b54
--- /dev/null
@@ -0,0 +1,26 @@
+#as:
+#source: nonrepresentable-1.c
+#source: nonrepresentable-2.c
+#objdump: --ctf=.ctf
+#ld: -shared
+#name: Nonrepresentable types
+
+.*: +file format .*
+
+Contents of CTF section .ctf:
+
+  Header:
+    Magic number: 0xdff2
+    Version: 4 \(CTF_VERSION_3\)
+#...
+  Function objects:
+#...
+    foo -> 0x[0-9]*: \(kind 5\) int \(\*\) \(\(nonrepresentable type.*\)\) \(aligned at 0x8\)
+#...
+  Types:
+#...
+    0x[0-9a-f]*: \(kind 0\) \(nonrepresentable type.*\)
+#...
+
+  Strings:
+#...
index efe32a87523f05fcd8c483bbf56d8a9af19473aa..8973dcf05e134a5ef2168bfcc41dfa6e8226ae0f 100644 (file)
@@ -15,7 +15,7 @@ Contents of CTF section .ctf:
     Compilation unit name: .*slice.c
 #...
     Data object section:       .* \(0x[1-9a-f][0-9a-f]* bytes\)
-    Type section:      .* \(0xd0 bytes\)
+    Type section:      .* \(0xe0 bytes\)
     String section:    .*
 #...
   Data objects:
@@ -25,8 +25,9 @@ Contents of CTF section .ctf:
 #...
     0x[0-9a-f]*: \(kind 6\) struct slices \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
         *\[0x0\] one: ID 0x[0-9a-f]*: \(kind 1\) int:1 \[slice 0x0:0x1\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\)
-        *\[0x1\] two: ID 0x[0-9a-f]*: \(kind 1\) int:2 \[slice 0x1:0x2\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\)
-        *\[0x3\] six: ID 0x[0-9a-f]*: \(kind 1\) int:6 \[slice 0x3:0x6\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\)
-        *\[0x9\] ten: ID 0x[0-9a-f]*: \(kind 1\) int:10 \[slice 0x9:0xa\] \(format 0x1\) \(size 0x2\) \(aligned at 0x2\)
-        *\[0x13\] bar: ID 0x[0-9a-f]*: \(kind 8\) enum foo:1 \[slice 0x13:0x1\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\)
+        *\[0x1\] two: ID 0x[0-9a-f]*: \(kind 1\) int:2 \[slice 0x0:0x2\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\)
+        *\[0x3\] six: ID 0x[0-9a-f]*: \(kind 1\) int:6 \[slice 0x0:0x6\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\)
+        *\[0x9\] ten: ID 0x[0-9a-f]*: \(kind 1\) int:10 \[slice 0x0:0xa\] \(format 0x1\) \(size 0x2\) \(aligned at 0x2\)
+        *\[0x13\] bar: ID 0x[0-9a-f]*: \(kind 8\) enum foo:1 \[slice 0x0:0x1\] \(format 0x1\) \(size 0x1\) \(aligned at 0x1\)
+
 #...
index a56c945f9b1d5f694870277ad0b9c5c980a53ca3..b1080889a8edbb4b5ac8a519e4735d13fc29bf63 100644 (file)
@@ -1625,7 +1625,7 @@ proc compile_one_cc { src output additional_flags } {
     return [run_host_cmd_yesno "$CC" "$flags $CFLAGS $additional_flags $src -o $output"]
 }
 
-# Returns true if the target compiler supports -gt
+# Returns true if the target compiler supports -gctf
 proc check_ctf_available { } {
     global ctf_available_saved
 
@@ -1639,7 +1639,7 @@ proc check_ctf_available { } {
            set f [open $src "w"]
            puts $f "int main() { return 0; }"
            close $f
-           set ctf_available_saved [compile_one_cc $src $output "-gt -c"]
+           set ctf_available_saved [compile_one_cc $src $output "-gctf -c"]
            remote_file host delete $src
            remote_file host delete $output
            file delete $src
index 51ecc85f75a7d953c742e0f610efbfcd3af89549..979c6c55cb2f5fba706d9c18806c7ca359ff70a2 100644 (file)
@@ -1,3 +1,9 @@
+2021-05-06  Nick Alcock  <nick.alcock@oracle.com>
+
+       * testsuite/lib/ctf-lib.exp: Use -gctf, not -gt.
+       * testsuite/libctf-regression/nonstatic-var-section-ld-r.lk:
+       Hidden symbols now get into the symtypetab anyway.
+
 2021-05-06  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-open.c (init_types): Unknown types may have names.
index 2f1742c8755e59ea102677bc3242bed532413559..0fb095829c65d013c3f61f8d2749e4fb9f3fe353 100644 (file)
@@ -197,10 +197,10 @@ proc run_lookup_test { name } {
        set lookup_flags ""
        if { $run_ld } {
            set lookup_output "tmpdir/out.so"
-           set lookup_flags "-gt -fPIC $shared $opts(link_flags)"
+           set lookup_flags "-gctf -fPIC $shared $opts(link_flags)"
        } else {
            set lookup_output "tmpdir/out.o"
-           set lookup_flags "-gt -fPIC -c"
+           set lookup_flags "-gctf -fPIC -c"
        }
        if [board_info [target_info name] exists cflags] {
            append lookup_flags " [board_info [target_info name] cflags]"
index 68c777fef66c7bf6889b23cc7457519a25081535..7e31a37557ccf5871ccd40770a25d2cbf176f206 100644 (file)
@@ -4,4 +4,3 @@
 # link_flags: -Wl,--ctf-variables -r
 foo is of type [0-9a-f]*
 bar is of type [0-9a-f]*
-foo missing from the data object section