strip: Handle mixed allocated/non-allocated sections.
authorMark Wielaard <mark@klomp.org>
Sun, 29 Jul 2018 22:27:52 +0000 (00:27 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 30 Aug 2018 09:43:22 +0000 (11:43 +0200)
commit08ed26703d658b7ae57ab60b865d05c1cde777e3
tree90158fbb901cb15aae7c8d970760735b0f80e2fd
parent6983e59b727458a6c64d9659c85f08218bc4fcda
strip: Handle mixed allocated/non-allocated sections.

Normally in non-ET_REL files all allocated sections come before
all non-allocated sections. eu-strip relies on this when stripping
a file and calculating the file offsets. But recently on Fedora
there are non-allocated .gnu.build.attributes NOTE sections in
the middle of the allocated sections, with a sh_offset field that
is larger then the next section. This confuses eu-strip so much that
it might corrupt the stripped file.

Work around this by calculating the sh_offset fields in two phases
when detecting mixed allocated/non-allocated sections. First handle
the allocated ones, then use the offset after the last allocated
section to calculate the offsets of the non-allocated sections left
in the stripped file.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/ChangeLog
src/strip.c