This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Do not join input sections when linker creates relocatable object file (-r option)
ClosedPublic

Authored by evgeny777 on Oct 4 2016, 5:03 AM.

Details

Summary

When -r option is used lld may end up creating malformed object file. The simplest example is an input file having following sections

.text._init SHT_PROGBITS
.text._fini SHT_PROGBITS
.rela.text._init SHT_RELA
.rela.text._fini SHT_RELA

Given input above lld will produce object file with two relocation sections for a single section .text. If you then pass this file as an input for GNU ld, you'll get error 'File not recognized: bad value'

Diff Detail

Repository
rL LLVM

Event Timeline

evgeny777 updated this revision to Diff 73456.Oct 4 2016, 5:03 AM
evgeny777 retitled this revision from to [ELF] Do not join input sections when linker creates relocatable object file (-r option).
evgeny777 updated this object.
evgeny777 added reviewers: ruiu, rafael.
evgeny777 set the repository for this revision to rL LLVM.
evgeny777 added a project: lld.
evgeny777 added subscribers: grimar, ikudrin, llvm-commits.
ruiu accepted this revision.Oct 4 2016, 1:18 PM
ruiu edited edge metadata.

LGTM

ELF/Writer.cpp
94 ↗(On Diff #73456)

Please replace Name with S->Name in this function. I think it made sense when it was S->getName() but not anymore.

This revision is now accepted and ready to land.Oct 4 2016, 1:18 PM
This revision was automatically updated to reflect the committed changes.