summaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2021-10-25 11:17:02 +0100
committerNick Alcock <nick.alcock@oracle.com>2021-10-25 11:17:05 +0100
commiteb5323fdf88aff59afca0a545877c4d777ff2726 (patch)
treebacc4ebe4f83df36805d5a30ec1f890be3e89295 /ld
parenta0cc569d599f92c3a9168fcd23a0b18f7ff42f1d (diff)
libctf, ld: handle nonrepresentable types better
ctf_type_visit (used, among other things, by the type dumping code) was aborting when it saw a nonrepresentable type anywhere: even a single structure member with a nonrepresentable type caused an abort with ECTF_NONREPRESENTABLE. This is not useful behaviour, given that the abort comes from a type-resolution we are only doing in order to determine whether the type is a structure or union. We know nonrepresentable types can't be either, so handle that case and pass the nonrepresentable type down. (The added test verifies that the dumper now handles this case and prints nonrepresentable structure members as it already does nonrepresentable top-level types, rather than skipping the whole structure -- or, without the previous commit, skipping the whole types section.) ld/ChangeLog 2021-10-25 Nick Alcock <nick.alcock@oracle.com> * testsuite/ld-ctf/nonrepresentable-member.*: New test. libctf/ChangeLog 2021-10-25 Nick Alcock <nick.alcock@oracle.com> * ctf-types.c (ctf_type_rvisit): Handle nonrepresentable types.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog4
-rw-r--r--ld/testsuite/ld-ctf/nonrepresentable-member.c7
-rw-r--r--ld/testsuite/ld-ctf/nonrepresentable-member.d25
3 files changed, 36 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 470e446ad5..c613b39804 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,9 @@
2021-10-25 Nick Alcock <nick.alcock@oracle.com>
+ * testsuite/ld-ctf/nonrepresentable-member.*: New test.
+
+2021-10-25 Nick Alcock <nick.alcock@oracle.com>
+
* testsuite/ld-ctf/array.d: Change --ctf=.ctf to --ctf.
* testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise.
diff --git a/ld/testsuite/ld-ctf/nonrepresentable-member.c b/ld/testsuite/ld-ctf/nonrepresentable-member.c
new file mode 100644
index 0000000000..b3657af01e
--- /dev/null
+++ b/ld/testsuite/ld-ctf/nonrepresentable-member.c
@@ -0,0 +1,7 @@
+struct blah
+{
+ int boring;
+ int __attribute__((vector_size(8))) foo;
+ const int __attribute__((vector_size(8))) bar;
+ int this_is_printed;
+} wibble __attribute__((__used__));
diff --git a/ld/testsuite/ld-ctf/nonrepresentable-member.d b/ld/testsuite/ld-ctf/nonrepresentable-member.d
new file mode 100644
index 0000000000..6c76253a8c
--- /dev/null
+++ b/ld/testsuite/ld-ctf/nonrepresentable-member.d
@@ -0,0 +1,25 @@
+#as:
+#source: nonrepresentable-member.c
+#objdump: --ctf
+#ld: -shared
+#name: Nonrepresentable members
+
+.*: +file format .*
+
+Contents of CTF section .ctf:
+
+ Header:
+ Magic number: 0xdff2
+ Version: 4 \(CTF_VERSION_3\)
+#...
+ Types:
+#...
+ 0x[0-9a-f]*: \(kind 6\) struct blah .*
+ *\[0x0\] boring: ID 0x[0-9a-f]*: \(kind 1\) int .*
+ *\[0x[0-9a-f]*\] foo: .* \(.*represent.*\)
+ *\[0x[0-9a-f]*\] bar: .* \(.*represent.*\)
+ *\[0x[0-9a-f]*\] this_is_printed: ID 0x[0-9a-f]*: \(kind 1\) int .*
+#...
+
+ Strings:
+#...