This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Produce relocation section name consistent with output section name when --emit-reloc used with linker script.
ClosedPublic

Authored by grimar on Nov 30 2017, 7:28 AM.

Details

Summary

This is for "Bug 35474 - --emit-relocs produces wrongly-named reloc sections".

LLD currently for scripts like:

.text.boot : { *(.text.boot) }

emits relocation section with name .rela.text because does not take
redefined name of output section into account and builds section name
using rules for non-scripted case. Patch fixes this oddness.

Diff Detail

Event Timeline

grimar created this revision.Nov 30 2017, 7:28 AM
ruiu added inline comments.Nov 30 2017, 1:13 PM
ELF/Writer.cpp
91

This saves only two characters. Just use S->Name instead of Name.

104–105

Is it possible that a section is a synthetic section and has type of SHT_REL[A]?

ruiu edited edge metadata.Nov 30 2017, 3:11 PM

LGTM given that you will name Name S->Name in a follow-up patch.

This change as is fixes my real-world case.
Thanks! Now I'm just blocked on --just-symbols...

grimar added inline comments.Dec 1 2017, 12:59 AM
ELF/Writer.cpp
104–105

Yes, .rela.dyn/.rela.plt for example.

btw, I was thinking about wrapping this whole block in if (Config->EmitRelocs).
It should not affect logic, but probably can make code more readable because reader not need
to read code for --emit-relocs usually. With explicit if statement it can be skipped.
But we usually do not do excessive checks for readability I think, so did not do that.

This revision was automatically updated to reflect the committed changes.