[llvm-objcopy][MachO] Skip sections with zero offset
authorAlexander Shaposhnikov <alexshap@fb.com>
Fri, 6 Nov 2020 21:10:41 +0000 (13:10 -0800)
committerAlexander Shaposhnikov <alexshap@fb.com>
Fri, 6 Nov 2020 21:29:43 +0000 (13:29 -0800)
commitf147f59cd377a6be68e5ca5c343eb11df8e7ee6f
treebfe881a02153fa4d6f1c780e30bd7b613d8c5d26
parent2993850237b089d134cec2776312b61ef9bff757
[llvm-objcopy][MachO] Skip sections with zero offset

Some binaries can contain regular sections with zero offset and zero size.
This diff makes llvm-objcopy's handling of such sections consistent with
cctools's strip (which doesn't modify them),
previously the tool would allocate file space for them.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D90796
llvm/test/tools/llvm-objcopy/MachO/zero-offset-section.test [new file with mode: 0644]
llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
llvm/tools/llvm-objcopy/MachO/MachOReader.cpp
llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp
llvm/tools/llvm-objcopy/MachO/Object.h