From patchwork Fri Sep 22 13:38:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 817510 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-462780-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tUBBLiBh"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xzF1r25FBz9sPm for ; Fri, 22 Sep 2017 23:38:54 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=vjXlhKZWabL3YcShOuAtsjpnD/BgSY6xGwyeCL+2crPWGc i7hQhW1X5eJLOpW68/XB1rqM6L/XnbGXeswj08gEc/ZOh4bNWv9lOExLa4uj1cah A2q6/jI7P61Oo/7HbZSq4W6tcjBSpJyb7ICdI/aKECjoZLkTFNmk3n348cRJk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=vGJPBEdPD+HzeUtI1tbzoFRjZTk=; b=tUBBLiBhvh+p5Brx2fD2 iysyqrT2tatXGGGyWooI1Jo4bSIpn0wMbg79qFdcOs7ZCl4+h+nrToG9ir44RRFq 1tiH6Y7WFJHQVXKcHGBPOq7fDe9GIupyq4eUhkkEmJAzNhNiwDmgX3gh+zzPnCgN R5ARBS7oiTcHjqu715TBzdQ= Received: (qmail 28239 invoked by alias); 22 Sep 2017 13:38:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 28053 invoked by uid 89); 22 Sep 2017 13:38:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1724 X-HELO: mail-io0-f175.google.com Received: from mail-io0-f175.google.com (HELO mail-io0-f175.google.com) (209.85.223.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Sep 2017 13:38:16 +0000 Received: by mail-io0-f175.google.com with SMTP id q11so3060861ioe.10 for ; Fri, 22 Sep 2017 06:38:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8s9DyYNba3vtiAW+JvyL+VtTBLJ82y/PuMEfcIkrcv0=; b=aNOIZIzCcP8I3w4Mn9JDeS7CdQ9TsJxlkIvt6FatrQXqTXICXTvoqVhAvmXkGYqKfG ACT0i7zp+prxJSvCtLz6Kh95a+4Fj50E9Tg4IHAwqZT1ujUTVAijizSmPq/5a9DeoiJK fFq9C1rgvtGbbs9y31BkkvFJrU1blNfE0LuMbRJHz5O8PGaW4smWc2EUvK2epn1gx/RI 2Vq3S/IPhuE6/AOLSesWcfQpTIyaV3K1wNhTinhbqSDJmHTdEHoJq+msSp81BTSx7bL8 gNyuN+oPYEY9LiddyAFnOrpdv352fHVdgC7FWWNTByK+3lJoUy57azSXorLLSD0uzZb9 rDQA== X-Gm-Message-State: AHPjjUiJb5diY7zEatalsGuLhigFf+nig3zZs4nJeYCnGMqXJpjta+YK jIxUCMyBFqhlXb11tuIRn5P3YJSxrDM8I3iHC7F8gWNX X-Google-Smtp-Source: AOwi7QBmM1WzNzFyCsdzhG32kzZTtmpHCms0llTOWMt5h8+RrjPGss3LvU220HTHWqGICuVX9SI5ozqnD7TjVFbcmeM= X-Received: by 10.202.75.211 with SMTP id y202mr6628374oia.140.1506087494051; Fri, 22 Sep 2017 06:38:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.168.117.78 with HTTP; Fri, 22 Sep 2017 06:38:12 -0700 (PDT) From: Ian Lance Taylor Date: Fri, 22 Sep 2017 06:38:12 -0700 Message-ID: Subject: libbacktrace patch committed: Replace lstat and readlink if not available To: gcc-patches This patch to libbacktrace provides dummy versions of lstat and readlink if they are not available on the system. Bootstrapped and ran libbacktrace tests on x86_64-pc-linux-gnu both normally and with a hand-edited config.h. Committed to mainline. Ian 2017-09-22 Ian Lance Taylor PR sanitizer/77631 * configure.ac: Check for lstat and readlink. * elf.c (lstat, readlink): Provide dummy versions if real versions are not available. * configure, config.h.in: Rebuild. Index: configure.ac =================================================================== --- configure.ac (revision 253093) +++ configure.ac (working copy) @@ -373,6 +373,7 @@ if test "$have_fcntl" = "yes"; then fi AC_CHECK_DECLS(strnlen) +AC_CHECK_FUNCS(lstat readlink) # Check for getexecname function. if test -n "${with_target_subdir}"; then Index: elf.c =================================================================== --- elf.c (revision 253093) +++ elf.c (working copy) @@ -75,6 +75,35 @@ xstrnlen (const char *s, size_t maxlen) #endif +#ifndef HAVE_LSTAT + +/* Dummy version of lstat for systems that don't have it. */ + +static int +xlstat (const char *path ATTRIBUTE_UNUSED, struct stat *st ATTRIBUTE_UNUSED) +{ + return -1; +} + +#define lstat xlstat + +#endif + +#ifndef HAVE_READLINK + +/* Dummy version of readlink for systems that don't have it. */ + +static ssize_t +xreadlink (const char *path ATTRIBUTE_UNUSED, char *buf ATTRIBUTE_UNUSED, + size_t bufsz ATTRIBUTE_UNUSED) +{ + return -1; +} + +#define readlink xreadlink + +#endif + #ifndef HAVE_DL_ITERATE_PHDR /* Dummy version of dl_iterate_phdr for systems that don't have it. */