diff options
author | Matt Davis <nullptr@fb.com> | 2019-09-26 17:03:20 +0000 |
---|---|---|
committer | Matt Davis <nullptr@fb.com> | 2019-09-26 17:03:20 +0000 |
commit | 1683917d99e0e7c1b922e961b5cd0f20fd55d00f (patch) | |
tree | 4a9f0764dbdecc77657032b62db542c3602222bf /test | |
parent | 51997f03061bda3c31727fe3feaaf79720580f42 (diff) |
[lld][mach-o] Avoid segfaulting when handling an empty section list.
Summary:
The following patch avoids segfaulting if the section list is empty when writing a mach-o MH_OBJECT. I ran into this case from a more complicated example trying to dead_strip while using '-r' in lld.
I'm not sure if having empty sections is a legal mach-o, but it does seem that other llvm-binutils tools can ingest such a boring object with out issue. Would it be better to emit an error, emit a warning, or do nothing? It seems that adding a warning diagnostic might be helpful to users, as I did not expect to have a section-less object when the linker was done.
Reviewers: kledzik, ruiu
Subscribers: llvm-commits, jrm
Tags: #lld, #llvm
Differential Revision: https://reviews.llvm.org/D67735
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@372995 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/mach-o/empty-sections.yaml | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/mach-o/empty-sections.yaml b/test/mach-o/empty-sections.yaml new file mode 100644 index 000000000..ca6b150b1 --- /dev/null +++ b/test/mach-o/empty-sections.yaml @@ -0,0 +1,9 @@ +# RUN: ld64.lld -arch x86_64 -r %s -o %t +# +# Test that writing empty mach-o sections does not segfault the linker. +# + +--- !mach-o +arch: x86_64 +file-type: MH_OBJECT +... |