From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117600 invoked by alias); 15 Jul 2019 10:59:48 -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 117554 invoked by uid 48); 15 Jul 2019 10:59:44 -0000 From: "vries at gcc dot gnu.org" To: elfutils-devel@sourceware.org Subject: [Bug tools/24809] New: eu-unstrip to drop SECTION symbols if section .note.gnu.gold-version present Date: Mon, 15 Jul 2019 10:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: tools X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: 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: 2019-q3/txt/msg00053.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D24809 Bug ID: 24809 Summary: eu-unstrip to drop SECTION symbols if section .note.gnu.gold-version present Product: elfutils Version: unspecified Status: NEW Severity: enhancement Priority: P2 Component: tools Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org CC: elfutils-devel at sourceware dot org Target Milestone: --- Consider a hello world with debug info, linked using gold: ... $ gcc hello.c -g -fuse-ld=3Dgold -o hello ... Now say we strip using objcopy, and then unstrip: ... $ objcopy --only-keep-debug hello hello.debug $ objcopy --strip-debug hello hello.stripped $ eu-unstrip hello.stripped hello.debug -o hello.unstripped ... Interestingly, the unstripped exec is larger than the original: ... $ ls -la -rwxr-xr-x 1 vries users 14104 15 jul 12:34 hello -rwxr-xr-x 1 vries users 11528 15 jul 12:34 hello.debug -rwxr-xr-x 1 vries users 8760 15 jul 12:34 hello.stripped -rwxr-xr-x 1 vries users 14896 15 jul 12:34 hello.unstripped ... Comparing section sizes, we get: ... $ readelf -S -W hello | grep ']'| sed 's/\[ /[/' | egrep -v 'NULL|Name' | a= wk '{print $2, $6}' > SIZE.1 $ readelf -S -W hello.unstripped | grep ']'| sed 's/\[ /[/' | egrep -v 'NULL|Name' | awk '{print $2, $6}' > SIZE.2 $ diff -u SIZE.1 SIZE.2 --- SIZE.1 2019-07-15 12:43:14.495608629 +0200 +++ SIZE.2 2019-07-15 12:43:07.743655249 +0200 @@ -35,6 +35,6 @@ .debug_ranges 000080 .debug_loc 00013e .note.gnu.gold-version 00001c -.symtab 0003c0 -.strtab 000213 +.symtab 000720 +.strtab 0001cf .shstrtab 000190 ... That is, the .strtab section is slightly smaller, but the .symtab section significantly larger. The difference is because of the SECTION symbols, which ld normally adds, b= ut gold doesn't. However, objcopy adds them nevertheless: ... $ readelf -s hello | grep -c SECTION 0 $ readelf -s hello.debug | grep -c SECTION 37 $ readelf -s hello.stripped | grep -c SECTION 30 $ readelf -s hello.unstripped | grep -c SECTION 37 ... It would be good if eu-unstrip could recognize the fact that the exec was produced using gold (there seems to be a section .note.gnu.gold-version) and drop those symbols (and likewise, objcopy should probably do the same). --=20 You are receiving this mail because: You are on the CC list for the bug.