|
15 | 15 | #include "llvm/MC/MCAsmInfoDarwin.h"
|
16 | 16 | #include "llvm/MC/MCContext.h"
|
17 | 17 | #include "llvm/MC/MCExpr.h"
|
| 18 | +#include "llvm/MC/MCSectionMachO.h" |
18 | 19 | #include "llvm/MC/MCStreamer.h"
|
19 | 20 | using namespace llvm;
|
20 | 21 |
|
21 |
| -void MCAsmInfoDarwin::anchor() { } |
| 22 | +bool MCAsmInfoDarwin::isSectionAtomizableBySymbols( |
| 23 | + const MCSection &Section) const { |
| 24 | + const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section); |
| 25 | + |
| 26 | + // Sections holding 1 byte strings are atomized based on the data they |
| 27 | + // contain. |
| 28 | + // Sections holding 2 byte strings require symbols in order to be atomized. |
| 29 | + // There is no dedicated section for 4 byte strings. |
| 30 | + if (SMO.getKind().isMergeable1ByteCString()) |
| 31 | + return false; |
| 32 | + |
| 33 | + if (SMO.getSegmentName() == "__TEXT" && |
| 34 | + SMO.getSectionName() == "__objc_classname" && |
| 35 | + SMO.getType() == MachO::S_CSTRING_LITERALS) |
| 36 | + return false; |
| 37 | + |
| 38 | + if (SMO.getSegmentName() == "__TEXT" && |
| 39 | + SMO.getSectionName() == "__objc_methname" && |
| 40 | + SMO.getType() == MachO::S_CSTRING_LITERALS) |
| 41 | + return false; |
| 42 | + |
| 43 | + if (SMO.getSegmentName() == "__TEXT" && |
| 44 | + SMO.getSectionName() == "__objc_methtype" && |
| 45 | + SMO.getType() == MachO::S_CSTRING_LITERALS) |
| 46 | + return false; |
| 47 | + |
| 48 | + if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring") |
| 49 | + return false; |
| 50 | + |
| 51 | + // no_dead_strip sections are not atomized in practice. |
| 52 | + if (SMO.hasAttribute(MachO::S_ATTR_NO_DEAD_STRIP)) |
| 53 | + return false; |
| 54 | + |
| 55 | + switch (SMO.getType()) { |
| 56 | + default: |
| 57 | + return true; |
| 58 | + |
| 59 | + // These sections are atomized at the element boundaries without using |
| 60 | + // symbols. |
| 61 | + case MachO::S_4BYTE_LITERALS: |
| 62 | + case MachO::S_8BYTE_LITERALS: |
| 63 | + case MachO::S_16BYTE_LITERALS: |
| 64 | + case MachO::S_LITERAL_POINTERS: |
| 65 | + case MachO::S_NON_LAZY_SYMBOL_POINTERS: |
| 66 | + case MachO::S_LAZY_SYMBOL_POINTERS: |
| 67 | + case MachO::S_MOD_INIT_FUNC_POINTERS: |
| 68 | + case MachO::S_MOD_TERM_FUNC_POINTERS: |
| 69 | + case MachO::S_INTERPOSING: |
| 70 | + return false; |
| 71 | + } |
| 72 | +} |
22 | 73 |
|
23 | 74 | MCAsmInfoDarwin::MCAsmInfoDarwin() {
|
24 | 75 | // Common settings for all Darwin targets.
|
|
0 commit comments