llvm-project/llvm/test/tools/llvm-objcopy
Fangrui Song 20de182246 [llvm-objcopy] --only-keep-debug: place zero-size segment according to its parent segment
Alternative to D74755. sectionWithinSegment() treats an empty section as having
a size of 1. Due to the rule, an empty .tdata will not be attributed to an
empty PT_TLS. (The empty p_align=64 PT_TLS is for Android Bionic's TCB
compatibility (ELF-TLS). See https://reviews.llvm.org/D62055#1507426)

Currently --only-keep-debug will not layout a segment with no section
(layoutSegmentsForOnlyKeepDebug()), thus p_offset of PT_TLS can go past the end
of the file. The strange p_offset can trigger validation errors for subsequent
tools, e.g. llvm-objcopy errors when reading back the separate debug file
(readProgramHeaders()).

This patch places such an empty segment according to its parent segment.  This
special cases works for the empty PT_TLS used in Android. For a non-empty
segment, it should have at least one non-empty section and will be handled by
the normal code. Note, p_memsz PT_LOAD is rejected by both Linux and FreeBSD.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D90897
2020-11-11 09:21:10 -08:00
..
COFF [llvm-objcopy] [COFF] Fix a misconception about debug directory payloads 2020-04-29 20:35:36 +03:00
ELF [llvm-objcopy] --only-keep-debug: place zero-size segment according to its parent segment 2020-11-11 09:21:10 -08:00
Inputs
MachO [llvm-objcopy][MachO] Fix adding multiple sections 2020-11-07 18:16:06 -08:00
wasm [llvm-objcopy] Fix pipeline syntax 2020-02-12 11:35:00 +01:00
redefine-symbols.test [test] Use yaml2obj -o %t instead of > %t 2020-01-21 17:20:18 -08:00
tool-help-message.test [llvm-objcopy][MachO] Add llvm-bitcode-strip driver 2020-09-18 18:13:05 -07:00
tool-name.test [llvm-objcopy][MachO] Add llvm-bitcode-strip driver 2020-09-18 18:13:05 -07:00
tool-version.test [llvm-objcopy][MachO] Add llvm-bitcode-strip driver 2020-09-18 18:13:05 -07:00