This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj] - Do not skip zeroes blocks if there are relocations against them.
ClosedPublic

Authored by grimar on Feb 13 2019, 5:45 AM.

Details

Summary

This is for -D -reloc combination.

Recently I inspected an ELF object and was confused, because of the whole .rodata section
was skipped for me. It contained zero bytes, but I expected to see the relocations there.
I did not instantly realize that that happens because we skip all zero bytes after the rL350823.

In this patch, I suggest to not skip the zero bytes that have a relocation against them when -reloc is used.
If -reloc is not used, then the behavior will be the same.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Feb 13 2019, 5:45 AM
grimar updated this revision to Diff 186637.Feb 13 2019, 5:49 AM
  • Update the comment.

This behavior is reasonable, and is what GNU objdump has:

0000000000000000 <.rodata>:
	...
			0: R_X86_64_64	*ABS*
			a: R_X86_64_64	*ABS*

It doesn't use our 8-zeroes heuristic, though.

This behavior is reasonable, and is what GNU objdump has:

0000000000000000 <.rodata>:
	...
			0: R_X86_64_64	*ABS*
			a: R_X86_64_64	*ABS*

It doesn't use our 8-zeroes heuristic, though.

FWIW, I did not try to follow the objdump. I think we can do better :)

jhenderson added inline comments.Feb 18 2019, 6:10 AM
test/tools/llvm-objdump/disasm-zeroes-relocations.test
2 ↗(On Diff #186637)

Could you also add a case to this test showing that disassembly does skip the zeroes in this case, if the -reloc switch is not used, please?

tools/llvm-objdump/llvm-objdump.cpp
1287–1288 ↗(On Diff #186637)

I'd rephrase this slightly as "For -reloc: print zero blocks patched by relocations, so that relocations can be shown in the dump."

grimar updated this revision to Diff 187243.Feb 18 2019, 6:48 AM
grimar marked 2 inline comments as done.
  • Addressed review comments.
This revision is now accepted and ready to land.Feb 19 2019, 1:56 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 19 2019, 4:38 AM