This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Do not merge relocation sections by name when using --emit-relocs.
ClosedPublic

Authored by grimar on Jun 2 2017, 4:01 AM.

Details

Summary

Previously we would merge relocation sections by name.
That did not work in some cases, like testcase shows.

Patch implements logic to merge relocation sections if their target
sections were merged into the same output section.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Jun 2 2017, 4:01 AM
ruiu added inline comments.Jun 5 2017, 7:51 AM
ELF/OutputSections.cpp
345 ↗(On Diff #101185)

Use auto.

ELF/OutputSections.h
70–71 ↗(On Diff #101185)

Pointer to a relocation section for this section. Usually nullptr because we consume relocations, but if --emit-relocs is specified (which is rare), it may have a non-null value.

test/ELF/emit-relocs-merge.test
1 ↗(On Diff #101185)

Can you create this using llvm-mc?

grimar added inline comments.Jun 5 2017, 8:10 AM
test/ELF/emit-relocs-merge.test
1 ↗(On Diff #101185)

I do not think so. Idea here was to create relocation section that does not have name starting from ".rel" or ".rela".
I do not think llvm-mc allows to do that.

ruiu added inline comments.Jun 5 2017, 8:47 AM
test/ELF/emit-relocs-merge.test
1 ↗(On Diff #101185)

But you can test this if you use a linker script, no? You are using` .zed : { *(.foo) *(.bar) }` as an example.

grimar added inline comments.Jun 5 2017, 10:42 PM
test/ELF/emit-relocs-merge.test
1 ↗(On Diff #101185)

I sure can, but linkerscript case (a bit outdated) is a D33780. I am about to update this patch
to support linkerscript case, add testcase from D33780 with Rafael's comments addressed and remove
this yaml test then.

grimar updated this revision to Diff 101519.Jun 6 2017, 12:39 AM
grimar edited the summary of this revision. (Show Details)
  • Addressed review comments.
  • Switched to linkerscript testcase.
ELF/OutputSections.cpp
345 ↗(On Diff #101185)

Done.

ELF/OutputSections.h
70–71 ↗(On Diff #101185)

Done.

ruiu accepted this revision.Jun 6 2017, 8:52 AM

LGTM

This revision is now accepted and ready to land.Jun 6 2017, 8:52 AM
This revision was automatically updated to reflect the committed changes.