[llvm] r218408 - Report endianness in output of {dwarf, obj}dump

Renato Golin renato.golin at linaro.org
Wed Sep 24 13:07:41 PDT 2014


Author: rengolin
Date: Wed Sep 24 15:07:41 2014
New Revision: 218408

URL: http://llvm.org/viewvc/llvm-project?rev=218408&view=rev
Log:
Report endianness in output of {dwarf, obj}dump

For biendian targets like ARM and AArch64, it is useful to have the
output of the llvm-dwarfdump and llvm-objdump report the endianness
used when the object files were generated.

Patch by Charlie Turner.

Added:
    llvm/trunk/test/tools/llvm-dwarfdump/AArch64/little-endian-dump.ll
      - copied, changed from r218407, llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll
    llvm/trunk/test/tools/llvm-dwarfdump/ARM/little-endian-dump.ll
      - copied, changed from r218407, llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll
Modified:
    llvm/trunk/include/llvm/Object/ELFObjectFile.h
    llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll
    llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll

Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=218408&r1=218407&r2=218408&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Wed Sep 24 15:07:41 2014
@@ -855,6 +855,7 @@ uint8_t ELFObjectFile<ELFT>::getBytesInA
 
 template <class ELFT>
 StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
+  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
   switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) {
   case ELF::ELFCLASS32:
     switch (EF.getHeader()->e_machine) {
@@ -863,7 +864,7 @@ StringRef ELFObjectFile<ELFT>::getFileFo
     case ELF::EM_X86_64:
       return "ELF32-x86-64";
     case ELF::EM_ARM:
-      return "ELF32-arm";
+      return (IsLittleEndian ? "ELF32-arm-little" : "ELF32-arm-big");
     case ELF::EM_HEXAGON:
       return "ELF32-hexagon";
     case ELF::EM_MIPS:
@@ -883,7 +884,7 @@ StringRef ELFObjectFile<ELFT>::getFileFo
     case ELF::EM_X86_64:
       return "ELF64-x86-64";
     case ELF::EM_AARCH64:
-      return "ELF64-aarch64";
+      return (IsLittleEndian ? "ELF64-aarch64-little" : "ELF64-aarch64-big");
     case ELF::EM_PPC64:
       return "ELF64-ppc64";
     case ELF::EM_S390:

Modified: llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll?rev=218408&r1=218407&r2=218408&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll Wed Sep 24 15:07:41 2014
@@ -1,5 +1,7 @@
 ; RUN: llc -O0 -filetype=obj -o %t1 < %s
-; RUN: llvm-dwarfdump %t1
+; RUN: llvm-dwarfdump %t1 | FileCheck %s
+
+; CHECK: file format ELF64-aarch64-big 
 
 target datalayout = "E-m:e-i64:64-i128:128-n32:64-S128"
 target triple = "aarch64_be-none--eabi"

Copied: llvm/trunk/test/tools/llvm-dwarfdump/AArch64/little-endian-dump.ll (from r218407, llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/AArch64/little-endian-dump.ll?p2=llvm/trunk/test/tools/llvm-dwarfdump/AArch64/little-endian-dump.ll&p1=llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll&r1=218407&r2=218408&rev=218408&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/AArch64/big-endian-dump.ll (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/AArch64/little-endian-dump.ll Wed Sep 24 15:07:41 2014
@@ -1,8 +1,10 @@
 ; RUN: llc -O0 -filetype=obj -o %t1 < %s
-; RUN: llvm-dwarfdump %t1
+; RUN: llvm-dwarfdump %t1 | FileCheck %s
 
-target datalayout = "E-m:e-i64:64-i128:128-n32:64-S128"
-target triple = "aarch64_be-none--eabi"
+; CHECK: file format ELF64-aarch64-little
+
+target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-none--eabi"
 
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!3, !4}

Modified: llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll?rev=218408&r1=218407&r2=218408&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll Wed Sep 24 15:07:41 2014
@@ -1,5 +1,7 @@
 ; RUN: llc -O0 -filetype=obj -o %t1 < %s
-; RUN: llvm-dwarfdump %t1
+; RUN: llvm-dwarfdump %t1 | FileCheck %s
+
+; CHECK: file format ELF32-arm-big
 
 target datalayout = "E-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
 target triple = "armebv8-none--eabi"

Copied: llvm/trunk/test/tools/llvm-dwarfdump/ARM/little-endian-dump.ll (from r218407, llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/ARM/little-endian-dump.ll?p2=llvm/trunk/test/tools/llvm-dwarfdump/ARM/little-endian-dump.ll&p1=llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll&r1=218407&r2=218408&rev=218408&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/ARM/big-endian-dump.ll (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/ARM/little-endian-dump.ll Wed Sep 24 15:07:41 2014
@@ -1,8 +1,10 @@
 ; RUN: llc -O0 -filetype=obj -o %t1 < %s
-; RUN: llvm-dwarfdump %t1
+; RUN: llvm-dwarfdump %t1 | FileCheck %s
 
-target datalayout = "E-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
-target triple = "armebv8-none--eabi"
+; CHECK: file format ELF32-arm-little
+
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
+target triple = "armv8-none--eabi"
 
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!3, !4, !5, !6}





More information about the llvm-commits mailing list