From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 4BC83384F012 for ; Wed, 14 Jul 2021 17:40:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4BC83384F012 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (77-167-121-15.hybrid.kpn.net [77.167.121.15]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 6FBE9300066F; Wed, 14 Jul 2021 19:40:14 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id 0DF302E80FE3; Wed, 14 Jul 2021 19:40:10 +0200 (CEST) Date: Wed, 14 Jul 2021 19:40:09 +0200 From: Mark Wielaard To: Tomasz =?utf-8?B?UGF3ZcWC?= Gajc Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH] readelf: allow build with LLVM/clang Message-ID: References: <20210712095941.15620-1-tpgxyz@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210712095941.15620-1-tpgxyz@gmail.com> X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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: Wed, 14 Jul 2021 17:40:24 -0000 Hi Tomasz, On Mon, Jul 12, 2021 at 11:59:41AM +0200, Tomasz Paweł Gajc via Elfutils-devel wrote: > 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 > [...] > --- 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])) I don't think this is correct. If you believe the testcase is (now) wrong because it tests for an unneeded feature please just adjust the test. > 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; \ > + } ) This doesn't compile with gcc: readelf.c: In function ‘print_debug_line_section’: readelf.c:8766:12: error: variable ‘show_op_index’ set but not used [-Werror=unused-but-set-variable] 8766 | bool show_op_index; | ^~~~~~~~~~~~~ cc1: all warnings being treated as errors Removing the unused show_op_index makes two testcases fail: FAIL: run-readelf-line.sh ========================= --- readelf.out 2021-07-14 19:37:00.962372827 +0200 +++ - 2021-07-14 19:37:00.971161054 +0200 @@ -42,13 +42,13 @@ [ 36] set prologue end flag [ 37] special opcode 19: address+0 = 0x100005a4
, line+1 = 6 [ 38] set column to 8 - [ 3a] special opcode 47: address+8 = 0x100005a6 , line+1 = 7 + [ 3a] special opcode 47: address+8 = 0x100005ac , line+1 = 7 [ 3b] set 'is_stmt' to 0 [ 3c] advance line by constant -7 to 0 - [ 3e] special opcode 32: address+4 = 0x100005a7 , line+0 = 0 + [ 3e] special opcode 32: address+4 = 0x100005b0 , line+0 = 0 [ 3f] set column to 3 [ 41] set 'is_stmt' to 1 - [ 42] special opcode 108: address+24 = 0x100005ad , line+6 = 6 - [ 43] special opcode 76: address+16 = 0x100005b1 , line+2 = 8 - [ 44] advance address by 32 to 0x100005b9 + [ 42] special opcode 108: address+24 = 0x100005c8 , line+6 = 6 + [ 43] special opcode 76: address+16 = 0x100005d8 , line+2 = 8 + [ 44] advance address by 32 to 0x100005f8 [ 46] extended opcode 1: end of sequence FAIL run-readelf-line.sh (exit status: 1) FAIL: run-readelf-multi-noline.sh ================================= --- readelf.out 2021-07-14 19:37:10.054186557 +0200 +++ - 2021-07-14 19:37:10.062074795 +0200 @@ -112,6 +112,6 @@ [ 6e] extended opcode 2: set address to +0x724
[ 79] copy [ 7a] set column to 15 - [ 7c] special opcode 32: address+4 = +0x725 , line+0 = 1 - [ 7d] advance address by 4 to +0x726 + [ 7c] special opcode 32: address+4 = +0x728 , line+0 = 1 + [ 7d] advance address by 4 to +0x72c [ 7f] extended opcode 1: end of sequence FAIL run-readelf-multi-noline.sh (exit status: 1) Cheers, Mark