[llvm] r260489 - [readobj] Dump DT_JMPREL relocations when outputting dynamic relocations.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 14:34:28 PST 2016


Thanks!

On 10 February 2016 at 23:59, Michael J. Spencer via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: mspencer
> Date: Wed Feb 10 22:59:53 2016
> New Revision: 260489
>
> URL: http://llvm.org/viewvc/llvm-project?rev=260489&view=rev
> Log:
> [readobj] Dump DT_JMPREL relocations when outputting dynamic relocations.
>
> Modified:
>     llvm/trunk/test/Object/relocation-executable.test
>     llvm/trunk/test/tools/llvm-readobj/dynamic-symbols.test
>     llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
>
> Modified: llvm/trunk/test/Object/relocation-executable.test
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/relocation-executable.test?rev=260489&r1=260488&r2=260489&view=diff
> ==============================================================================
> --- llvm/trunk/test/Object/relocation-executable.test (original)
> +++ llvm/trunk/test/Object/relocation-executable.test Wed Feb 10 22:59:53 2016
> @@ -34,6 +34,18 @@ RUN:   %p/Inputs/hello-world.elf-x86-64
>  // DYN-NEXT:     Symbol: __gmon_start__
>  // DYN-NEXT:     Addend: 0x0
>  // DYN-NEXT:   }
> +// DYN-NEXT:   Relocation {
> +// DYN-NEXT:     Offset: 0x4018F8
> +// DYN-NEXT:     Type: R_X86_64_JUMP_SLOT (7)
> +// DYN-NEXT:     Symbol: __libc_start_main
> +// DYN-NEXT:     Addend: 0x0
> +// DYN-NEXT:   }
> +// DYN-NEXT:   Relocation {
> +// DYN-NEXT:     Offset: 0x401900
> +// DYN-NEXT:     Type: R_X86_64_JUMP_SLOT (7)
> +// DYN-NEXT:     Symbol: puts
> +// DYN-NEXT:     Addend: 0x0
> +// DYN-NEXT:   }
>  // DYN-NEXT: }
>
>  RUN: llvm-readobj -dyn-relocations -expand-relocs \
>
> Modified: llvm/trunk/test/tools/llvm-readobj/dynamic-symbols.test
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/dynamic-symbols.test?rev=260489&r1=260488&r2=260489&view=diff
> ==============================================================================
> --- llvm/trunk/test/tools/llvm-readobj/dynamic-symbols.test (original)
> +++ llvm/trunk/test/tools/llvm-readobj/dynamic-symbols.test Wed Feb 10 22:59:53 2016
> @@ -1,6 +1,6 @@
> -RUN: llvm-readobj -dyn-symbols -dynamic-table \
> +RUN: llvm-readobj -dyn-symbols -dynamic-table -dyn-relocations \
>  RUN:   %S/Inputs/dynamic-table-exe-no-shdrs.x86 | FileCheck %s
> -RUN: llvm-readobj -dyn-symbols -dynamic-table \
> +RUN: llvm-readobj -dyn-symbols -dynamic-table -relocations \
>  RUN:   %S/Inputs/dynamic-table-exe-no-phdrs.x86 | FileCheck %s
>
>  CHECK:      File:
> @@ -8,7 +8,32 @@ CHECK-NEXT: Format: ELF32-i386
>  CHECK-NEXT: Arch: i386
>  CHECK-NEXT: AddressSize: 32bit
>  CHECK-NEXT: LoadName:
> -CHECK-NEXT: DynamicSymbols [
> +CHECK:        0x85F R_386_RELATIVE - 0x0
> +CHECK-NEXT:   0x874 R_386_RELATIVE - 0x0
> +CHECK-NEXT:   0x19FC R_386_RELATIVE - 0x0
> +CHECK-NEXT:   0x1A00 R_386_RELATIVE - 0x0
> +CHECK-NEXT:   0x1B2C R_386_RELATIVE - 0x0
> +CHECK-NEXT:   0x1B60 R_386_RELATIVE - 0x0
> +CHECK-NEXT:   0x0 R_386_NONE - 0x0
> +CHECK-NEXT:   0x864 R_386_PC32 puts 0x0
> +CHECK-NEXT:   0x880 R_386_PC32 _ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode 0x0
> +CHECK-NEXT:   0x88C R_386_PC32 _ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev 0x0
> +CHECK-NEXT:   0x89B R_386_PC32 _Unwind_Resume 0x0
> +CHECK-NEXT:   0x9BB R_386_32 __gxx_personality_v0 0x0
> +CHECK-NEXT:   0x1B18 R_386_GLOB_DAT __gmon_start__ 0x0
> +CHECK-NEXT:   0x1B1C R_386_GLOB_DAT _Jv_RegisterClasses 0x0
> +CHECK-NEXT:   0x1B20 R_386_GLOB_DAT _ITM_deregisterTMCloneTable 0x0
> +CHECK-NEXT:   0x1B24 R_386_GLOB_DAT _ITM_registerTMCloneTable 0x0
> +CHECK-NEXT:   0x1B28 R_386_GLOB_DAT __cxa_finalize 0x0
> +CHECK:        0x1B3C R_386_JUMP_SLOT __gmon_start__ 0x0
> +CHECK-NEXT:   0x1B40 R_386_JUMP_SLOT __libc_start_main 0x0
> +CHECK-NEXT:   0x1B44 R_386_JUMP_SLOT _ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev 0x0
> +CHECK-NEXT:   0x1B48 R_386_JUMP_SLOT _ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode 0x0
> +CHECK-NEXT:   0x1B4C R_386_JUMP_SLOT puts 0x0
> +CHECK-NEXT:   0x1B50 R_386_JUMP_SLOT __gxx_personality_v0 0x0
> +CHECK-NEXT:   0x1B54 R_386_JUMP_SLOT _Unwind_Resume 0x0
> +CHECK-NEXT:   0x1B58 R_386_JUMP_SLOT __cxa_finalize 0x0
> +CHECK:        DynamicSymbols [
>  CHECK-NEXT:   Symbol {
>  CHECK-NEXT:     Name: @
>  CHECK-NEXT:     Value: 0x0
>
> Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=260489&r1=260488&r2=260489&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
> +++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Wed Feb 10 22:59:53 2016
> @@ -165,6 +165,7 @@ private:
>    // Dynamic relocation info.
>    DynRegionInfo DynRelRegion;
>    DynRegionInfo DynRelaRegion;
> +  DynRegionInfo DynPLTRelRegion;
>
>    DynRegionInfo DynSymRegion;
>    StringRef DynamicStringTable;
> @@ -1126,6 +1127,21 @@ void ELFDumper<ELFT>::parseDynamicTable(
>      case ELF::DT_RELENT:
>        DynRelRegion.EntSize = Dyn.getVal();
>        break;
> +    case ELF::DT_PLTREL:
> +      if (Dyn.getVal() == DT_REL)
> +        DynPLTRelRegion.EntSize =  sizeof(Elf_Rel);
> +      else if (Dyn.getVal() == DT_RELA)
> +        DynPLTRelRegion.EntSize = sizeof(Elf_Rela);
> +      else
> +        reportError(Twine("unknown DT_PLTREL value of ") +
> +                    Twine((uint64_t)Dyn.getVal()));
> +      break;
> +    case ELF::DT_JMPREL:
> +      DynPLTRelRegion.Addr = toMappedAddr(Dyn.getPtr());
> +      break;
> +    case ELF::DT_PLTRELSZ:
> +      DynPLTRelRegion.Size = Dyn.getVal();
> +      break;
>      }
>    }
>    if (StringTableBegin)
> @@ -1155,6 +1171,7 @@ void ELFDumper<ELFT>::parseDynamicTable(
>      CheckDRI(DynamicTable);
>      CheckDRI(DynRelRegion);
>      CheckDRI(DynRelaRegion);
> +    CheckDRI(DynPLTRelRegion);
>
>      if (DynamicStringTable.data() >= Start && DynamicStringTable.data() < End)
>        End = DynamicStringTable.data();
> @@ -1307,6 +1324,17 @@ template <class ELFT> void ELFDumper<ELF
>        Elf_Rela Rela;
>        Rela.r_offset = Rel.r_offset;
>        Rela.r_info = Rel.r_info;
> +      Rela.r_addend = 0;
> +      printDynamicRelocation(Rela);
> +    }
> +  if (DynPLTRelRegion.EntSize == sizeof(Elf_Rela))
> +    for (const Elf_Rela &Rela : DynPLTRelRegion.getAsRange<Elf_Rela>())
> +      printDynamicRelocation(Rela);
> +  else
> +    for (const Elf_Rel &Rel : DynPLTRelRegion.getAsRange<Elf_Rel>()) {
> +      Elf_Rela Rela;
> +      Rela.r_offset = Rel.r_offset;
> +      Rela.r_info = Rel.r_info;
>        Rela.r_addend = 0;
>        printDynamicRelocation(Rela);
>      }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list