public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "Tomasz Paweł Gajc" <tpgxyz@gmail.com>
To: elfutils-devel@sourceware.org
Subject: [PATCH] readelf: allow build with LLVM/clang
Date: Mon, 12 Jul 2021 11:59:41 +0200	[thread overview]
Message-ID: <20210712095941.15620-1-tpgxyz@gmail.com> (raw)

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 <tpgxyz@gmail.com>
---
 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


             reply	other threads:[~2021-07-12  9:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12  9:59 Tomasz Paweł Gajc [this message]
2021-07-14 17:40 ` Mark Wielaard
2021-07-15  5:46   ` Timm Baeder
2021-07-15 12:10     ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210712095941.15620-1-tpgxyz@gmail.com \
    --to=tpgxyz@gmail.com \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).