From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 8F0FA3857C7E for ; Mon, 12 Jul 2021 09:59:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F0FA3857C7E Received: by mail-lj1-x232.google.com with SMTP id 141so6718204ljj.2 for ; Mon, 12 Jul 2021 02:59:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=tUzbaS1IKauTYK4J9pyCA9ydgb+dax1z7XRD5F5QO6g=; b=JWjHB0S8AZqO9SKgGUaSd6N9iOuBhfaxOTF/GirAHsiKazNF4Lo69GPmyFyFq8VHqR 6OuzZMaK5foxeQZKpBhL8RewVil1ZIjWWnku0Nl+ypXdbRH5NPaQM6m82Opy7tchXG3F Qvc+l9gIYg0XYAT7U12tug2PSa2SqhxJfcJ2jWzwhWmasbf+U1Qn17d0llgAPty5tXDe KQTfPzjY2ji8LF61WWHNHYQm9wFAi6Tia298Un0jzhibGqHgNPG/5XhyWSap0RE8trrC ba84ot6J4QpxIuWVX3+F1Iccp3qW6+FVu7YFsDHh7KetGGo+6uDwZE3+kw3b6m2ugaF/ MaHQ== X-Gm-Message-State: AOAM530j9LzwiX9492ZlzzqUKbh5xLTUBUUj5LiNrLzcnNzjSMfcNi+Q CtLScseHDq4rSq0yOJ3SsqKBmbSi9w4h5m4u X-Google-Smtp-Source: ABdhPJyK0+GVFLWK4Cb/Pe5FtXB8zhlpcallk0v2Mo0SX3hAkxzSsDo9o1MShqHjI6M0cPmaxiGMzg== X-Received: by 2002:a2e:5c8:: with SMTP id 191mr4789046ljf.54.1626083988069; Mon, 12 Jul 2021 02:59:48 -0700 (PDT) Received: from omv-rockpro64.. (host-80-238-115-177.jmdi.pl. [80.238.115.177]) by smtp.gmail.com with ESMTPSA id c25sm150521lja.16.2021.07.12.02.59.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 02:59:47 -0700 (PDT) From: =?UTF-8?q?Tomasz=20Pawe=C5=82=20Gajc?= To: elfutils-devel@sourceware.org Subject: [PATCH] readelf: allow build with LLVM/clang Date: Mon, 12 Jul 2021 11:59:41 +0200 Message-Id: <20210712095941.15620-1-tpgxyz@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2021 09:59:53 -0000 convert last nested function to allow build with LLVM/clang. Original patch comes from https://github.com/OpenMandrivaAssociation/elfutils/blob/master/elfutils-0.185-clang.patch Tested with OpenMandriva Lx cooker and LLVM/clang-12.0.1 Signed-off-by: Tomasz Paweł Gajc --- configure.ac | 2 +- src/readelf.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index b348a717..2b998c9c 100644 --- a/configure.ac +++ b/configure.ac @@ -127,7 +127,7 @@ void baz (int n) ac_cv_c99=yes, ac_cv_c99=no) CFLAGS="$old_CFLAGS"]) AS_IF([test "x$ac_cv_c99" != xyes], - AC_MSG_ERROR([gcc with GNU99 support required])) + AC_MSG_WARN([gcc with GNU99 support required])) AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))], ac_cv_visibility, [dnl diff --git a/src/readelf.c b/src/readelf.c index 161d7e65..3d6f263e 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -8763,13 +8763,17 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, /* Apply the "operation advance" from a special opcode or DW_LNS_advance_pc (as per DWARF4 6.2.5.1). */ unsigned int op_addr_advance; - inline void advance_pc (unsigned int op_advance) - { - op_addr_advance = minimum_instr_len * ((op_index + op_advance) - / max_ops_per_instr); - address += op_addr_advance; - op_index = (op_index + op_advance) % max_ops_per_instr; - } + bool show_op_index; + #define advance_pc(op_advance_arg) \ + ( { \ + unsigned int op_advance = op_advance_arg; \ + op_addr_advance = minimum_instr_len * ((op_index + (op_advance)) \ + / max_ops_per_instr); \ + address += (op_advance); \ + show_op_index = (op_index > 0 || \ + (op_index + (op_advance)) % max_ops_per_instr > 0); \ + op_index = (op_index + (op_advance)) % max_ops_per_instr; \ + } ) if (max_ops_per_instr == 0) { -- 2.32.0