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

Side by Side Diff: src/IceELFSection.h

Issue 889613004: Track undefined sym in the symtab. Remove hack for missing relocs against undef. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: separate asserts Created 5 years, 10 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
« no previous file with comments | « src/IceELFObjectWriter.cpp ('k') | src/IceELFSection.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceELFSection.h - Model of ELF sections ------*- C++ -*-===// 1 //===- subzero/src/IceELFSection.h - Model of ELF sections ------*- C++ -*-===//
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 // Representation of ELF sections. 10 // Representation of ELF sections.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 RelatedSection = Section; 210 RelatedSection = Section;
211 } 211 }
212 212
213 // Track additional relocations which start out relative to offset 0, 213 // Track additional relocations which start out relative to offset 0,
214 // but should be adjusted to be relative to BaseOff. 214 // but should be adjusted to be relative to BaseOff.
215 void addRelocations(RelocOffsetT BaseOff, const FixupRefList &FixupRefs); 215 void addRelocations(RelocOffsetT BaseOff, const FixupRefList &FixupRefs);
216 216
217 // Track a single additional relocation. 217 // Track a single additional relocation.
218 void addRelocation(const AssemblerFixup &Fixup) { Fixups.push_back(Fixup); } 218 void addRelocation(const AssemblerFixup &Fixup) { Fixups.push_back(Fixup); }
219 219
220 size_t getSectionDataSize(const GlobalContext &Ctx, 220 size_t getSectionDataSize() const;
221 const ELFSymbolTableSection *SymTab) const;
222 221
223 template <bool IsELF64> 222 template <bool IsELF64>
224 void writeData(const GlobalContext &Ctx, ELFStreamer &Str, 223 void writeData(const GlobalContext &Ctx, ELFStreamer &Str,
225 const ELFSymbolTableSection *SymTab); 224 const ELFSymbolTableSection *SymTab);
226 225
227 bool isRela() const { return Header.sh_type == SHT_RELA; } 226 bool isRela() const { return Header.sh_type == SHT_RELA; }
228 227
229 private: 228 private:
230 const ELFSection *RelatedSection; 229 const ELFSection *RelatedSection;
231 FixupList Fixups; 230 FixupList Fixups;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 Str.writeLE16(SymInfo.st_shndx); 325 Str.writeLE16(SymInfo.st_shndx);
327 } 326 }
328 } 327 }
329 } 328 }
330 329
331 template <bool IsELF64> 330 template <bool IsELF64>
332 void ELFRelocationSection::writeData(const GlobalContext &Ctx, ELFStreamer &Str, 331 void ELFRelocationSection::writeData(const GlobalContext &Ctx, ELFStreamer &Str,
333 const ELFSymbolTableSection *SymTab) { 332 const ELFSymbolTableSection *SymTab) {
334 for (const AssemblerFixup &Fixup : Fixups) { 333 for (const AssemblerFixup &Fixup : Fixups) {
335 const ELFSym *Symbol = SymTab->findSymbol(Fixup.symbol(&Ctx)); 334 const ELFSym *Symbol = SymTab->findSymbol(Fixup.symbol(&Ctx));
336 // TODO(jvoung): Make sure this always succeeds. 335 if (!Symbol)
337 // We currently don't track data symbols, so they aren't even marked 336 llvm::report_fatal_error("Missing symbol mentioned in reloc");
338 // as undefined symbols. 337
339 if (Symbol) { 338 if (IsELF64) {
340 if (IsELF64) { 339 Elf64_Rela Rela;
341 Elf64_Rela Rela; 340 Rela.r_offset = Fixup.position();
342 Rela.r_offset = Fixup.position(); 341 Rela.setSymbolAndType(Symbol->getNumber(), Fixup.kind());
343 Rela.setSymbolAndType(Symbol->getNumber(), Fixup.kind()); 342 Rela.r_addend = Fixup.offset();
344 Rela.r_addend = Fixup.offset(); 343 Str.writeAddrOrOffset<IsELF64>(Rela.r_offset);
345 Str.writeAddrOrOffset<IsELF64>(Rela.r_offset); 344 Str.writeELFXword<IsELF64>(Rela.r_info);
346 Str.writeELFXword<IsELF64>(Rela.r_info); 345 Str.writeELFXword<IsELF64>(Rela.r_addend);
347 Str.writeELFXword<IsELF64>(Rela.r_addend); 346 } else {
348 } else { 347 Elf32_Rel Rel;
349 Elf32_Rel Rel; 348 Rel.r_offset = Fixup.position();
350 Rel.r_offset = Fixup.position(); 349 Rel.setSymbolAndType(Symbol->getNumber(), Fixup.kind());
351 Rel.setSymbolAndType(Symbol->getNumber(), Fixup.kind()); 350 Str.writeAddrOrOffset<IsELF64>(Rel.r_offset);
352 Str.writeAddrOrOffset<IsELF64>(Rel.r_offset); 351 Str.writeELFWord<IsELF64>(Rel.r_info);
353 Str.writeELFWord<IsELF64>(Rel.r_info);
354 }
355 } 352 }
356 } 353 }
357 } 354 }
358 355
359 } // end of namespace Ice 356 } // end of namespace Ice
360 357
361 #endif // SUBZERO_SRC_ICEELFSECTION_H 358 #endif // SUBZERO_SRC_ICEELFSECTION_H
OLDNEW
« no previous file with comments | « src/IceELFObjectWriter.cpp ('k') | src/IceELFSection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698