| OLD | NEW |
| 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 break; | 363 break; |
| 364 } | 364 } |
| 365 | 365 |
| 366 const uint8_t SymbolType = STT_OBJECT; | 366 const uint8_t SymbolType = STT_OBJECT; |
| 367 for (VariableDeclaration *Var : Vars) { | 367 for (VariableDeclaration *Var : Vars) { |
| 368 // If the variable declaration does not have an initializer, its symtab | 368 // If the variable declaration does not have an initializer, its symtab |
| 369 // entry will be created separately. | 369 // entry will be created separately. |
| 370 if (!Var->hasInitializer()) | 370 if (!Var->hasInitializer()) |
| 371 continue; | 371 continue; |
| 372 Elf64_Xword Align = Var->getAlignment(); | 372 Elf64_Xword Align = Var->getAlignment(); |
| 373 const Elf64_Xword MinAlign = 1; |
| 374 Align = std::max(Align, MinAlign); |
| 373 Section->padToAlignment(Str, Align); | 375 Section->padToAlignment(Str, Align); |
| 374 SizeT SymbolSize = Var->getNumBytes(); | 376 SizeT SymbolSize = Var->getNumBytes(); |
| 375 bool IsExternal = Var->isExternal() || Ctx.getFlags().getDisableInternal(); | 377 bool IsExternal = Var->isExternal() || Ctx.getFlags().getDisableInternal(); |
| 376 const uint8_t SymbolBinding = IsExternal ? STB_GLOBAL : STB_LOCAL; | 378 const uint8_t SymbolBinding = IsExternal ? STB_GLOBAL : STB_LOCAL; |
| 377 IceString MangledName = Var->mangleName(&Ctx); | 379 IceString MangledName = Var->mangleName(&Ctx); |
| 378 SymTab->createDefinedSym(MangledName, SymbolType, SymbolBinding, Section, | 380 SymTab->createDefinedSym(MangledName, SymbolType, SymbolBinding, Section, |
| 379 Section->getCurrentSize(), SymbolSize); | 381 Section->getCurrentSize(), SymbolSize); |
| 380 StrTab->add(MangledName); | 382 StrTab->add(MangledName); |
| 381 if (!Var->hasNonzeroInitializer()) { | 383 if (!Var->hasNonzeroInitializer()) { |
| 382 assert(ST == BSS || ST == ROData); | 384 assert(ST == BSS || ST == ROData); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 if (IsELF64) { | 611 if (IsELF64) { |
| 610 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), | 612 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), |
| 611 AllSections.size()); | 613 AllSections.size()); |
| 612 } else { | 614 } else { |
| 613 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), | 615 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), |
| 614 AllSections.size()); | 616 AllSections.size()); |
| 615 } | 617 } |
| 616 } | 618 } |
| 617 | 619 |
| 618 } // end of namespace Ice | 620 } // end of namespace Ice |
| OLD | NEW |