llvm.org GIT mirror llvm / 346801a
Support MIPS64EL relocation type names MIPS64EL relocation entries have up to three relocation operations. Because libObject only exposes a single relocation name, use the concatenation of the individual relocation type names. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179357 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Rieck 7 years ago
1 changed file(s) with 63 addition(s) and 44 deletion(s). Raw diff Collapse all Expand all
688688 protected:
689689 const Elf_Sym *getSymbol(DataRefImpl Symb) const; // FIXME: Should be private?
690690 void validateSymbol(DataRefImpl Symb) const;
691 StringRef getRelocationTypeName(uint32_t Type) const;
691692
692693 public:
693694 error_code getSymbolName(const Elf_Shdr *section,
16061607 }
16071608
16081609 #define LLVM_ELF_SWITCH_RELOC_TYPE_NAME(enum) \
1609 case ELF::enum: res = #enum; break;
1610
1611 template
1612 error_code ELFObjectFile::getRelocationTypeName(
1613 DataRefImpl Rel, SmallVectorImpl &Result) const {
1614 const Elf_Shdr *sec = getSection(Rel.w.b);
1615 uint32_t type;
1616 StringRef res;
1617 switch (sec->sh_type) {
1618 default :
1619 return object_error::parse_failed;
1620 case ELF::SHT_REL : {
1621 type = getRel(Rel)->getType(isMips64EL());
1622 break;
1623 }
1624 case ELF::SHT_RELA : {
1625 type = getRela(Rel)->getType(isMips64EL());
1626 break;
1627 }
1628 }
1610 case ELF::enum: Res = #enum; break;
1611
1612 template
1613 StringRef ELFObjectFile::getRelocationTypeName(uint32_t Type) const {
1614 StringRef Res = "Unknown";
16291615 switch (Header->e_machine) {
16301616 case ELF::EM_X86_64:
1631 switch (type) {
1617 switch (Type) {
16321618 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_NONE);
16331619 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_64);
16341620 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC32);
16611647 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPC32_TLSDESC);
16621648 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSDESC_CALL);
16631649 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSDESC);
1664 default:
1665 res = "Unknown";
1650 default: break;
16661651 }
16671652 break;
16681653 case ELF::EM_386:
1669 switch (type) {
1654 switch (Type) {
16701655 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_NONE);
16711656 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_32);
16721657 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PC32);
17071692 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DESC_CALL);
17081693 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DESC);
17091694 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_IRELATIVE);
1710 default:
1711 res = "Unknown";
1695 default: break;
17121696 }
17131697 break;
17141698 case ELF::EM_MIPS:
1715 switch (type) {
1699 switch (Type) {
17161700 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_NONE);
17171701 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_16);
17181702 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_32);
17641748 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_GLOB_DAT);
17651749 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_COPY);
17661750 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_JUMP_SLOT);
1767 default:
1768 res = "Unknown";
1751 default: break;
17691752 }
17701753 break;
17711754 case ELF::EM_AARCH64:
1772 switch (type) {
1755 switch (Type) {
17731756 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_NONE);
17741757 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_ABS64);
17751758 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_ABS32);
18431826 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSDESC_LD64_LO12_NC);
18441827 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSDESC_ADD_LO12_NC);
18451828 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSDESC_CALL);
1846
1847 default:
1848 res = "Unknown";
1829 default: break;
18491830 }
18501831 break;
18511832 case ELF::EM_ARM:
1852 switch (type) {
1833 switch (Type) {
18531834 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_NONE);
18541835 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PC24);
18551836 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ABS32);
19811962 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ME_TOO);
19821963 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_TLS_DESCSEQ16);
19831964 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_TLS_DESCSEQ32);
1984 default:
1985 res = "Unknown";
1965 default: break;
19861966 }
19871967 break;
19881968 case ELF::EM_HEXAGON:
1989 switch (type) {
1969 switch (Type) {
19901970 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_NONE);
19911971 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B22_PCREL);
19921972 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B15_PCREL);
20732053 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_TPREL_32_6_X);
20742054 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_TPREL_16_X);
20752055 LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_TPREL_11_X);
2076 default:
2077 res = "Unknown";
2056 default: break;
20782057 }
20792058 break;
2080 default:
2081 res = "Unknown";
2082 }
2083 Result.append(res.begin(), res.end());
2084 return object_error::success;
2059 default: break;
2060 }
2061 return Res;
20852062 }
20862063
20872064 #undef LLVM_ELF_SWITCH_RELOC_TYPE_NAME
2065
2066 template
2067 error_code ELFObjectFile::getRelocationTypeName(
2068 DataRefImpl Rel, SmallVectorImpl &Result) const {
2069 const Elf_Shdr *sec = getSection(Rel.w.b);
2070 uint32_t type;
2071 switch (sec->sh_type) {
2072 default :
2073 return object_error::parse_failed;
2074 case ELF::SHT_REL : {
2075 type = getRel(Rel)->getType(isMips64EL());
2076 break;
2077 }
2078 case ELF::SHT_RELA : {
2079 type = getRela(Rel)->getType(isMips64EL());
2080 break;
2081 }
2082 }
2083
2084 if (!isMips64EL()) {
2085 StringRef Name = getRelocationTypeName(type);
2086 Result.append(Name.begin(), Name.end());
2087 } else {
2088 uint8_t Type1 = (type >> 0) & 0xFF;
2089 uint8_t Type2 = (type >> 8) & 0xFF;
2090 uint8_t Type3 = (type >> 16) & 0xFF;
2091
2092 // Concat all three relocation type names.
2093 StringRef Name = getRelocationTypeName(Type1);
2094 Result.append(Name.begin(), Name.end());
2095
2096 Name = getRelocationTypeName(Type2);
2097 Result.append(1, '/');
2098 Result.append(Name.begin(), Name.end());
2099
2100 Name = getRelocationTypeName(Type3);
2101 Result.append(1, '/');
2102 Result.append(Name.begin(), Name.end());
2103 }
2104
2105 return object_error::success;
2106 }
20882107
20892108 template
20902109 error_code ELFObjectFile::getRelocationAdditionalInfo(