llvm.org GIT mirror llvm / 63b2f8c
ELF: Fix the section that relocations apply to. Add test to verify. Patch by Danil Malyshev! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141901 91177308-0d34-0410-b5e6-96231b3b80d8 Michael J. Spencer 9 years ago
2 changed file(s) with 7 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
761761 const Elf_Shdr *sec = reinterpret_cast(Sec.p);
762762 typename RelocMap_t::const_iterator ittr = SectionRelocMap.find(sec);
763763 if (sec != 0 && ittr != SectionRelocMap.end()) {
764 RelData.w.a = getSection(ittr->second[0])->sh_link;
764 RelData.w.a = getSection(ittr->second[0])->sh_info;
765765 RelData.w.b = ittr->second[0];
766766 RelData.w.c = 0;
767767 }
779779 // Get the index of the last relocation section for this section.
780780 std::size_t relocsecindex = ittr->second[ittr->second.size() - 1];
781781 const Elf_Shdr *relocsec = getSection(relocsecindex);
782 RelData.w.a = relocsec->sh_link;
782 RelData.w.a = relocsec->sh_info;
783783 RelData.w.b = relocsecindex;
784784 RelData.w.c = relocsec->sh_size / relocsec->sh_entsize;
785785 }
11131113 SymbolTableSections.push_back(sh);
11141114 }
11151115 if (sh->sh_type == ELF::SHT_REL || sh->sh_type == ELF::SHT_RELA) {
1116 SectionRelocMap[getSection(sh->sh_link)].push_back(i);
1116 SectionRelocMap[getSection(sh->sh_info)].push_back(i);
11171117 }
11181118 ++sh;
11191119 }
66 RUN: llvm-objdump -r %p/TestObjectFiles/trivial-object-test.elf-x86-64 \
77 RUN: | FileCheck %s -check-prefix ELF-x86-64
88
9 COFF-i386: .text
910 COFF-i386: IMAGE_REL_I386_DIR32 L_.str
1011 COFF-i386: IMAGE_REL_I386_REL32 _puts
1112 COFF-i386: IMAGE_REL_I386_REL32 _SomeOtherFunction
1213
14 COFF-x86-64: .text
1315 COFF-x86-64: IMAGE_REL_AMD64_REL32 L.str
1416 COFF-x86-64: IMAGE_REL_AMD64_REL32 puts
1517 COFF-x86-64: IMAGE_REL_AMD64_REL32 SomeOtherFunction
1618
19 ELF-i386: .text
1720 ELF-i386: R_386_32
1821 ELF-i386: R_386_PC32
1922 ELF-i386: R_386_PC32
2023
24 ELF-x86-64: .text
2125 ELF-x86-64: R_X86_64_32S .rodata.str1.1
2226 ELF-x86-64: R_X86_64_PC32 puts
2327 ELF-x86-64: R_X86_64_PC32 SomeOtherFunction