[lld-macho] Don't attempt to emit rebase opcodes for debug sections
authorJez Ng <jezng@fb.com>
Wed, 9 Dec 2020 01:47:19 +0000 (17:47 -0800)
committerJez Ng <jezng@fb.com>
Thu, 10 Dec 2020 23:57:51 +0000 (15:57 -0800)
commit863f7a745e6ba5b9aebca82eeba1a2fb1db53e20
treeba0c28e276f41f54891f24e244b41f3b0c2f9b5f
parent95831a56d092c563b03167ece592be301a2a0081
[lld-macho] Don't attempt to emit rebase opcodes for debug sections

This was causing a crash as we were attempting to look up the
nonexistent parent OutputSection of the debug sections. We didn't detect
it earlier because there was no test for PIEs with debug info (PIEs
require us to emit rebases for X86_64_RELOC_UNSIGNED).

This diff filters out the debug sections while loading the ObjFiles. In
addition to fixing the above problem, it also lets us avoid doing
redundant work -- we no longer parse / apply relocations / attempt to
emit dyld opcodes for these sections that we don't emit.

Fixes llvm.org/PR48392.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D92904
lld/MachO/Dwarf.cpp
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/MachO/Writer.cpp
lld/test/MachO/stabs.s