diff --git a/test/tools/llvm-objdump/Inputs/common-symbol-elf b/test/tools/llvm-objdump/Inputs/common-symbol-elf new file mode 100644 index 00000000000..9609edb041f Binary files /dev/null and b/test/tools/llvm-objdump/Inputs/common-symbol-elf differ diff --git a/test/tools/llvm-objdump/common-symbol-elf.test b/test/tools/llvm-objdump/common-symbol-elf.test new file mode 100644 index 00000000000..32df05ac051 --- /dev/null +++ b/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 diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index cd94a3a49c6..1204a973d45 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -642,7 +642,15 @@ void llvm::PrintSymbolTable(const ObjectFile *o) { 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 @@ void llvm::PrintSymbolTable(const ObjectFile *o) { << ' '; if (Absolute) { outs() << "*ABS*"; + } else if (Common) { + outs() << "*COM*"; } else if (Section == o->section_end()) { outs() << "*UND*"; } else {