From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107374 invoked by alias); 5 Jul 2018 14:21:04 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 105092 invoked by uid 48); 5 Jul 2018 14:20:58 -0000 From: "mark at klomp dot org" To: elfutils-devel@sourceware.org Subject: [Bug general/23370] run-next-cfi-self.sh doesn't handle compressed ELF sections Date: Thu, 05 Jul 2018 14:21:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: general X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mark at klomp dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc short_desc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2018-q3/txt/msg00007.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D23370 Mark Wielaard changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mark at klomp dot org Summary|run-next-cfi-self.sh fails |run-next-cfi-self.sh |on armv7l |doesn't handle compressed | |ELF sections --- Comment #1 from Mark Wielaard --- Although relocations in ET_REL files could be an issue, they aren't actually for this test, because the relocations that are there are against the addre= sses inside to .debug_frame section, and we don't care what they are in this test case. [We do really need some easier way to apply simple relocations when dealing with ET_REL files (currently you need to create a Dwfl, which is a bit over= kill in this case).] The real issue in this case is that the toolchain that created this test fi= le (size.o) used ELF debug section compression: [35] .debug_frame PROGBITS 00000000 0057e4 0000c5 0 C 0 = 0=20 4 [ELF ZLIB (1) 000154 4] (Oddly enough it seems it only does this for ET_REL files and the linker ag= ain decompresses again when creating the ET_EXEC/DYN files. Which seems horribly inefficient.) So the real fix is to just uncompress the section in the test: diff --git a/tests/next_cfi.c b/tests/next_cfi.c index b923744..ae324c4 100644 --- a/tests/next_cfi.c +++ b/tests/next_cfi.c @@ -33,7 +33,7 @@ #include void -handle_section (const unsigned char e_ident[], +handle_section (char *name, const unsigned char e_ident[], Elf_Scn *scn, const bool is_eh) { if (is_eh) @@ -41,6 +41,24 @@ handle_section (const unsigned char e_ident[], else printf (".debug_frame\n"); + GElf_Shdr mem; + GElf_Shdr *shdr =3D gelf_getshdr (scn, &mem); + if (shdr =3D=3D NULL) + error (EXIT_FAILURE, 0, "Couldn't get section header: %s", + elf_errmsg (-1)); + if ((shdr->sh_flags & SHF_COMPRESSED) !=3D 0) + { + if (elf_compress (scn, 0, 0) < 0) + error (EXIT_FAILURE, 0, "Couldn't decompress section: %s", + elf_errmsg (-1)); + } + else if (name[0] =3D=3D '.' && name[1] =3D=3D 'z') + { + if (elf_compress_gnu (scn, 0, 0) < 0) + error (EXIT_FAILURE, 0, "Couldn't decompress section: %s", + elf_errmsg (-1)); + } + Elf_Data *data =3D elf_getdata (scn, NULL); if (data =3D=3D NULL || data->d_buf =3D=3D NULL) error (EXIT_FAILURE, 0, "no section data"); @@ -117,9 +135,10 @@ main (int argc, char *argv[]) if (name !=3D NULL && shdr.sh_type =3D=3D SHT_PROGBITS) { if (strcmp (name, ".eh_frame") =3D=3D 0) - handle_section (ident, scn, true); - if (strcmp (name, ".debug_frame") =3D=3D 0) - handle_section (ident, scn, false); + handle_section (name, ident, scn, true); + if (strcmp (name, ".debug_frame") =3D=3D 0 + || strcmp (name, ".zdebug_frame") =3D=3D 0) + handle_section (name, ident, scn, false); } } } --=20 You are receiving this mail because: You are on the CC list for the bug.