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

Side by Side Diff: src/IceELFObjectWriter.cpp

Issue 1181013016: Subzero. Fixes memory leaks. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: clang-format: for f in $(git diff --name-only HEAD~7); do if [[ ${f} == *h || ${f} == *cpp ]]; then… Created 5 years, 6 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 // This file defines the writer for ELF relocatable object files. 10 // This file defines the writer for ELF relocatable object files.
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 Section->getCurrentSize(), SymbolSize); 380 Section->getCurrentSize(), SymbolSize);
381 StrTab->add(MangledName); 381 StrTab->add(MangledName);
382 if (!Var->hasNonzeroInitializer()) { 382 if (!Var->hasNonzeroInitializer()) {
383 assert(ST == BSS || ST == ROData); 383 assert(ST == BSS || ST == ROData);
384 if (ST == ROData) 384 if (ST == ROData)
385 Section->appendZeros(Str, SymbolSize); 385 Section->appendZeros(Str, SymbolSize);
386 else 386 else
387 Section->setSize(Section->getCurrentSize() + SymbolSize); 387 Section->setSize(Section->getCurrentSize() + SymbolSize);
388 } else { 388 } else {
389 assert(ST != BSS); 389 assert(ST != BSS);
390 for (VariableDeclaration::Initializer *Init : Var->getInitializers()) { 390 for (const std::unique_ptr<VariableDeclaration::Initializer> &Init :
391 Var->getInitializers()) {
391 switch (Init->getKind()) { 392 switch (Init->getKind()) {
392 case VariableDeclaration::Initializer::DataInitializerKind: { 393 case VariableDeclaration::Initializer::DataInitializerKind: {
393 const auto Data = llvm::cast<VariableDeclaration::DataInitializer>( 394 const auto Data = llvm::cast<VariableDeclaration::DataInitializer>(
394 Init)->getContents(); 395 Init.get())->getContents();
395 Section->appendData(Str, llvm::StringRef(Data.data(), Data.size())); 396 Section->appendData(Str, llvm::StringRef(Data.data(), Data.size()));
396 break; 397 break;
397 } 398 }
398 case VariableDeclaration::Initializer::ZeroInitializerKind: 399 case VariableDeclaration::Initializer::ZeroInitializerKind:
399 Section->appendZeros(Str, Init->getNumBytes()); 400 Section->appendZeros(Str, Init->getNumBytes());
400 break; 401 break;
401 case VariableDeclaration::Initializer::RelocInitializerKind: { 402 case VariableDeclaration::Initializer::RelocInitializerKind: {
402 const auto Reloc = 403 const auto Reloc =
403 llvm::cast<VariableDeclaration::RelocInitializer>(Init); 404 llvm::cast<VariableDeclaration::RelocInitializer>(Init.get());
404 AssemblerFixup NewFixup; 405 AssemblerFixup NewFixup;
405 NewFixup.set_position(Section->getCurrentSize()); 406 NewFixup.set_position(Section->getCurrentSize());
406 NewFixup.set_kind(RelocationKind); 407 NewFixup.set_kind(RelocationKind);
407 const bool SuppressMangling = true; 408 const bool SuppressMangling = true;
408 NewFixup.set_value(Ctx.getConstantSym( 409 NewFixup.set_value(Ctx.getConstantSym(
409 Reloc->getOffset(), Reloc->getDeclaration()->mangleName(&Ctx), 410 Reloc->getOffset(), Reloc->getDeclaration()->mangleName(&Ctx),
410 SuppressMangling)); 411 SuppressMangling));
411 RelSection->addRelocation(NewFixup); 412 RelSection->addRelocation(NewFixup);
412 Section->appendRelocationOffset(Str, RelSection->isRela(), 413 Section->appendRelocationOffset(Str, RelSection->isRela(),
413 Reloc->getOffset()); 414 Reloc->getOffset());
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 if (ELF64) { 615 if (ELF64) {
615 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), 616 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(),
616 AllSections.size()); 617 AllSections.size());
617 } else { 618 } else {
618 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), 619 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(),
619 AllSections.size()); 620 AllSections.size());
620 } 621 }
621 } 622 }
622 623
623 } // end of namespace Ice 624 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698