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

Unified Diff: src/IceELFObjectWriter.cpp

Issue 1257283004: Iasm and obj lowering for advanced switch lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceELFObjectWriter.h ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceELFObjectWriter.cpp
diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp
index 37b1d58acdf274fc727997e4867a685902417f1f..f32a2b6671bb9b2857cfa77387f7f68c6edbd6e8 100644
--- a/src/IceELFObjectWriter.cpp
+++ b/src/IceELFObjectWriter.cpp
@@ -20,6 +20,7 @@
#include "IceELFStreamer.h"
#include "IceGlobalContext.h"
#include "IceGlobalInits.h"
+#include "IceInst.h"
#include "IceOperand.h"
#include "llvm/Support/MathExtras.h"
@@ -553,6 +554,44 @@ void ELFObjectWriter::writeAllRelocationSections() {
writeRelocationSections(RelRODataSections);
}
+void ELFObjectWriter::writeJumpTable(const JumpTableData &JT,
+ FixupKind RelocationKind) {
+ ELFDataSection *Section;
+ ELFRelocationSection *RelSection;
+ const Elf64_Xword PointerSize = typeWidthInBytes(getPointerType());
+ const Elf64_Xword ShAddralign = PointerSize;
+ const Elf64_Xword ShEntsize = PointerSize;
+ const IceString SectionName =
+ MangleSectionName(".rodata", JT.getFunctionName() + "$jumptable");
+ Section = createSection<ELFDataSection>(SectionName, SHT_PROGBITS, SHF_ALLOC,
+ ShAddralign, ShEntsize);
+ Section->setFileOffset(alignFileOffset(ShAddralign));
+ RODataSections.push_back(Section);
+ RelSection = createRelocationSection(Section);
+ RelRODataSections.push_back(RelSection);
+
+ const uint8_t SymbolType = STT_OBJECT;
+ Section->padToAlignment(Str, PointerSize);
+ bool IsExternal = Ctx.getFlags().getDisableInternal();
+ const uint8_t SymbolBinding = IsExternal ? STB_GLOBAL : STB_LOCAL;
+ IceString JumpTableName =
+ InstJumpTable::makeName(JT.getFunctionName(), JT.getId());
+ SymTab->createDefinedSym(JumpTableName, SymbolType, SymbolBinding, Section,
+ Section->getCurrentSize(), PointerSize);
+ StrTab->add(JumpTableName);
+
+ for (intptr_t TargetOffset : JT.getTargetOffsets()) {
+ AssemblerFixup NewFixup;
+ NewFixup.set_position(Section->getCurrentSize());
+ NewFixup.set_kind(RelocationKind);
+ constexpr bool SuppressMangling = true;
+ NewFixup.set_value(Ctx.getConstantSym(TargetOffset, JT.getFunctionName(),
+ SuppressMangling));
+ RelSection->addRelocation(NewFixup);
+ Section->appendRelocationOffset(Str, RelSection->isRela(), TargetOffset);
+ }
+}
+
void ELFObjectWriter::setUndefinedSyms(const ConstantList &UndefSyms) {
for (const Constant *S : UndefSyms) {
const auto Sym = llvm::cast<ConstantRelocatable>(S);
« no previous file with comments | « src/IceELFObjectWriter.h ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698