aboutsummaryrefslogtreecommitdiff
path: root/libctf
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2021-01-05 13:25:56 +0000
committerNick Alcock <nick.alcock@oracle.com>2021-01-05 14:53:40 +0000
commitabed0b0718a6a9cd24cc68fb1f73baf6b31d8ff4 (patch)
tree490951afb5e422263c184bf5161884ff0dda493d /libctf
parent9bc769718db238c98f14aafc335426f47b52d4cd (diff)
downloadfsf-binutils-gdb-abed0b0718a6a9cd24cc68fb1f73baf6b31d8ff4.zip
fsf-binutils-gdb-abed0b0718a6a9cd24cc68fb1f73baf6b31d8ff4.tar.gz
fsf-binutils-gdb-abed0b0718a6a9cd24cc68fb1f73baf6b31d8ff4.tar.bz2
libctf: warn about information loss because of unreleased format changes
In the last cycle there have been various changes that have replaced parts of the CTF format with other parts without format compatibility. This was not a compat break, because the old format was never accepted by any version of libctf (the not-in-official-release CTF compiler patch was emitting an invalid func info section), but nonetheless it can confuse users using that patch if they link together object files and find the func info sections in the inputs silently disappearing. Scan the linker inputs for this problem and emit a warning if any are found. libctf/ChangeLog 2021-01-05 Nick Alcock <nick.alcock@oracle.com> * ctf-link.c (ctf_link_warn_outdated_inputs): New. (ctf_link_write): Call it.
Diffstat (limited to 'libctf')
-rw-r--r--libctf/ChangeLog5
-rw-r--r--libctf/ctf-link.c30
2 files changed, 35 insertions, 0 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index f11b511..db75fd5 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,5 +1,10 @@
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
+ * ctf-link.c (ctf_link_warn_outdated_inputs): New.
+ (ctf_link_write): Call it.
+
+2021-01-05 Nick Alcock <nick.alcock@oracle.com>
+
* testsuite/libctf-lookup/enum-symbol.lk: New symbol-lookup test.
* testsuite/libctf-lookup/enum-symbol-ctf.c: New CTF input.
* testsuite/libctf-lookup/enum-symbol.c: New lookup test.
diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c
index 14ed322..5384b20 100644
--- a/libctf/ctf-link.c
+++ b/libctf/ctf-link.c
@@ -2004,6 +2004,34 @@ ctf_change_parent_name (void *key _libctf_unused_, void *value, void *arg)
ctf_parent_name_set (fp, name);
}
+/* Warn if we may suffer information loss because the CTF input files are too
+ old. Usually we provide complete backward compatibility, but compiler
+ changes etc which never hit a release may have a flag in the header that
+ simply prevents those changes from being used. */
+static void
+ctf_link_warn_outdated_inputs (ctf_dict_t *fp)
+{
+ ctf_next_t *i = NULL;
+ void *name_;
+ void *ifp_;
+ int err;
+
+ while ((err = ctf_dynhash_next (fp->ctf_link_inputs, &i, &name_, &ifp_)) == 0)
+ {
+ const char *name = (const char *) name_;
+ ctf_dict_t *ifp = (ctf_dict_t *) ifp_;
+
+ if (!(ifp->ctf_header->cth_flags & CTF_F_NEWFUNCINFO)
+ && (ifp->ctf_header->cth_varoff - ifp->ctf_header->cth_funcoff) > 0)
+ ctf_err_warn (ifp, 1, 0, _("linker input %s has CTF func info but uses "
+ "an old, unreleased func info format: "
+ "this func info section will be dropped."),
+ name);
+ }
+ if (err != ECTF_NEXT_END)
+ ctf_err_warn (fp, 0, err, _("error checking for outdated inputs"));
+}
+
/* Write out a CTF archive (if there are per-CU CTF files) or a CTF file
(otherwise) into a new dynamically-allocated string, and return it.
Members with sizes above THRESHOLD are compressed. */
@@ -2023,6 +2051,8 @@ ctf_link_write (ctf_dict_t *fp, size_t *size, size_t threshold)
memset (&arg, 0, sizeof (ctf_name_list_accum_cb_arg_t));
arg.fp = fp;
+ ctf_link_warn_outdated_inputs (fp);
+
if (fp->ctf_link_outputs)
{
ctf_dynhash_iter (fp->ctf_link_outputs, ctf_accumulate_archive_names, &arg);