]> git.ipfire.org Git - thirdparty/elfutils.git/commit
readelf: Handle DW_OP_call2 and DW_OP_call4 correctly.
authorMark Wielaard <mark@klomp.org>
Thu, 7 Dec 2017 15:31:54 +0000 (16:31 +0100)
committerMark Wielaard <mark@klomp.org>
Mon, 11 Dec 2017 23:02:54 +0000 (00:02 +0100)
commit57b7f381e167356fa47d58c18bbc2e856f75ee16
tree2d940044251ab49ea32192b28b5d8a1e07ba71fc
parentb0654221fc2691b3ec633463285c9ef4a86267ae
readelf: Handle DW_OP_call2 and DW_OP_call4 correctly.

DW_OP_call2 and DW_OP_call4 didn't correctly advance the data pointer.
This caused print_ops to produce garbage operands. Also format the
arguments as DIE offsets. That makes it easier to follow the call to the
actual dwarf_procedure DIE.

Testcase from https://sourceware.org/bugzilla/show_bug.cgi?id=22532

The testcase only checks the eu-readelf output is correct for the
byte_size attribute. But it might be interesting to write a full
expression parser to check the actual sizes.

 [    3e]    structure_type
             name                 (strp) "pck__rec"
             byte_size            (exprloc)
              [   0] push_object_address
              [   1] deref_size 1
              [   3] call4 [    95]
              [   8] plus_uconst 7
              [  10] const1s -4
              [  12] and

 [    95]    dwarf_procedure
             location             (exprloc)
              [   0] dup
              [   1] lit1
              [   2] ne
              [   3] bra 10
              [   6] lit4
              [   7] skip 31
              [  10] dup
              [  11] lit4
              [  12] ne
              [  13] bra 20
              [  16] lit0
              [  17] skip 31
              [  20] dup
              [  21] lit3
              [  22] eq
              [  23] bra 30
              [  26] lit0
              [  27] skip 31
              [  30] lit4
              [  31] swap
              [  32] drop

The "answer" depends on the Discr value (first byte at object address),
and is rounded up to 4 or 8 bytes.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/ChangeLog
src/readelf.c
tests/ChangeLog
tests/Makefile.am
tests/run-readelf-variant.sh [new file with mode: 0755]
tests/testfile-ada-variant.bz2 [new file with mode: 0644]