llvm-capstone/lld/MachO
Jez Ng 3646ee503d [lld-macho] Refactor segment/section creation, sorting, and merging
Summary:
There were a few issues with the previous setup:

1. The section sorting comparator used a declarative map of section names to
  determine the correct order, but it turns out we need to match on more than
  just names -- in particular, an upcoming diff will sort based on whether the
  S_ZERO_FILL flag is set. This diff changes the sorter to a more imperative but
  flexible form.

2. We were sorting OutputSections stored in a MapVector, which left the
  MapVector in an inconsistent state -- the wrong keys map to the wrong values!
  In practice, we weren't doing key lookups (only container iteration) after the
  sort, so this was fine, but it was still a dubious state of affairs. This diff
  copies the OutputSections to a vector before sorting them.

3. We were adding unneeded OutputSections to OutputSegments and then filtering
  them out later, which meant that we had to remember whether an OutputSegment
  was in a pre- or post-filtered state. This diff only adds the sections to the
  segments if they are needed.

In addition to those major changes, two minor ones worth noting:

1. I renamed all OutputSection variable names to `osec`, to parallel `isec`.
  Previously we were using some inconsistent combination of `osec`, `os`, and
  `section`.

2. I added a check (and a test) for InputSections with names that clashed with
  those of our synthetic OutputSections.

Reviewers: #lld-macho

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81887
2020-06-21 17:13:59 -07:00
..
Arch [lld-macho] Handle GOT relocations of non-dylib symbols 2020-06-17 20:41:28 -07:00
CMakeLists.txt [lld] Fix shared library build by adding the missing dependency. 2020-06-08 16:12:58 -04:00
Config.h [lld-macho] Handle framework search path, alongside library search path 2020-06-17 20:41:28 -07:00
Driver.cpp [lld-macho] Handle framework search path, alongside library search path 2020-06-17 20:41:28 -07:00
Driver.h [lld-macho] Specify the complete set of command-line options for ld64 2020-06-15 12:50:20 -07:00
ExportTrie.cpp [lld-macho] Use export trie instead of symtab when linking against dylibs 2020-05-09 20:56:22 -07:00
ExportTrie.h [lld-macho] Use export trie instead of symtab when linking against dylibs 2020-05-09 20:56:22 -07:00
InputFiles.cpp [lld-macho] Ensure __bss sections we output have file offset of zero 2020-06-17 20:41:28 -07:00
InputFiles.h lld: remove old test support path 2020-06-16 15:57:58 -07:00
InputSection.cpp [lld-macho] Ensure __bss sections we output have file offset of zero 2020-06-17 20:41:28 -07:00
InputSection.h [lld-macho] Ensure __bss sections we output have file offset of zero 2020-06-17 20:41:28 -07:00
MachOStructs.h [lld-macho] Ensure reads from nlist_64 structs are aligned when necessary 2020-06-02 13:19:38 -07:00
MergedOutputSection.cpp [lld-macho] Handle alignment correctly when merging InputSections 2020-06-17 20:41:28 -07:00
MergedOutputSection.h [lld-macho] Refactor segment/section creation, sorting, and merging 2020-06-21 17:13:59 -07:00
Options.td fix a typo to cycle bots 2020-06-18 11:31:47 -04:00
OutputSection.cpp [lld-macho] Refactor segment/section creation, sorting, and merging 2020-06-21 17:13:59 -07:00
OutputSection.h [lld-macho] Refactor segment/section creation, sorting, and merging 2020-06-21 17:13:59 -07:00
OutputSegment.cpp [lld-macho] Refactor segment/section creation, sorting, and merging 2020-06-21 17:13:59 -07:00
OutputSegment.h [lld-macho] Refactor segment/section creation, sorting, and merging 2020-06-21 17:13:59 -07:00
Symbols.cpp [lld-macho] Set __PAGEZERO size to 4GB 2020-06-02 13:19:38 -07:00
Symbols.h [lld-macho] Handle GOT relocations of non-dylib symbols 2020-06-17 20:41:28 -07:00
SymbolTable.cpp [lld] Add archive file support to Mach-O backend 2020-05-14 12:58:35 -07:00
SymbolTable.h [lld] Add archive file support to Mach-O backend 2020-05-14 12:58:35 -07:00
SyntheticSections.cpp [lld-macho] Refactor segment/section creation, sorting, and merging 2020-06-21 17:13:59 -07:00
SyntheticSections.h [lld-macho] Refactor segment/section creation, sorting, and merging 2020-06-21 17:13:59 -07:00
Target.cpp Reland D75382 "[lld] Initial commit for new Mach-O backend" 2020-04-02 12:03:43 -07:00
Target.h [lld-macho] Handle GOT relocations of non-dylib symbols 2020-06-17 20:41:28 -07:00
Writer.cpp [lld-macho] Refactor segment/section creation, sorting, and merging 2020-06-21 17:13:59 -07:00
Writer.h [lld-macho] Extend SyntheticSections to cover all segment load commands 2020-04-27 12:58:12 -07:00