From patchwork Mon Jul 12 09:59:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Tomasz_Pawe=C5=82_Gajc?= X-Patchwork-Id: 45836 From: tpgxyz@gmail.com (=?utf-8?q?Tomasz_Pawe=C5=82_Gajc?=) Date: Mon, 12 Jul 2021 11:59:41 +0200 Subject: [PATCH] readelf: allow build with LLVM/clang Message-ID: <20210712095941.15620-1-tpgxyz@gmail.com> 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) {