This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Rename .bss.rel.ro to .data.rel.ro.bss for some Linker Scripts.
ClosedPublic

Authored by peter.smith on Nov 22 2017, 10:11 AM.

Details

Summary

This is patch 3 of 3 spun out from D40029 covering: Name change when linker scripts are used.

LLD uses .bss.rel.ro for read-only copy relocations whereas the ld.bfd and gold linkers use .data.rel.ro. In some linker scripts including ld.bfd's internal linker script, the relro sections are placed sequentially assuming .data.rel.ro is used. LLD's use of .bss.rel.ro means that the copy relocations get matched into the .bss section causing the relro sections to be non-contiguous.

This change checks for a .data.rel.ro OutputSection when a linker script with the SECTIONS command is used. The section will match in the .data.rel.ro output section and will maintain contiguous relro.

Diff Detail

Repository
rL LLVM

Event Timeline

peter.smith created this revision.Nov 22 2017, 10:11 AM
ruiu accepted this revision.Nov 23 2017, 6:05 PM

LGTM

ELF/Writer.cpp
292 ↗(On Diff #123972)

nit: add a blank line before a comment.

295 ↗(On Diff #123972)

nit: It feels a bit too long. I'd name HasDataRelRo or something like that.

This revision is now accepted and ready to land.Nov 23 2017, 6:05 PM
grimar added a subscriber: grimar.Nov 23 2017, 10:24 PM
grimar added inline comments.
test/ELF/relro-script.s
19 ↗(On Diff #123972)

nit: Can you put REQURES at first line of test ?

This revision was automatically updated to reflect the committed changes.

Thanks for the comments, I've applied those prior to commit.