aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2009-09-30 00:23:42 +0000
committerBob Wilson <bob.wilson@apple.com>2009-09-30 00:23:42 +0000
commit0fb34683b9e33238288d2af1e090582464df8387 (patch)
treeb25c0b9beb4df970ff31ff9ec11845e0fd8d0d32 /lib
parentfdc826f6e834a2da80965a34f2ffb5d869fd8c64 (diff)
For Darwin, emit all the text section directives together before the dwarf
section directives. This causes the assembler to put the text sections at the beginning of the object file, which helps work around a limitation of the Darwin ARM relocations. Radar 7255355. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83127 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
index df349e33b4..6fc47ef779 100644
--- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
@@ -1046,6 +1046,25 @@ void ARMAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
bool ARMAsmPrinter::doInitialization(Module &M) {
+ if (Subtarget->isTargetDarwin()) {
+ Reloc::Model RelocM = TM.getRelocationModel();
+ if (RelocM == Reloc::PIC_ || RelocM == Reloc::DynamicNoPIC) {
+ // Declare all the text sections up front (before the DWARF sections
+ // emitted by AsmPrinter::doInitialization) so the assembler will keep
+ // them together at the beginning of the object file. This helps
+ // avoid out-of-range branches that are due a fundamental limitation of
+ // the way symbol offsets are encoded with the current Darwin ARM
+ // relocations.
+ O << "\t.section __TEXT,__text,regular\n"
+ << "\t.section __TEXT,__textcoal_nt,coalesced\n"
+ << "\t.section __TEXT,__const_coal,coalesced\n";
+ if (RelocM == Reloc::DynamicNoPIC)
+ O << "\t.section __TEXT,__symbol_stub4,symbol_stubs,none,12\n";
+ else
+ O << "\t.section __TEXT,__picsymbolstub4,symbol_stubs,none,16\n";
+ }
+ }
+
bool Result = AsmPrinter::doInitialization(M);
DW = getAnalysisIfAvailable<DwarfWriter>();