llvm.org GIT mirror llvm / 8ea9566
ARM: emit hidden stubs into a proper non_lazy_symbol_pointer section. rdar://problem/16660411 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207517 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 6 years ago
2 changed file(s) with 52 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
456456 emitAttributes();
457457 }
458458
459 static void
460 emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel,
461 MachineModuleInfoImpl::StubValueTy &MCSym) {
462 // L_foo$stub:
463 OutStreamer.EmitLabel(StubLabel);
464 // .indirect_symbol _foo
465 OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol);
466
467 if (MCSym.getInt())
468 // External to current translation unit.
469 OutStreamer.EmitIntValue(0, 4/*size*/);
470 else
471 // Internal to current translation unit.
472 //
473 // When we place the LSDA into the TEXT section, the type info
474 // pointers need to be indirect and pc-rel. We accomplish this by
475 // using NLPs; however, sometimes the types are local to the file.
476 // We need to fill in the value for the NLP in those cases.
477 OutStreamer.EmitValue(
478 MCSymbolRefExpr::Create(MCSym.getPointer(), OutStreamer.getContext()),
479 4 /*size*/);
480 }
481
459482
460483 void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
461484 if (Subtarget->isTargetMachO()) {
472495 // Switch with ".non_lazy_symbol_pointer" directive.
473496 OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
474497 EmitAlignment(2);
475 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
476 // L_foo$stub:
477 OutStreamer.EmitLabel(Stubs[i].first);
478 // .indirect_symbol _foo
479 MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second;
480 OutStreamer.EmitSymbolAttribute(MCSym.getPointer(),MCSA_IndirectSymbol);
481
482 if (MCSym.getInt())
483 // External to current translation unit.
484 OutStreamer.EmitIntValue(0, 4/*size*/);
485 else
486 // Internal to current translation unit.
487 //
488 // When we place the LSDA into the TEXT section, the type info
489 // pointers need to be indirect and pc-rel. We accomplish this by
490 // using NLPs; however, sometimes the types are local to the file.
491 // We need to fill in the value for the NLP in those cases.
492 OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(),
493 OutContext),
494 4/*size*/);
495 }
498
499 for (auto &Stub : Stubs)
500 emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second);
496501
497502 Stubs.clear();
498503 OutStreamer.AddBlankLine();
500505
501506 Stubs = MMIMacho.GetHiddenGVStubList();
502507 if (!Stubs.empty()) {
503 OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
508 OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
504509 EmitAlignment(2);
505 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
506 // L_foo$stub:
507 OutStreamer.EmitLabel(Stubs[i].first);
508 // .long _foo
509 OutStreamer.EmitValue(MCSymbolRefExpr::
510 Create(Stubs[i].second.getPointer(),
511 OutContext),
512 4/*size*/);
513 }
510
511 for (auto &Stub : Stubs)
512 emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second);
514513
515514 Stubs.clear();
516515 OutStreamer.AddBlankLine();
0 ; RUN: llc -mtriple=thumbv7s-apple-ios7.0 -o - %s | FileCheck %s
1
2 @var = external global i32
3 @var_hidden = external hidden global i32
4
5 define i32* @get_var() {
6 ret i32* @var
7 }
8
9 define i32* @get_var_hidden() {
10 ret i32* @var_hidden
11 }
12
13 ; CHECK: .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
14
15 ; CHECK: .indirect_symbol _var
16 ; CHECK-NEXT: .long 0
17
18 ; CHECK-NOT: __DATA,__data
19
20 ; CHECK: .indirect_symbol _var_hidden
21 ; CHECK-NEXT: .long 0