aboutsummaryrefslogtreecommitdiff
path: root/libctf/testsuite/libctf-lookup/big-struct-ctf.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2025-09-22 21:07:11 +0100
committerNick Alcock <nick.alcock@oracle.com>2025-09-25 05:42:27 +0100
commit7412b0a35c72921f9d84a2f6b07219f7cb6acd6d (patch)
treeaeb8111bf10c9e1260f8accae1a27052cf78e33d /libctf/testsuite/libctf-lookup/big-struct-ctf.c
parent6fb5a51c4084d5734e2da524b9fc023db49a57c5 (diff)
downloadbinutils-7412b0a35c72921f9d84a2f6b07219f7cb6acd6d.zip
binutils-7412b0a35c72921f9d84a2f6b07219f7cb6acd6d.tar.gz
binutils-7412b0a35c72921f9d84a2f6b07219f7cb6acd6d.tar.bz2
libctf: fix querying of large structures
After GCC PR 121411 is fixed, large structures (with offsets > 512MiB) are written correctly... but libctf cannot query them properly unless they are even bigger (> 4GiB), because it checks to see if the ctt_size is CTF_LSIZE_SENT to decide whether to use a ctf_lmember_t or a ctf_member_t to encode the structure members. But the structure member offsets are in *bits*, not bytes: the right value to check is CTF_LSTRUCT_THRESH, which is 1/8th the size. (Thanks to Martin Pirker <martin.pirker1@chello.at> for the diagnosis and fix.) Testing this is a bit fun, because we don't want to emit an error if the compiler is broken: but we cannot tell whether the compiler is broken using the existing lookup harness, because its input is passed through the linker (and thus the broken ld). So add another sort of link mode, "objects", which keeps the constituent object files around and passes both the final linker output and the object files that make it up to the lookup program. Our testcase can then check the linker input to see if the compiler is buggy, and only if it isn't check the linker output and fail if things aren't right. libctf/ PR libctf/33339 * ctf-types.c (ctf_struct_member): Check CTF_LSTRUCT_THRESH, not CTF_LSIZE_SENT. * testsuite/lib/ctf-lib.exp (run_lookup_test): New 'objects' link option. * testsuite/libctf-lookup/big-struct-corruption.*: New test. * testsuite/libctf-lookup/big-struct-ctf.c: New test input.
Diffstat (limited to 'libctf/testsuite/libctf-lookup/big-struct-ctf.c')
-rw-r--r--libctf/testsuite/libctf-lookup/big-struct-ctf.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/libctf/testsuite/libctf-lookup/big-struct-ctf.c b/libctf/testsuite/libctf-lookup/big-struct-ctf.c
new file mode 100644
index 0000000..fc99a3e
--- /dev/null
+++ b/libctf/testsuite/libctf-lookup/big-struct-ctf.c
@@ -0,0 +1,72 @@
+#if defined (__SIZEOF_PTRDIFF_T__) && __SIZEOF_PTRDIFF_T__ > 4
+
+#define CONCAT_(a,b) a ## b
+#define CONCAT(a,b) CONCAT_(a, b)
+#define COUNT(name) CONCAT(name, __COUNTER__)
+#define MEMBNAME const char COUNT(memb)[1024 * 1024]
+#define MEMB10 \
+ MEMBNAME; \
+ MEMBNAME; \
+ MEMBNAME; \
+ MEMBNAME; \
+ MEMBNAME; \
+ MEMBNAME; \
+ MEMBNAME; \
+ MEMBNAME; \
+ MEMBNAME; \
+ MEMBNAME;
+
+#define MEMB100 \
+ MEMB10 \
+ MEMB10 \
+ MEMB10 \
+ MEMB10 \
+ MEMB10 \
+ MEMB10 \
+ MEMB10 \
+ MEMB10 \
+ MEMB10 \
+ MEMB10
+
+#define MEMB1000 \
+ MEMB100 \
+ MEMB100 \
+ MEMB100 \
+ MEMB100 \
+ MEMB100 \
+ MEMB100 \
+ MEMB100 \
+ MEMB100 \
+ MEMB100 \
+ MEMB100
+
+#define MEMB10000 \
+ MEMB1000 \
+ MEMB1000 \
+ MEMB1000 \
+ MEMB1000 \
+ MEMB1000 \
+ MEMB1000 \
+ MEMB1000 \
+ MEMB1000 \
+ MEMB1000 \
+ MEMB1000
+
+struct big
+{
+ MEMB1000;
+};
+
+struct huge
+{
+ MEMB10000;
+};
+
+struct big big_used;
+struct huge huge_used;
+
+#else
+
+int test_disabled;
+
+#endif