llvm.org GIT mirror llvm / 032b305
llvm-readobj: fix printing number of relocations in Android packed format. With '-elf-output-style=GNU -relocations', a header containing the number of entries is printed before all the relocation entries in the section. For Android packed format, we need to perform the unpacking first before we can get the actual number of relocations in the section. Patch by Rahul Chaudhry! Differential Revision: https://reviews.llvm.org/D47800 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334147 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 2 years ago
2 changed file(s) with 11 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1313 # LLVM1-NEXT: }
1414
1515 # RUN: yaml2obj -docnum 1 %s | llvm-readobj -elf-output-style=GNU -relocations - | FileCheck --check-prefix=GNU1 %s
16 # GNU1: Relocation section '.rela.dyn' at offset 0x180 contains 8 entries:
1617 # GNU1: 0000000000001100 0000000000000008 R_X86_64_RELATIVE 0
1718 # GNU1-NEXT: 0000000000001180 0000000000000008 R_X86_64_RELATIVE 0
1819 # GNU1-NEXT: 0000000000001188 0000000100000001 R_X86_64_64 0000000000000000 sym1 + 0
5960 # LLVM2-NEXT: }
6061
6162 # RUN: yaml2obj -docnum 2 %s | llvm-readobj -elf-output-style=GNU -relocations - | FileCheck --check-prefix=GNU2 %s
63 # GNU2: Relocation section '.rel.dyn' at offset 0xfc contains 10 entries:
6264 # GNU2: 00001008 00000101 R_386_32 00000000 sym1
6365 # GNU2-NEXT: 00001010 00000203 R_386_GOT32 00000000 sym2
6466 # GNU2-NEXT: 0000100c 00000008 R_386_RELATIVE
26402640 HasRelocSections = true;
26412641 StringRef Name = unwrapOrError(Obj->getSectionName(&Sec));
26422642 unsigned Entries = Sec.getEntityCount();
2643 std::vector AndroidRelas;
2644 if (Sec.sh_type == ELF::SHT_ANDROID_REL ||
2645 Sec.sh_type == ELF::SHT_ANDROID_RELA) {
2646 // Android's packed relocation section needs to be unpacked first
2647 // to get the actual number of entries.
2648 AndroidRelas = unwrapOrError(Obj->android_relas(&Sec));
2649 Entries = AndroidRelas.size();
2650 }
26432651 uintX_t Offset = Sec.sh_offset;
26442652 OS << "\nRelocation section '" << Name << "' at offset 0x"
26452653 << to_hexString(Offset, false) << " contains " << Entries
26642672 break;
26652673 case ELF::SHT_ANDROID_REL:
26662674 case ELF::SHT_ANDROID_RELA:
2667 for (const auto &R : unwrapOrError(Obj->android_relas(&Sec)))
2675 for (const auto &R : AndroidRelas)
26682676 printRelocation(Obj, SymTab, R, Sec.sh_type == ELF::SHT_ANDROID_RELA);
26692677 break;
26702678 }