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

Side by Side Diff: src/IceELFObjectWriter.cpp

Issue 1900543002: Subzero: Allow per-method controls. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: More cleanup Created 4 years, 8 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
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 /// \file 10 /// \file
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (Var->getIsConstant()) 281 if (Var->getIsConstant())
282 return ELFObjectWriter::ROData; 282 return ELFObjectWriter::ROData;
283 if (Var->hasNonzeroInitializer()) 283 if (Var->hasNonzeroInitializer())
284 return ELFObjectWriter::Data; 284 return ELFObjectWriter::Data;
285 return ELFObjectWriter::BSS; 285 return ELFObjectWriter::BSS;
286 } 286 }
287 287
288 // Partition the Vars list by SectionType into VarsBySection. If TranslateOnly 288 // Partition the Vars list by SectionType into VarsBySection. If TranslateOnly
289 // is non-empty, then only the TranslateOnly variable is kept for emission. 289 // is non-empty, then only the TranslateOnly variable is kept for emission.
290 void partitionGlobalsBySection(const VariableDeclarationList &Vars, 290 void partitionGlobalsBySection(const VariableDeclarationList &Vars,
291 VariableDeclarationPartition VarsBySection[], 291 VariableDeclarationPartition VarsBySection[]) {
292 const std::string &TranslateOnly) {
293 for (VariableDeclaration *Var : Vars) { 292 for (VariableDeclaration *Var : Vars) {
294 if (GlobalContext::matchSymbolName(Var->getName(), TranslateOnly)) { 293 if (getFlags().matchTranslateOnly(Var->getName(), 0)) {
295 size_t Section = classifyGlobalSection(Var); 294 size_t Section = classifyGlobalSection(Var);
296 assert(Section < ELFObjectWriter::NumSectionTypes); 295 assert(Section < ELFObjectWriter::NumSectionTypes);
297 VarsBySection[Section].push_back(Var); 296 VarsBySection[Section].push_back(Var);
298 } 297 }
299 } 298 }
300 } 299 }
301 300
302 } // end of anonymous namespace 301 } // end of anonymous namespace
303 302
304 void ELFObjectWriter::writeDataSection(const VariableDeclarationList &Vars, 303 void ELFObjectWriter::writeDataSection(const VariableDeclarationList &Vars,
305 FixupKind RelocationKind, 304 FixupKind RelocationKind,
306 const std::string &SectionSuffix, 305 const std::string &SectionSuffix,
307 bool IsPIC) { 306 bool IsPIC) {
308 TimerMarker Timer(TimerStack::TT_writeELF, &Ctx); 307 TimerMarker Timer(TimerStack::TT_writeELF, &Ctx);
309 assert(!SectionNumbersAssigned); 308 assert(!SectionNumbersAssigned);
310 VariableDeclarationPartition VarsBySection[ELFObjectWriter::NumSectionTypes]; 309 VariableDeclarationPartition VarsBySection[ELFObjectWriter::NumSectionTypes];
311 for (auto &SectionList : VarsBySection) 310 for (auto &SectionList : VarsBySection)
312 SectionList.reserve(Vars.size()); 311 SectionList.reserve(Vars.size());
313 partitionGlobalsBySection(Vars, VarsBySection, getFlags().getTranslateOnly()); 312 partitionGlobalsBySection(Vars, VarsBySection);
314 size_t I = 0; 313 size_t I = 0;
315 for (auto &SectionList : VarsBySection) { 314 for (auto &SectionList : VarsBySection) {
316 writeDataOfType(static_cast<SectionType>(I++), SectionList, RelocationKind, 315 writeDataOfType(static_cast<SectionType>(I++), SectionList, RelocationKind,
317 SectionSuffix, IsPIC); 316 SectionSuffix, IsPIC);
318 } 317 }
319 } 318 }
320 319
321 namespace { 320 namespace {
322 std::string MangleSectionName(const char Base[], const std::string &Suffix) { 321 std::string MangleSectionName(const char Base[], const std::string &Suffix) {
323 if (Suffix.empty()) 322 if (Suffix.empty())
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 if (ELF64) { 686 if (ELF64) {
688 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), 687 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(),
689 AllSections.size()); 688 AllSections.size());
690 } else { 689 } else {
691 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), 690 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(),
692 AllSections.size()); 691 AllSections.size());
693 } 692 }
694 } 693 }
695 694
696 } // end of namespace Ice 695 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698