From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by sourceware.org (Postfix) with ESMTPS id 4995C393C858 for ; Fri, 18 Dec 2020 19:52:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4995C393C858 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BIJmYgv182137 for ; Fri, 18 Dec 2020 19:52:11 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 35cn9rv0sx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 18 Dec 2020 19:52:11 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0BIJoKd5146418 for ; Fri, 18 Dec 2020 19:52:11 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 35d7t29psb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 Dec 2020 19:52:11 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0BIJqACX015429 for ; Fri, 18 Dec 2020 19:52:10 GMT Received: from loom.srvr.nix (/81.187.191.129) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 18 Dec 2020 11:52:09 -0800 From: Nick Alcock To: binutils@sourceware.org Cc: jose.marchesi@oracle.com, weimin.pan@oracle.com, Nick Alcock Subject: [PATCH 09/13] libctf: warn about information loss because of unreleased format changes Date: Fri, 18 Dec 2020 19:51:43 +0000 Message-Id: <20201218195147.378720-10-nick.alcock@oracle.com> X-Mailer: git-send-email 2.29.2.250.g8336e49d6f.dirty In-Reply-To: <20201218195147.378720-1-nick.alcock@oracle.com> References: <20201218195147.378720-1-nick.alcock@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9839 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012180133 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9839 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 malwarescore=0 priorityscore=1501 phishscore=0 mlxscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012180133 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Dec 2020 19:52:13 -0000 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 2020-12-15 Nick Alcock * ctf-link.c (ctf_link_warn_outdated_inputs): New. (ctf_link_write): Call it. --- libctf/ctf-link.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c index cdf3db3a7c3..d436b7b8abc 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); -- 2.29.2.250.g8336e49d6f.dirty