Home | History | Annotate | Download | only in MC

Lines Matching refs:ELF

1 //===- lib/MC/ELFObjectWriter.cpp - ELF File Writer -------------------===//
10 // This file implements ELF object file writer information.
33 #include "llvm/Support/ELF.h"
77 if (MCELF::GetType(*SymbolData) == ELF::STT_FILE)
79 if (MCELF::GetType(*RHS.SymbolData) == ELF::STT_FILE)
86 /// The target specific ELF writer instance.
370 // Emit the ELF header.
373 // ELF Header
386 Write8(is64Bit() ? ELF::ELFCLASS64 : ELF::ELFCLASS32); // e_ident[EI_CLASS]
389 Write8(isLittleEndian() ? ELF::ELFDATA2LSB : ELF::ELFDATA2MSB);
391 Write8(ELF::EV_CURRENT); // e_ident[EI_VERSION]
396 WriteZeros(ELF::EI_NIDENT - ELF::EI_PAD);
398 Write16(ELF::ET_REL); // e_type
402 Write32(ELF::EV_CURRENT); // e_version
405 WriteWord(SectionDataSize + (is64Bit() ? sizeof(ELF::Elf64_Ehdr) :
406 sizeof(ELF::Elf32_Ehdr))); // e_shoff = sec hdr table off in bytes
411 // e_ehsize = ELF header size
412 Write16(is64Bit() ? sizeof(ELF::Elf64_Ehdr) : sizeof(ELF::Elf32_Ehdr));
418 Write16(is64Bit() ? sizeof(ELF::Elf64_Shdr) : sizeof(ELF::Elf32_Shdr));
421 if (NumberOfSections >= ELF::SHN_LORESERVE)
422 Write16(ELF::SHN_UNDEF);
427 if (ShstrtabIndex >= ELF::SHN_LORESERVE)
428 Write16(ELF::SHN_XINDEX);
441 if (shndx >= ELF::SHN_LORESERVE && !Reserved)
447 uint16_t Index = (shndx >= ELF::SHN_LORESERVE && !Reserved) ?
448 uint16_t(ELF::SHN_XINDEX) : shndx;
596 if (Section.getType() == ELF::SHT_RELA ||
597 Section.getType() == ELF::SHT_REL ||
598 Section.getType() == ELF::SHT_STRTAB ||
599 Section.getType() == ELF::SHT_SYMTAB ||
600 Section.getType() == ELF::SHT_SYMTAB_SHNDX)
602 WriteSymbolEntry(SymtabF, ShndxF, 0, ELF::STT_SECTION, 0, 0,
603 ELF::STV_DEFAULT, SectionIndexMap.lookup(&Section),
615 if (MCELF::GetBinding(Data) == ELF::STB_LOCAL)
623 if (MCELF::GetBinding(Data) == ELF::STB_LOCAL)
676 if (Section.getFlags() & ELF::SHF_MERGE) {
795 bool IsGlobal = MCELF::GetBinding(Data) == ELF::STB_GLOBAL;
834 if (Section.getType() != ELF::SHT_GROUP)
843 if (Section.getType() == ELF::SHT_GROUP ||
844 Section.getType() == ELF::SHT_REL ||
845 Section.getType() == ELF::SHT_RELA)
865 MCELF::SetBinding(Data, ELF::STB_GLOBAL);
896 if (!Local && MCELF::GetBinding(*it) == ELF::STB_LOCAL) {
898 MCELF::SetBinding(*it, ELF::STB_GLOBAL);
899 MCELF::SetBinding(SD, ELF::STB_GLOBAL);
903 MCELF::SetBinding(*it, ELF::STB_WEAK);
907 MSD.SectionIndex = ELF::SHN_COMMON;
909 MSD.SectionIndex = ELF::SHN_ABS;
914 MSD.SectionIndex = ELF::SHN_UNDEF;
919 if (MSD.SectionIndex >= ELF::SHN_LORESERVE)
932 unsigned Skip = MSD.SectionIndex == ELF::SHN_UNDEF ? 2 : 1;
944 if (MSD.SectionIndex == ELF::SHN_UNDEF)
970 if (NumRegularSections > ELF::SHN_LORESERVE)
993 EntrySize = is64Bit() ? sizeof(ELF::Elf64_Rela) : sizeof(ELF::Elf32_Rela);
995 EntrySize = is64Bit() ? sizeof(ELF::Elf64_Rel) : sizeof(ELF::Elf32_Rel);
999 ELF::SHT_RELA : ELF::SHT_REL, 0,
1065 struct ELF::Elf64_Rela ERE64;
1074 struct ELF::Elf32_Rela ERE32;
1109 unsigned EntrySize = is64Bit() ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32;
1113 Ctx.getELFSection(".shstrtab", ELF::SHT_STRTAB, 0,
1119 Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0,
1129 Ctx.getELFSection(".symtab_shndx", ELF::SHT_SYMTAB_SHNDX, 0,
1136 StrtabSection = Ctx.getELFSection(".strtab", ELF::SHT_STRTAB, 0,
1207 Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS, 0,
1217 if (!(Section.getFlags() & ELF::SHF_GROUP))
1228 String32(*F, ELF::GRP_COMDAT);
1240 if (!(Section.getFlags() & ELF::SHF_GROUP))
1261 case ELF::SHT_DYNAMIC:
1266 case ELF::SHT_REL:
1267 case ELF::SHT_RELA: {
1270 SymtabSection = Asm.getContext().getELFSection(".symtab", ELF::SHT_SYMTAB,
1277 unsigned SecNameLen = (Section.getType() == ELF::SHT_REL) ? 4 : 5;
1281 ELF::SHT_PROGBITS, 0,
1287 case ELF::SHT_SYMTAB:
1288 case ELF::SHT_DYNSYM:
1293 case ELF::SHT_SYMTAB_SHNDX:
1297 case ELF::SHT_PROGBITS:
1298 case ELF::SHT_STRTAB:
1299 case ELF::SHT_NOBITS:
1300 case ELF::SHT_NOTE:
1301 case ELF::SHT_NULL:
1302 case ELF::SHT_ARM_ATTRIBUTES:
1303 case ELF::SHT_INIT_ARRAY:
1304 case ELF::SHT_FINI_ARRAY:
1305 case ELF::SHT_PREINIT_ARRAY:
1306 case ELF::SHT_X86_64_UNWIND:
1310 case ELF::SHT_GROUP:
1393 NumSections >= ELF::SHN_LORESERVE ? NumSections : 0;
1395 ShstrtabIndex >= ELF::SHN_LORESERVE ? ShstrtabIndex : 0;
1402 if (Section.getType() != ELF::SHT_GROUP)
1422 if (Section.getType() == ELF::SHT_GROUP)
1430 if (Section.getType() != ELF::SHT_GROUP &&
1431 Section.getType() != ELF::SHT_REL &&
1432 Section.getType() != ELF::SHT_RELA)
1440 if (Section.getType() == ELF::SHT_REL ||
1441 Section.getType() == ELF::SHT_RELA)
1477 uint64_t HeaderSize = is64Bit() ? sizeof(ELF::Elf64_Ehdr) :
1478 sizeof(ELF::Elf32_Ehdr);
1503 sizeof(ELF::Elf64_Shdr) : sizeof(ELF::Elf32_Shdr);
1519 // Write out the ELF header ...