[PATCH] [llvm-readobj] Properly decode DF_1_XXX flags

Davide Italiano dccitaliano at gmail.com
Sat May 23 16:49:09 PDT 2015


Hi echristo,

Part 2 of D9955 , i.e. llvm-readobj bits.
It seems that readelf puts a "Flags: " string before the actual flag value for FLAGS1 and not FLAGS, e.g.

0x000000000000001e (FLAGS)              ORIGIN BIND_NOW
0x000000006ffffffb (FLAGS_1)            Flags: NOW ORIGIN

I personally think this doesn't make a lot of sense and considering llvm-readobj already broke format compatibility w/ GNU readelf (at least the version on my system, 2.17.50), not surrounding among others the type name with braces, I just ignored it, so llvm-readobj -dynamic-table will print something like:

0x000000000000001E FLAGS                ORIGIN BIND_NOW
0x000000006FFFFFFB FLAGS_1              NOW ORIGIN

If there are objections, I can change the format.


P.S. Too bad all the tests for llvm-readobj rely on executable, maybe at some point this should be changed, but at least the new test doesn't.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9958

Files:
  test/tools/llvm-readobj/Inputs/main.c
  test/tools/llvm-readobj/elf-dtflags.test
  tools/llvm-readobj/ELFDumper.cpp

Index: test/tools/llvm-readobj/Inputs/main.c
===================================================================
--- test/tools/llvm-readobj/Inputs/main.c
+++ test/tools/llvm-readobj/Inputs/main.c
@@ -0,0 +1,6 @@
+// Toy source code for llvm-readobj testing.
+int
+main(void)
+{
+  return (0);
+}
Index: test/tools/llvm-readobj/elf-dtflags.test
===================================================================
--- test/tools/llvm-readobj/elf-dtflags.test
+++ test/tools/llvm-readobj/elf-dtflags.test
@@ -0,0 +1,7 @@
+# Test that llvm-readobj dumps DF_XXX and DF_1_XXX flags correctly.
+#
+#RUN: clang -Wl,-z,origin -Wl,-z,now %p/Inputs/main.c -o %t.o
+#RUN: llvm-readobj -dynamic-table %t.o | FileCheck %s
+#
+#CHECK: 0x000000000000001E FLAGS                ORIGIN BIND_NOW
+#CHECK: 0x000000006FFFFFFB FLAGS_1              NOW ORIGIN
Index: tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- tools/llvm-readobj/ELFDumper.cpp
+++ tools/llvm-readobj/ELFDumper.cpp
@@ -778,6 +778,7 @@
   LLVM_READOBJ_TYPE_CASE(FINI_ARRAY);
   LLVM_READOBJ_TYPE_CASE(FINI_ARRAYSZ);
   LLVM_READOBJ_TYPE_CASE(FLAGS);
+  LLVM_READOBJ_TYPE_CASE(FLAGS_1);
   LLVM_READOBJ_TYPE_CASE(HASH);
   LLVM_READOBJ_TYPE_CASE(INIT);
   LLVM_READOBJ_TYPE_CASE(INIT_ARRAY);
@@ -837,6 +838,34 @@
   LLVM_READOBJ_DT_FLAG_ENT(DF, STATIC_TLS)
 };
 
+static const EnumEntry<unsigned> ElfDynamicDTFlags1[] = {
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, NOW),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, GLOBAL),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, GROUP),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, NODELETE),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, LOADFLTR),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, INITFIRST),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, NOOPEN),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, ORIGIN),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, DIRECT),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, TRANS),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, INTERPOSE),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, NODEFLIB),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, NODUMP),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, CONFALT),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, ENDFILTEE),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, DISPRELDNE),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, NODIRECT),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, IGNMULDEF),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, NOKSYMS),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, NOHDR),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, EDITED),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, NORELOC),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, SYMINTPOSE),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, GLOBAUDIT),
+  LLVM_READOBJ_DT_FLAG_ENT(DF_1, SINGLETON)
+};
+
 static const EnumEntry<unsigned> ElfDynamicDTMipsFlags[] = {
   LLVM_READOBJ_DT_FLAG_ENT(RHF, NONE),
   LLVM_READOBJ_DT_FLAG_ENT(RHF, QUICKSTART),
@@ -950,6 +979,9 @@
   case DT_FLAGS:
     printFlags(Value, makeArrayRef(ElfDynamicDTFlags), OS);
     break;
+  case DT_FLAGS_1:
+    printFlags(Value, makeArrayRef(ElfDynamicDTFlags1), OS);
+    break;
   }
 }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9958.26376.patch
Type: text/x-patch
Size: 2898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150523/4ac59bf4/attachment.bin>


More information about the llvm-commits mailing list