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

Side by Side Diff: src/IceELFObjectWriter.cpp

Issue 1221643012: Subzero: Add -Wshadow to the build. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Change the previous underscore naming style 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 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.
11 // 11 //
12 //===----------------------------------------------------------------------===// 12 //===----------------------------------------------------------------------===//
13 13
14 #include "IceELFObjectWriter.h" 14 #include "IceELFObjectWriter.h"
15 15
16 #include "IceAssembler.h" 16 #include "IceAssembler.h"
17 #include "IceDefs.h" 17 #include "IceDefs.h"
18 #include "IceELFSection.h" 18 #include "IceELFSection.h"
19 #include "IceELFStreamer.h" 19 #include "IceELFStreamer.h"
20 #include "IceGlobalContext.h" 20 #include "IceGlobalContext.h"
21 #include "IceGlobalInits.h" 21 #include "IceGlobalInits.h"
22 #include "IceOperand.h" 22 #include "IceOperand.h"
23
24 #pragma clang diagnostic push
25 #pragma clang diagnostic ignored "-Wunused-parameter"
26 #pragma clang diagnostic ignored "-Wshadow"
23 #include "llvm/Support/MathExtras.h" 27 #include "llvm/Support/MathExtras.h"
28 #pragma clang diagnostic pop
24 29
25 using namespace llvm::ELF; 30 using namespace llvm::ELF;
26 31
27 namespace Ice { 32 namespace Ice {
28 33
29 namespace { 34 namespace {
30 35
31 struct { 36 struct {
32 bool IsELF64; 37 bool IsELF64;
33 uint16_t ELFMachine; 38 uint16_t ELFMachine;
(...skipping 22 matching lines...) Expand all
56 61
57 uint32_t getELFFlags(TargetArch Arch) { 62 uint32_t getELFFlags(TargetArch Arch) {
58 if (Arch < TargetArch_NUM) 63 if (Arch < TargetArch_NUM)
59 return ELFTargetInfo[Arch].ELFFlags; 64 return ELFTargetInfo[Arch].ELFFlags;
60 llvm_unreachable("Invalid target arch for getELFFlags"); 65 llvm_unreachable("Invalid target arch for getELFFlags");
61 return 0; 66 return 0;
62 } 67 }
63 68
64 } // end of anonymous namespace 69 } // end of anonymous namespace
65 70
66 ELFObjectWriter::ELFObjectWriter(GlobalContext &Ctx, ELFStreamer &Out) 71 ELFObjectWriter::ELFObjectWriter(GlobalContext &MyCtx, ELFStreamer &Out)
67 : Ctx(Ctx), Str(Out), ELF64(isELF64(Ctx.getFlags().getTargetArch())) { 72 : Ctx(MyCtx), Str(Out), ELF64(isELF64(Ctx.getFlags().getTargetArch())) {
68 // Create the special bookkeeping sections now. 73 // Create the special bookkeeping sections now.
69 const IceString NullSectionName(""); 74 const IceString NullSectionName("");
70 NullSection = new (Ctx.allocate<ELFSection>()) 75 NullSection = new (Ctx.allocate<ELFSection>())
71 ELFSection(NullSectionName, SHT_NULL, 0, 0, 0); 76 ELFSection(NullSectionName, SHT_NULL, 0, 0, 0);
72 77
73 const IceString ShStrTabName(".shstrtab"); 78 const IceString ShStrTabName(".shstrtab");
74 ShStrTab = new (Ctx.allocate<ELFStringTableSection>()) 79 ShStrTab = new (Ctx.allocate<ELFStringTableSection>())
75 ELFStringTableSection(ShStrTabName, SHT_STRTAB, 0, 1, 0); 80 ELFStringTableSection(ShStrTabName, SHT_STRTAB, 0, 1, 0);
76 ShStrTab->add(ShStrTabName); 81 ShStrTab->add(ShStrTabName);
77 82
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 314
310 // TODO(jvoung): Handle fdata-sections. 315 // TODO(jvoung): Handle fdata-sections.
311 void ELFObjectWriter::writeDataOfType(SectionType ST, 316 void ELFObjectWriter::writeDataOfType(SectionType ST,
312 const VariableDeclarationList &Vars, 317 const VariableDeclarationList &Vars,
313 FixupKind RelocationKind, 318 FixupKind RelocationKind,
314 const IceString &SectionSuffix) { 319 const IceString &SectionSuffix) {
315 if (Vars.empty()) 320 if (Vars.empty())
316 return; 321 return;
317 ELFDataSection *Section; 322 ELFDataSection *Section;
318 ELFRelocationSection *RelSection; 323 ELFRelocationSection *RelSection;
319 IceString SectionName;
320 Elf64_Xword ShAddralign = 1; 324 Elf64_Xword ShAddralign = 1;
321 for (VariableDeclaration *Var : Vars) { 325 for (VariableDeclaration *Var : Vars) {
322 Elf64_Xword Align = Var->getAlignment(); 326 Elf64_Xword Align = Var->getAlignment();
323 ShAddralign = std::max(ShAddralign, Align); 327 ShAddralign = std::max(ShAddralign, Align);
324 } 328 }
325 const Elf64_Xword ShEntsize = 0; // non-uniform data element size. 329 const Elf64_Xword ShEntsize = 0; // non-uniform data element size.
326 // Lift this out, so it can be re-used if we do fdata-sections? 330 // Lift this out, so it can be re-used if we do fdata-sections?
327 switch (ST) { 331 switch (ST) {
328 case ROData: { 332 case ROData: {
329 const IceString SectionName = MangleSectionName(".rodata", SectionSuffix); 333 const IceString SectionName = MangleSectionName(".rodata", SectionSuffix);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 if (ELF64) { 629 if (ELF64) {
626 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), 630 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(),
627 AllSections.size()); 631 AllSections.size());
628 } else { 632 } else {
629 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), 633 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(),
630 AllSections.size()); 634 AllSections.size());
631 } 635 }
632 } 636 }
633 637
634 } // end of namespace Ice 638 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698