This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Handle multiple discontiguous .note sections
ClosedPublic

Authored by phosek on Jan 31 2017, 7:00 PM.

Details

Summary

There could be multiple discontiguous output .note sections in which case we need to put these into separate PT_NOTE segments rather then placing them into a single segment. Where possible, we could reorder the input sections to make sure that all .note are layed out next to each other to avoid creation multiple PT_NOTE segments, but even in that case, it's still possible to construct a discontiguous case e.g. by using a linker script.

Diff Detail

Repository
rL LLVM

Event Timeline

phosek created this revision.Jan 31 2017, 7:00 PM
ruiu added inline comments.Jan 31 2017, 8:17 PM
ELF/Writer.cpp
1236–1240

Can you move this code out of this for loop and create a new loop only for .notes? I think doing that improves readability.

grimar added a subscriber: grimar.Feb 1 2017, 2:01 AM

I think this also needs testcase which shows that next case still creates single PT_NOTE segment:

.note : { *(.note.a) *(.note.b) }
phosek updated this revision to Diff 86654.Feb 1 2017, 9:33 AM
phosek marked an inline comment as done.
ruiu accepted this revision.Feb 1 2017, 11:26 AM

LGTM

Please add a comment saying that that code creates one PT_NOTE per a group of contiguous .note sections.

This revision is now accepted and ready to land.Feb 1 2017, 11:26 AM
This revision was automatically updated to reflect the committed changes.