aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCMachOStreamer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC/MCMachOStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCMachOStreamer.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 88aeeb980738..9f22b9b0a866 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -10,7 +10,6 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Triple.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCCodeEmitter.h"
@@ -19,17 +18,16 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCFragment.h"
-#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCLinkerOptimizationHint.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectStreamer.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionMachO.h"
-#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolMachO.h"
#include "llvm/MC/MCValue.h"
+#include "llvm/MC/SectionKind.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
@@ -37,6 +35,13 @@
#include <cassert>
#include <vector>
+namespace llvm {
+class MCInst;
+class MCStreamer;
+class MCSubtargetInfo;
+class Triple;
+} // namespace llvm
+
using namespace llvm;
namespace {
@@ -126,6 +131,7 @@ public:
void finalizeCGProfileEntry(const MCSymbolRefExpr *&SRE);
void finalizeCGProfile();
+ void createAddrSigSection();
};
} // end anonymous namespace.
@@ -353,6 +359,7 @@ bool MCMachOStreamer::emitSymbolAttribute(MCSymbol *Sym,
case MCSA_Weak:
case MCSA_Local:
case MCSA_LGlobal:
+ case MCSA_Exported:
return false;
case MCSA_Global:
@@ -455,8 +462,8 @@ void MCMachOStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
// section.
}
- PushSection();
- SwitchSection(Section);
+ pushSection();
+ switchSection(Section);
// The symbol may not be present, which only creates the section.
if (Symbol) {
@@ -464,7 +471,7 @@ void MCMachOStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
emitLabel(Symbol);
emitZeros(Size);
}
- PopSection();
+ popSection();
}
// This should always be called with the thread local bss section. Like the
@@ -524,6 +531,7 @@ void MCMachOStreamer::finishImpl() {
finalizeCGProfile();
+ createAddrSigSection();
this->MCObjectStreamer::finishImpl();
}
@@ -574,3 +582,16 @@ MCStreamer *llvm::createMachOStreamer(MCContext &Context,
S->getAssembler().setRelaxAll(true);
return S;
}
+
+// Create the AddrSig section and first data fragment here as its layout needs
+// to be computed immediately after in order for it to be exported correctly.
+void MCMachOStreamer::createAddrSigSection() {
+ MCAssembler &Asm = getAssembler();
+ MCObjectWriter &writer = Asm.getWriter();
+ if (!writer.getEmitAddrsigSection())
+ return;
+ MCSection *AddrSigSection =
+ Asm.getContext().getObjectFileInfo()->getAddrSigSection();
+ Asm.registerSection(*AddrSigSection);
+ new MCDataFragment(AddrSigSection);
+}