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

Side by Side Diff: src/IceELFObjectWriter.cpp

Issue 905463003: Adds accessor methods to class ClFlags. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits in patchset 2. Created 5 years, 10 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/IceConverter.cpp ('k') | src/IceGlobalContext.h » ('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/IceELFObjectWriter.cpp - ELF object file writer --------===// 1 //===- subzero/src/IceELFObjectWriter.cpp - ELF object file writer --------===//
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 // This file defines the writer for ELF relocatable object files. 10 // This file defines the writer for ELF relocatable object files.
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 289 }
290 290
291 } // end of anonymous namespace 291 } // end of anonymous namespace
292 292
293 void ELFObjectWriter::writeDataSection(const VariableDeclarationList &Vars, 293 void ELFObjectWriter::writeDataSection(const VariableDeclarationList &Vars,
294 FixupKind RelocationKind) { 294 FixupKind RelocationKind) {
295 assert(!SectionNumbersAssigned); 295 assert(!SectionNumbersAssigned);
296 VariableDeclarationList VarsBySection[ELFObjectWriter::NumSectionTypes]; 296 VariableDeclarationList VarsBySection[ELFObjectWriter::NumSectionTypes];
297 for (auto &SectionList : VarsBySection) 297 for (auto &SectionList : VarsBySection)
298 SectionList.reserve(Vars.size()); 298 SectionList.reserve(Vars.size());
299 partitionGlobalsBySection(Vars, VarsBySection, Ctx.getFlags().TranslateOnly); 299 partitionGlobalsBySection(Vars, VarsBySection,
300 Ctx.getFlags().getTranslateOnly());
300 bool IsELF64 = isELF64(Ctx.getTargetArch()); 301 bool IsELF64 = isELF64(Ctx.getTargetArch());
301 size_t I = 0; 302 size_t I = 0;
302 for (auto &SectionList : VarsBySection) { 303 for (auto &SectionList : VarsBySection) {
303 writeDataOfType(static_cast<SectionType>(I++), SectionList, RelocationKind, 304 writeDataOfType(static_cast<SectionType>(I++), SectionList, RelocationKind,
304 IsELF64); 305 IsELF64);
305 } 306 }
306 } 307 }
307 308
308 void ELFObjectWriter::writeDataOfType(SectionType ST, 309 void ELFObjectWriter::writeDataOfType(SectionType ST,
309 const VariableDeclarationList &Vars, 310 const VariableDeclarationList &Vars,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 365
365 const uint8_t SymbolType = STT_OBJECT; 366 const uint8_t SymbolType = STT_OBJECT;
366 for (VariableDeclaration *Var : Vars) { 367 for (VariableDeclaration *Var : Vars) {
367 // If the variable declaration does not have an initializer, its symtab 368 // If the variable declaration does not have an initializer, its symtab
368 // entry will be created separately. 369 // entry will be created separately.
369 if (!Var->hasInitializer()) 370 if (!Var->hasInitializer())
370 continue; 371 continue;
371 Elf64_Xword Align = Var->getAlignment(); 372 Elf64_Xword Align = Var->getAlignment();
372 Section->padToAlignment(Str, Align); 373 Section->padToAlignment(Str, Align);
373 SizeT SymbolSize = Var->getNumBytes(); 374 SizeT SymbolSize = Var->getNumBytes();
374 bool IsExternal = Var->isExternal() || Ctx.getFlags().DisableInternal; 375 bool IsExternal = Var->isExternal() || Ctx.getFlags().getDisableInternal();
375 const uint8_t SymbolBinding = IsExternal ? STB_GLOBAL : STB_LOCAL; 376 const uint8_t SymbolBinding = IsExternal ? STB_GLOBAL : STB_LOCAL;
376 IceString MangledName = Var->mangleName(&Ctx); 377 IceString MangledName = Var->mangleName(&Ctx);
377 SymTab->createDefinedSym(MangledName, SymbolType, SymbolBinding, Section, 378 SymTab->createDefinedSym(MangledName, SymbolType, SymbolBinding, Section,
378 Section->getCurrentSize(), SymbolSize); 379 Section->getCurrentSize(), SymbolSize);
379 StrTab->add(MangledName); 380 StrTab->add(MangledName);
380 if (!Var->hasNonzeroInitializer()) { 381 if (!Var->hasNonzeroInitializer()) {
381 assert(ST == BSS || ST == ROData); 382 assert(ST == BSS || ST == ROData);
382 if (ST == ROData) 383 if (ST == ROData)
383 Section->appendZeros(Str, SymbolSize); 384 Section->appendZeros(Str, SymbolSize);
384 else 385 else
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 if (IsELF64) { 609 if (IsELF64) {
609 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), 610 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(),
610 AllSections.size()); 611 AllSections.size());
611 } else { 612 } else {
612 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), 613 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(),
613 AllSections.size()); 614 AllSections.size());
614 } 615 }
615 } 616 }
616 617
617 } // end of namespace Ice 618 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698