[PATCH] Modify llvm-objdump to display information for common symbols similar to GNU objdump

colinl at codeaurora.org colinl at codeaurora.org
Fri Jan 23 07:35:34 PST 2015


Output for GNU objdump:
$ objdump -t test.o

test.o:     file format elf32-little

SYMBOL TABLE:
00000000 l    df *ABS*  00000000 test.c
00000000 l    d  .text  00000000 .text
00000000 l    d  .data  00000000 .data
00000000 l    d  .bss   00000000 .bss
00000000 l    d  .comment       00000000 .comment
00000400       O *COM*  00000008 common_symbol

Output for llvm-objdump:
$ ./bin/llvm-objdump.exe -t test.o

test.o: file format ELF32-hexagon

SYMBOL TABLE:
00000000         *UND*  00000000
00000000 l    df *ABS*  00000000 test.c
00000000 l    d  .text  00000000 .text
00000000 l    d  .data  00000000 .data
00000000 l    d  .bss   00000000 .bss
00000000 l    d  .comment       00000000 .comment
00000400 g       *COM*  00000008 common_symbol

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D7147

Files:
  test/tools/llvm-objdump/Inputs/common-symbol-elf
  test/tools/llvm-objdump/common-symbol-elf.test
  tools/llvm-objdump/llvm-objdump.cpp

Index: test/tools/llvm-objdump/common-symbol-elf.test
===================================================================
--- test/tools/llvm-objdump/common-symbol-elf.test
+++ test/tools/llvm-objdump/common-symbol-elf.test
@@ -0,0 +1,3 @@
+// RUN: llvm-objdump -t %p/Inputs/common-symbol-elf | FileCheck %s
+
+CHECK: 00000400 g       *COM*  00000008 common_symbol
\ No newline at end of file
Index: tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- tools/llvm-objdump/llvm-objdump.cpp
+++ tools/llvm-objdump/llvm-objdump.cpp
@@ -642,7 +642,15 @@
     bool Global = Flags & SymbolRef::SF_Global;
     bool Weak = Flags & SymbolRef::SF_Weak;
     bool Absolute = Flags & SymbolRef::SF_Absolute;
+    bool Common = Flags & SymbolRef::SF_Common;
 
+    if (Common) {
+      uint32_t Alignment;
+      if (error(Symbol.getAlignment(Alignment)))
+        Alignment = 0;
+      Address = Size;
+      Size = Alignment;
+    }
     if (Address == UnknownAddressOrSize)
       Address = 0;
     if (Size == UnknownAddressOrSize)
@@ -672,6 +680,8 @@
            << ' ';
     if (Absolute) {
       outs() << "*ABS*";
+    } else if (Common) {
+      outs() << "*COM*";
     } else if (Section == o->section_end()) {
       outs() << "*UND*";
     } else {

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7147.18678.patch
Type: text/x-patch
Size: 1307 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150123/a083c930/attachment.bin>


More information about the llvm-commits mailing list