This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump] - Print symbol addressed when dumping disassembly output (-d)
ClosedPublic

Authored by grimar on Dec 28 2018, 2:22 AM.

Details

Summary

When GNU objdump dumps the input with -d it prints the symbol addresses,
for example:

0000000000000031 <foo>:
  31:	00 00                	add    %al,(%rax)
	...

0000000000000035 <bar>:
	...

when llvm-objdump dumps the same object, it doesn't do that:

foo:
		...
      39:	00 00 	addb	%al, (%rax)

bar:
		...
      39:	00 00 	addb	%al, (%rax)
      3b:	00 00 	addb	%al, (%rax)

The reason to do the same is the following:
I am working on a D56083, which implements -z/--disassemble-zeroes.
Normally the disassembly output will skip blocks of zeroes. Currently, by default GNU objdump
skip them, but llvm-objdump does not. And the issue is shown in the sample above.
If we omit the bytes at the beginning of the section (see bar above), then the first
address (0x0000000000000035) is not printed and it is inconvenient and makes the output
not so useful as we do not see the start address of the symbol then.

So I suggest to follow the GNU objdump behavior and also print the address unless the
-no-leading-addr flag is set.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Dec 28 2018, 2:22 AM
echristo accepted this revision.Dec 30 2018, 10:58 PM

Sure.

-eric

This revision is now accepted and ready to land.Dec 30 2018, 10:58 PM
jhenderson accepted this revision.Jan 2 2019, 5:36 AM

LGTM too. Not that I'm saying you should change it, as I don't know how complex it would be, but perhaps an alternative to consider might have been to disassemble the first zeroes after a symbol, even without -z. Something like this:

foo:
10: 00 00
...
bar:
40: 00 00
...

I'm not sure how desirable that is versus the alternative though (really, I'm not sure I see much benefit to the behaviour of not disassembling zeroes, but that's just me).

grimar added a comment.Jan 9 2019, 6:46 AM

LGTM too. Not that I'm saying you should change it, as I don't know how complex it would be, but perhaps an alternative to consider might have been to disassemble the first zeroes after a symbol, even without -z. Something like this:

foo:
10: 00 00
...
bar:
40: 00 00
...

I'm not sure how desirable that is versus the alternative though (really, I'm not sure I see much benefit to the behaviour of not disassembling zeroes, but that's just me).

I am definitely not against of further tweaking of the -z/no -z behavior, but I think printing the symbol address (this patch) can and should be an independent thing.
Skipping/not-skipping any zeroes is a heuristic logic that might change and it better to reduce/eliminate/not introduce any dependencies/assumptions here I believe.

This revision was automatically updated to reflect the committed changes.