]> git.ipfire.org Git - thirdparty/elfutils.git/commit
unstrip: Don't try to use unstripped .symtab with stripped .strtab
authorKevin Cernekee <cernekee@chromium.org>
Sun, 23 Oct 2016 17:25:55 +0000 (10:25 -0700)
committerMark Wielaard <mjw@redhat.com>
Mon, 24 Oct 2016 10:48:12 +0000 (12:48 +0200)
commit502380c7acbb12055941fac248df77132caa7194
tree0b1d11108c56054014eb00aa6da3aadeb23fbc6c
parenta24d52ac205b4983c80657b5aa2a7d90d7032837
unstrip: Don't try to use unstripped .symtab with stripped .strtab

Prematurely matching up the stripped and unstripped .strtab sections
in the "Match each debuginfo" loop can lead to a case where sec->outscn
gets populated for the stripped .strtab, which we normally want to
ignore.  This causes the .strtab override in the "Make sure each main
file section" loop to be skipped, so the code winds up using indices
from the unstripped .symtab to look up strings in the stripped .strtab.
This returns incorrect strings for a little while, and then fails
catastrophically when it tries to read past the end of the (smaller)
stripped file's .strtab section:

    eu-unstrip: invalid string offset in symbol [1589]

Fix this by adding logic to the "Match each debuginfo" loop to
treat the unstripped .strtab, .shstrtab, and .symtab sections
essentially the same way.

The new logic will break if the .strtab section shows up earlier than
the .symtab section.  We will assume this never happens in practice.

Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
src/ChangeLog
src/unstrip.c