[llvm-commits] [llvm] r141579 - in /llvm/trunk: include/llvm/Support/Format.h test/Object/objdump-sectionheaders.test tools/llvm-objdump/llvm-objdump.cpp
Dimitry Andric
dimitry at andric.com
Tue Oct 11 02:58:57 PDT 2011
On 2011-10-10 23:21, Nick Lewycky wrote:
> Author: nicholas
> Date: Mon Oct 10 16:21:34 2011
> New Revision: 141579
>
> URL: http://llvm.org/viewvc/llvm-project?rev=141579&view=rev
> Log:
> Add support for dumping section headers to llvm-objdump. This uses the same
> flags as binutils objdump but the output is different, not just in format but
> also showing different sections. Compare its results against readelf, not
> objdump.
>
> Added:
> llvm/trunk/test/Object/objdump-sectionheaders.test
> Modified:
> llvm/trunk/include/llvm/Support/Format.h
> llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
>
This makes the Object/objdump-sectionheaders.test fail on i386:
...
FAIL: LLVM :: Object/objdump-sectionheaders.test (3835 of 5635)
******************** TEST 'LLVM :: Object/objdump-sectionheaders.test' FAILED ********************
Script:
--
llvm-objdump -h /home/dim/src/llvm/trunk/test/Object/TestObjectFiles/trivial-object-test.elf-x86-64 | /home/dim/obj/llvm-1/Release+Asserts/bin/FileCheck /home/dim/src/llvm/trunk/test/Object/objdump-sectionheaders.test
--
Exit Code: 1
Command Output (stderr):
--
Stack dump:
0. Program arguments: llvm-objdump -h /home/dim/src/llvm/trunk/test/Object/TestObjectFiles/trivial-object-test.elf-x86-64
FileCheck error: '-' is empty.
--
The cause is an llvm-objdump segfault:
$ ~/obj/llvm-1/Release+Asserts/bin/llvm-objdump -h /home/dim/src/llvm/trunk/test/Object/TestObjectFiles/trivial-object-test.elf-x86-64
Sections:
Idx Name Size Address Type
0 000000000 00000000000000000 (null)
1 .text 000000026 00000000000000000 (null)
Stack dump:
0. Program arguments: /home/dim/obj/llvm-1/Release+Asserts/bin/llvm-objdump -h /home/dim/src/llvm/trunk/test/Object/TestObjectFiles/trivial-object-test.elf-x86-64
Segmentation fault: 11 (core dumped)
The segfault occurs in tools/llvm-objdump/llvm-objdump.cpp:
...
static void PrintSectionHeaders(const ObjectFile *o) {
..
uint64_t Address;
if (error(si->getAddress(Address))) return;
uint64_t Size;
...
outs() << format("%3d %-13s %09x %017x %s\n", i, Name.str().c_str(), Size,
Address, Type.c_str());
Size and Address are both 64-bit variables, but they are snprintf'd
using %x, which leads to a segfault on i386. I have attached a fix for
this.
Unfortunately, the format() functions in include/llvm/Support/Format.h
cannot have an __attribute__((format(printf(1,2)) appended, since that
attribute works only on variadic functions, which is a real pity. There
may be many more of these format problems... :)
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fix-llvm-objdump-crash-1.diff
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111011/184f5040/attachment.ksh>
More information about the llvm-commits
mailing list