Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: src/IceFixups.cpp

Issue 1506653002: Subzero: Add Non-SFI support for x86-32. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceFixups.h ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceFixups.cpp - Implementation of Assembler Fixups -----===// 1 //===- subzero/src/IceFixups.cpp - Implementation of Assembler Fixups -----===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 11 matching lines...) Expand all
22 const Constant *AssemblerFixup::NullSymbol = nullptr; 22 const Constant *AssemblerFixup::NullSymbol = nullptr;
23 23
24 RelocOffsetT AssemblerFixup::offset() const { 24 RelocOffsetT AssemblerFixup::offset() const {
25 if (isNullSymbol()) 25 if (isNullSymbol())
26 return 0; 26 return 0;
27 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(value_)) 27 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(value_))
28 return CR->getOffset(); 28 return CR->getOffset();
29 return 0; 29 return 0;
30 } 30 }
31 31
32 IceString AssemblerFixup::symbol(const GlobalContext *Ctx) const { 32 IceString AssemblerFixup::symbol(const GlobalContext *Ctx,
33 const Assembler *Asm) const {
33 std::string Buffer; 34 std::string Buffer;
34 llvm::raw_string_ostream Str(Buffer); 35 llvm::raw_string_ostream Str(Buffer);
35 const Constant *C = value_; 36 const Constant *C = value_;
36 assert(!isNullSymbol()); 37 assert(!isNullSymbol());
37 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(C)) { 38 if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(C)) {
38 if (CR->getSuppressMangling()) 39 if (CR->getSuppressMangling())
39 Str << CR->getName(); 40 Str << CR->getName();
40 else 41 else
41 Str << Ctx->mangleName(CR->getName()); 42 Str << Ctx->mangleName(CR->getName());
43 if (Asm && !Asm->fixupIsPCRel(kind()) && Ctx->getFlags().getUseNonsfi()) {
44 Str << "@GOTOFF";
45 }
42 } else { 46 } else {
43 // NOTE: currently only float/doubles are put into constant pools. In the 47 // NOTE: currently only float/doubles are put into constant pools. In the
44 // future we may put integers as well. 48 // future we may put integers as well.
45 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C)); 49 assert(llvm::isa<ConstantFloat>(C) || llvm::isa<ConstantDouble>(C));
46 C->emitPoolLabel(Str, Ctx); 50 C->emitPoolLabel(Str, Ctx);
47 } 51 }
48 return Str.str(); 52 return Str.str();
49 } 53 }
50 54
51 size_t AssemblerFixup::emit(GlobalContext *Ctx, const Assembler &Asm) const { 55 size_t AssemblerFixup::emit(GlobalContext *Ctx, const Assembler &Asm) const {
52 static constexpr const size_t FixupSize = 4; 56 static constexpr const size_t FixupSize = 4;
53 if (!BuildDefs::dump()) 57 if (!BuildDefs::dump())
54 return FixupSize; 58 return FixupSize;
55 Ostream &Str = Ctx->getStrEmit(); 59 Ostream &Str = Ctx->getStrEmit();
56 Str << "\t.long "; 60 Str << "\t.long ";
57 if (isNullSymbol()) 61 if (isNullSymbol())
58 Str << "__Sz_AbsoluteZero"; 62 Str << "__Sz_AbsoluteZero";
59 else 63 else
60 Str << symbol(Ctx); 64 Str << symbol(Ctx, &Asm);
61 RelocOffsetT Offset = Asm.load<RelocOffsetT>(position()); 65 RelocOffsetT Offset = Asm.load<RelocOffsetT>(position());
62 if (Offset) 66 if (Offset)
63 Str << " + " << Offset; 67 Str << " + " << Offset;
64 // For PCRel fixups, we write the pc-offset from a symbol into the Buffer 68 // For PCRel fixups, we write the pc-offset from a symbol into the Buffer
65 // (e.g., -4), but we don't represent that in the fixup's offset. Otherwise 69 // (e.g., -4), but we don't represent that in the fixup's offset. Otherwise
66 // the fixup holds the true offset, and so does the Buffer. Just load the 70 // the fixup holds the true offset, and so does the Buffer. Just load the
67 // offset from the buffer. 71 // offset from the buffer.
68 if (Asm.fixupIsPCRel(kind())) 72 if (Asm.fixupIsPCRel(kind()))
69 Str << " - ."; 73 Str << " - .";
70 Str << "\n"; 74 Str << "\n";
71 return FixupSize; 75 return FixupSize;
72 } 76 }
73 77
74 size_t AssemblerTextFixup::emit(GlobalContext *Ctx, const Assembler &) const { 78 size_t AssemblerTextFixup::emit(GlobalContext *Ctx, const Assembler &) const {
75 Ctx->getStrEmit() << Message << "\n"; 79 Ctx->getStrEmit() << Message << "\n";
76 return NumBytes; 80 return NumBytes;
77 } 81 }
78 82
79 } // end of namespace Ice 83 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceFixups.h ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698