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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 void ELFObjectWriter::writeDataInitializer(const IceString &VarName, | 226 void ELFObjectWriter::writeDataInitializer(const IceString &VarName, |
227 const llvm::StringRef Data) { | 227 const llvm::StringRef Data) { |
228 assert(!SectionNumbersAssigned); | 228 assert(!SectionNumbersAssigned); |
229 (void)Data; | 229 (void)Data; |
230 llvm_unreachable("TODO"); | 230 llvm_unreachable("TODO"); |
231 StrTab->add(VarName); | 231 StrTab->add(VarName); |
232 } | 232 } |
233 | 233 |
234 void ELFObjectWriter::writeInitialELFHeader() { | 234 void ELFObjectWriter::writeInitialELFHeader() { |
235 assert(!SectionNumbersAssigned); | 235 assert(!SectionNumbersAssigned); |
236 const size_t DummySHOffset = 0; | 236 const Elf64_Off DummySHOffset = 0; |
237 const SizeT DummySHStrIndex = 0; | 237 const SizeT DummySHStrIndex = 0; |
238 const SizeT DummyNumSections = 0; | 238 const SizeT DummyNumSections = 0; |
239 if (isELF64(Ctx.getTargetArch())) { | 239 if (isELF64(Ctx.getTargetArch())) { |
240 writeELFHeaderInternal<true>(DummySHOffset, DummySHStrIndex, | 240 writeELFHeaderInternal<true>(DummySHOffset, DummySHStrIndex, |
241 DummyNumSections); | 241 DummyNumSections); |
242 } else { | 242 } else { |
243 writeELFHeaderInternal<false>(DummySHOffset, DummySHStrIndex, | 243 writeELFHeaderInternal<false>(DummySHOffset, DummySHStrIndex, |
244 DummyNumSections); | 244 DummyNumSections); |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 template <bool IsELF64> | 248 template <bool IsELF64> |
249 void ELFObjectWriter::writeELFHeaderInternal(size_t SectionHeaderOffset, | 249 void ELFObjectWriter::writeELFHeaderInternal(Elf64_Off SectionHeaderOffset, |
250 SizeT SectHeaderStrIndex, | 250 SizeT SectHeaderStrIndex, |
251 SizeT NumSections) { | 251 SizeT NumSections) { |
252 // Write the e_ident: magic number, class, etc. | 252 // Write the e_ident: magic number, class, etc. |
253 // The e_ident is byte order and ELF class independent. | 253 // The e_ident is byte order and ELF class independent. |
254 Str.writeBytes(llvm::StringRef(ElfMagic, strlen(ElfMagic))); | 254 Str.writeBytes(llvm::StringRef(ElfMagic, strlen(ElfMagic))); |
255 Str.write8(IsELF64 ? ELFCLASS64 : ELFCLASS32); | 255 Str.write8(IsELF64 ? ELFCLASS64 : ELFCLASS32); |
256 Str.write8(ELFDATA2LSB); | 256 Str.write8(ELFDATA2LSB); |
257 Str.write8(EV_CURRENT); | 257 Str.write8(EV_CURRENT); |
258 Str.write8(ELFOSABI_NONE); | 258 Str.write8(ELFOSABI_NONE); |
259 const uint8_t ELF_ABIVersion = 0; | 259 const uint8_t ELF_ABIVersion = 0; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if (IsELF64) { | 338 if (IsELF64) { |
339 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), | 339 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), |
340 AllSections.size()); | 340 AllSections.size()); |
341 } else { | 341 } else { |
342 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), | 342 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), |
343 AllSections.size()); | 343 AllSections.size()); |
344 } | 344 } |
345 } | 345 } |
346 | 346 |
347 } // end of namespace Ice | 347 } // end of namespace Ice |
OLD | NEW |