public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] readelf: allow build with LLVM/clang
@ 2021-07-12  9:59 Tomasz Paweł Gajc
  2021-07-14 17:40 ` Mark Wielaard
  0 siblings, 1 reply; 4+ messages in thread
From: Tomasz Paweł Gajc @ 2021-07-12  9:59 UTC (permalink / raw)
  To: elfutils-devel

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-15 12:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12  9:59 [PATCH] readelf: allow build with LLVM/clang Tomasz Paweł Gajc
2021-07-14 17:40 ` Mark Wielaard
2021-07-15  5:46   ` Timm Baeder
2021-07-15 12:10     ` Mark Wielaard

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).