Lines Matching refs:ELF

88   Write8(is64Bit() ? ELF::ELFCLASS64 : ELF::ELFCLASS32); // e_ident[EI_CLASS]  in WriteHeader()
91 Write8(isLittleEndian() ? ELF::ELFDATA2LSB : ELF::ELFDATA2MSB); in WriteHeader()
93 Write8(ELF::EV_CURRENT); // e_ident[EI_VERSION] in WriteHeader()
96 case Triple::FreeBSD: Write8(ELF::ELFOSABI_FREEBSD); break; in WriteHeader()
97 case Triple::Linux: Write8(ELF::ELFOSABI_LINUX); break; in WriteHeader()
98 default: Write8(ELF::ELFOSABI_NONE); break; in WriteHeader()
102 WriteZeros(ELF::EI_NIDENT - ELF::EI_PAD); in WriteHeader()
104 Write16(ELF::ET_REL); // e_type in WriteHeader()
108 Write32(ELF::EV_CURRENT); // e_version in WriteHeader()
111 WriteWord(SectionDataSize + (is64Bit() ? sizeof(ELF::Elf64_Ehdr) : in WriteHeader()
112 sizeof(ELF::Elf32_Ehdr))); // e_shoff = sec hdr table off in bytes in WriteHeader()
118 Write16(is64Bit() ? sizeof(ELF::Elf64_Ehdr) : sizeof(ELF::Elf32_Ehdr)); in WriteHeader()
124 Write16(is64Bit() ? sizeof(ELF::Elf64_Shdr) : sizeof(ELF::Elf32_Shdr)); in WriteHeader()
127 if (NumberOfSections >= ELF::SHN_LORESERVE) in WriteHeader()
128 Write16(ELF::SHN_UNDEF); in WriteHeader()
133 if (ShstrtabIndex >= ELF::SHN_LORESERVE) in WriteHeader()
134 Write16(ELF::SHN_XINDEX); in WriteHeader()
147 if (shndx >= ELF::SHN_LORESERVE && !Reserved) in WriteSymbolEntry()
153 uint16_t Index = (shndx >= ELF::SHN_LORESERVE && !Reserved) ? in WriteSymbolEntry()
154 uint16_t(ELF::SHN_XINDEX) : shndx; in WriteSymbolEntry()
302 if (Section.getType() == ELF::SHT_RELA || in WriteSymbolTable()
303 Section.getType() == ELF::SHT_REL || in WriteSymbolTable()
304 Section.getType() == ELF::SHT_STRTAB || in WriteSymbolTable()
305 Section.getType() == ELF::SHT_SYMTAB || in WriteSymbolTable()
306 Section.getType() == ELF::SHT_SYMTAB_SHNDX) in WriteSymbolTable()
308 WriteSymbolEntry(SymtabF, ShndxF, 0, ELF::STT_SECTION, 0, 0, in WriteSymbolTable()
309 ELF::STV_DEFAULT, SectionIndexMap.lookup(&Section), false); in WriteSymbolTable()
320 if (MCELF::GetBinding(Data) == ELF::STB_LOCAL) in WriteSymbolTable()
328 if (MCELF::GetBinding(Data) == ELF::STB_LOCAL) in WriteSymbolTable()
381 if (Section.getFlags() & ELF::SHF_MERGE) { in SymbolToReloc()
495 bool IsGlobal = MCELF::GetBinding(Data) == ELF::STB_GLOBAL; in isInSymtab()
534 if (Section.getType() != ELF::SHT_GROUP) in ComputeIndexMap()
543 if (Section.getType() == ELF::SHT_GROUP || in ComputeIndexMap()
544 Section.getType() == ELF::SHT_REL || in ComputeIndexMap()
545 Section.getType() == ELF::SHT_RELA) in ComputeIndexMap()
565 MCELF::SetBinding(Data, ELF::STB_GLOBAL); in ComputeSymbolTable()
596 if (!Local && MCELF::GetBinding(*it) == ELF::STB_LOCAL) { in ComputeSymbolTable()
598 MCELF::SetBinding(*it, ELF::STB_GLOBAL); in ComputeSymbolTable()
599 MCELF::SetBinding(SD, ELF::STB_GLOBAL); in ComputeSymbolTable()
603 MCELF::SetBinding(*it, ELF::STB_WEAK); in ComputeSymbolTable()
607 MSD.SectionIndex = ELF::SHN_COMMON; in ComputeSymbolTable()
609 MSD.SectionIndex = ELF::SHN_ABS; in ComputeSymbolTable()
614 MSD.SectionIndex = ELF::SHN_UNDEF; in ComputeSymbolTable()
619 if (MSD.SectionIndex >= ELF::SHN_LORESERVE) in ComputeSymbolTable()
632 unsigned Skip = MSD.SectionIndex == ELF::SHN_UNDEF ? 2 : 1; in ComputeSymbolTable()
644 if (MSD.SectionIndex == ELF::SHN_UNDEF) in ComputeSymbolTable()
670 if (NumRegularSections > ELF::SHN_LORESERVE) in ComputeSymbolTable()
693 EntrySize = is64Bit() ? sizeof(ELF::Elf64_Rela) : sizeof(ELF::Elf32_Rela); in CreateRelocationSections()
695 EntrySize = is64Bit() ? sizeof(ELF::Elf64_Rel) : sizeof(ELF::Elf32_Rel); in CreateRelocationSections()
699 ELF::SHT_RELA : ELF::SHT_REL, 0, in CreateRelocationSections()
763 struct ELF::Elf64_Rela ERE64; in WriteRelocationsFragment()
772 struct ELF::Elf32_Rela ERE32; in WriteRelocationsFragment()
807 unsigned EntrySize = is64Bit() ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32; in CreateMetadataSections()
811 Ctx.getELFSection(".shstrtab", ELF::SHT_STRTAB, 0, in CreateMetadataSections()
817 Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0, in CreateMetadataSections()
827 Ctx.getELFSection(".symtab_shndx", ELF::SHT_SYMTAB_SHNDX, 0, in CreateMetadataSections()
834 StrtabSection = Ctx.getELFSection(".strtab", ELF::SHT_STRTAB, 0, in CreateMetadataSections()
905 Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS, 0, in CreateIndexedSections()
915 if (!(Section.getFlags() & ELF::SHF_GROUP)) in CreateIndexedSections()
926 String32(*F, ELF::GRP_COMDAT); in CreateIndexedSections()
938 if (!(Section.getFlags() & ELF::SHF_GROUP)) in CreateIndexedSections()
959 case ELF::SHT_DYNAMIC: in WriteSection()
964 case ELF::SHT_REL: in WriteSection()
965 case ELF::SHT_RELA: { in WriteSection()
968 SymtabSection = Asm.getContext().getELFSection(".symtab", ELF::SHT_SYMTAB, in WriteSection()
975 unsigned SecNameLen = (Section.getType() == ELF::SHT_REL) ? 4 : 5; in WriteSection()
979 ELF::SHT_PROGBITS, 0, in WriteSection()
985 case ELF::SHT_SYMTAB: in WriteSection()
986 case ELF::SHT_DYNSYM: in WriteSection()
991 case ELF::SHT_SYMTAB_SHNDX: in WriteSection()
995 case ELF::SHT_PROGBITS: in WriteSection()
996 case ELF::SHT_STRTAB: in WriteSection()
997 case ELF::SHT_NOBITS: in WriteSection()
998 case ELF::SHT_NOTE: in WriteSection()
999 case ELF::SHT_NULL: in WriteSection()
1000 case ELF::SHT_ARM_ATTRIBUTES: in WriteSection()
1001 case ELF::SHT_INIT_ARRAY: in WriteSection()
1002 case ELF::SHT_FINI_ARRAY: in WriteSection()
1003 case ELF::SHT_PREINIT_ARRAY: in WriteSection()
1004 case ELF::SHT_X86_64_UNWIND: in WriteSection()
1008 case ELF::SHT_GROUP: in WriteSection()
1095 NumSections >= ELF::SHN_LORESERVE ? NumSections : 0; in WriteSectionHeader()
1097 ShstrtabIndex >= ELF::SHN_LORESERVE ? ShstrtabIndex : 0; in WriteSectionHeader()
1104 if (Section.getType() != ELF::SHT_GROUP) in WriteSectionHeader()
1124 if (Section.getType() == ELF::SHT_GROUP) in ComputeSectionOrder()
1132 if (Section.getType() != ELF::SHT_GROUP && in ComputeSectionOrder()
1133 Section.getType() != ELF::SHT_REL && in ComputeSectionOrder()
1134 Section.getType() != ELF::SHT_RELA) in ComputeSectionOrder()
1142 if (Section.getType() == ELF::SHT_REL || in ComputeSectionOrder()
1143 Section.getType() == ELF::SHT_RELA) in ComputeSectionOrder()
1179 uint64_t HeaderSize = is64Bit() ? sizeof(ELF::Elf64_Ehdr) : in WriteObject()
1180 sizeof(ELF::Elf32_Ehdr); in WriteObject()
1205 sizeof(ELF::Elf64_Shdr) : sizeof(ELF::Elf32_Shdr); in WriteObject()
1260 case ELF::EM_386: in createELFObjectWriter()
1261 case ELF::EM_X86_64: in createELFObjectWriter()
1263 case ELF::EM_ARM: in createELFObjectWriter()
1265 case ELF::EM_MBLAZE: in createELFObjectWriter()
1267 case ELF::EM_PPC: in createELFObjectWriter()
1268 case ELF::EM_PPC64: in createELFObjectWriter()
1270 case ELF::EM_MIPS: in createELFObjectWriter()
1291 Write32(ELF::EF_ARM_EABIMASK & DefaultEABIVersion); in WriteEFlags()
1342 case ELF::R_ARM_ABS32: in ExplicitRelSym()
1368 case ELF::R_ARM_ABS32: EmitThisSym = false; break; in ExplicitRelSym()
1413 Type = ELF::R_ARM_REL32; in GetRelocTypeInner()
1419 Type = ELF::R_ARM_TLS_IE32; in GetRelocTypeInner()
1426 Type = ELF::R_ARM_PLT32; in GetRelocTypeInner()
1429 Type = ELF::R_ARM_CALL; in GetRelocTypeInner()
1434 Type = ELF::R_ARM_JUMP24; in GetRelocTypeInner()
1438 Type = ELF::R_ARM_MOVT_PREL; in GetRelocTypeInner()
1442 Type = ELF::R_ARM_MOVW_PREL_NC; in GetRelocTypeInner()
1446 Type = ELF::R_ARM_THM_MOVT_PREL; in GetRelocTypeInner()
1450 Type = ELF::R_ARM_THM_MOVW_PREL_NC; in GetRelocTypeInner()
1456 Type = ELF::R_ARM_THM_CALL; in GetRelocTypeInner()
1459 Type = ELF::R_ARM_NONE; in GetRelocTypeInner()
1471 Type = ELF::R_ARM_GOT_BREL; in GetRelocTypeInner()
1474 Type = ELF::R_ARM_TLS_GD32; in GetRelocTypeInner()
1477 Type = ELF::R_ARM_TLS_LE32; in GetRelocTypeInner()
1480 Type = ELF::R_ARM_TLS_IE32; in GetRelocTypeInner()
1483 Type = ELF::R_ARM_ABS32; in GetRelocTypeInner()
1486 Type = ELF::R_ARM_GOTOFF32; in GetRelocTypeInner()
1500 Type = ELF::R_ARM_CALL; in GetRelocTypeInner()
1503 Type = ELF::R_ARM_JUMP24; in GetRelocTypeInner()
1506 Type = ELF::R_ARM_MOVT_ABS; in GetRelocTypeInner()
1509 Type = ELF::R_ARM_MOVW_ABS_NC; in GetRelocTypeInner()
1512 Type = ELF::R_ARM_THM_MOVT_ABS; in GetRelocTypeInner()
1515 Type = ELF::R_ARM_THM_MOVW_ABS_NC; in GetRelocTypeInner()
1546 Type = ELF::R_PPC_REL24; in GetRelocType()
1549 Type = ELF::R_PPC_REL32; in GetRelocType()
1556 Type = ELF::R_PPC_ADDR24; in GetRelocType()
1559 Type = ELF::R_PPC_ADDR14_BRTAKEN; // XXX: or BRNTAKEN?_ in GetRelocType()
1562 Type = ELF::R_PPC_ADDR16_HA; in GetRelocType()
1565 Type = ELF::R_PPC_ADDR16_LO; in GetRelocType()
1568 Type = ELF::R_PPC_ADDR14; in GetRelocType()
1571 Type = ELF::R_PPC_ADDR32; in GetRelocType()
1574 Type = ELF::R_PPC_ADDR16; in GetRelocType()
1616 Type = ELF::R_MICROBLAZE_64_PCREL; in GetRelocType()
1619 Type = ELF::R_MICROBLAZE_32_PCREL; in GetRelocType()
1627 ? ELF::R_MICROBLAZE_32 in GetRelocType()
1628 : ELF::R_MICROBLAZE_64); in GetRelocType()
1631 Type = ELF::R_MICROBLAZE_32; in GetRelocType()
1665 case FK_Data_8: Type = ELF::R_X86_64_PC64; break; in GetRelocType()
1666 case FK_Data_4: Type = ELF::R_X86_64_PC32; break; in GetRelocType()
1667 case FK_Data_2: Type = ELF::R_X86_64_PC16; break; in GetRelocType()
1671 Type = ELF::R_X86_64_PC64; in GetRelocType()
1681 Type = ELF::R_X86_64_PC32; in GetRelocType()
1684 Type = ELF::R_X86_64_PLT32; in GetRelocType()
1687 Type = ELF::R_X86_64_GOTPCREL; in GetRelocType()
1690 Type = ELF::R_X86_64_GOTTPOFF; in GetRelocType()
1693 Type = ELF::R_X86_64_TLSGD; in GetRelocType()
1696 Type = ELF::R_X86_64_TLSLD; in GetRelocType()
1702 Type = ELF::R_X86_64_PC16; in GetRelocType()
1706 Type = ELF::R_X86_64_PC8; in GetRelocType()
1712 case FK_Data_8: Type = ELF::R_X86_64_64; break; in GetRelocType()
1718 Type = ELF::R_X86_64_32S; in GetRelocType()
1721 Type = ELF::R_X86_64_GOT32; in GetRelocType()
1724 Type = ELF::R_X86_64_GOTPCREL; in GetRelocType()
1727 Type = ELF::R_X86_64_TPOFF32; in GetRelocType()
1730 Type = ELF::R_X86_64_DTPOFF32; in GetRelocType()
1735 Type = ELF::R_X86_64_32; in GetRelocType()
1737 case FK_Data_2: Type = ELF::R_X86_64_16; break; in GetRelocType()
1739 case FK_Data_1: Type = ELF::R_X86_64_8; break; in GetRelocType()
1748 Type = ELF::R_386_PC32; in GetRelocType()
1751 Type = ELF::R_386_PLT32; in GetRelocType()
1759 Type = ELF::R_386_GOTPC; in GetRelocType()
1771 Type = ELF::R_386_32; in GetRelocType()
1774 Type = ELF::R_386_GOT32; in GetRelocType()
1777 Type = ELF::R_386_GOTOFF; in GetRelocType()
1780 Type = ELF::R_386_TLS_GD; in GetRelocType()
1783 Type = ELF::R_386_TLS_LE_32; in GetRelocType()
1786 Type = ELF::R_386_TLS_IE; in GetRelocType()
1789 Type = ELF::R_386_TLS_LE; in GetRelocType()
1792 Type = ELF::R_386_TLS_GOTIE; in GetRelocType()
1795 Type = ELF::R_386_TLS_LDM; in GetRelocType()
1798 Type = ELF::R_386_TLS_LDO_32; in GetRelocType()
1801 Type = ELF::R_386_TLS_IE_32; in GetRelocType()
1805 case FK_Data_2: Type = ELF::R_386_16; break; in GetRelocType()
1807 case FK_Data_1: Type = ELF::R_386_8; break; in GetRelocType()