Page MenuHomePhabricator

[ELF] Place .note in the first page to ensure they are available in core files
ClosedPublic

Authored by MaskRay on Dec 17 2018, 5:34 PM.

Details

Summary

Other large sections (e.g. .rela.dyn .dynstr) may push .note.* off the
first page. They won't be available in core files if RLIMIT_CORE is
limited.

This patch gives priority to alloctable SHT_NOTE sections so that they
are assuredly in the first page and will be available in core files.
They are small and contain important information (e.g. .note.gnu.build-id
identifies the origin of the core, .note.tag stores NT_FREEBSD_ABI_TAG).

Note: gold Output_section_order has a similar rule:

// Loadable read-only note sections come next so that the PT_NOTE
// segment is on the first page of the executable.
ORDER_RO_NOTE,

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

MaskRay created this revision.Dec 17 2018, 5:34 PM
MaskRay updated this revision to Diff 178571.Dec 17 2018, 5:38 PM
MaskRay edited the summary of this revision. (Show Details)

gold

MaskRay updated this revision to Diff 178573.Dec 17 2018, 5:41 PM

Forget to upload test file...

MaskRay updated this revision to Diff 178595.Dec 17 2018, 11:00 PM
MaskRay edited the summary of this revision. (Show Details)

Add comment about FreeBSD .note.tag

grimar added a subscriber: grimar.Dec 18 2018, 3:26 AM
ruiu accepted this revision.Dec 18 2018, 11:08 AM

LGTM

ELF/Writer.cpp
787–791

This exiting comment is a bit pointless. Let's update:

Put .note sections at the beginning of an output file so that they are likely to be included in a core file even if core file size is limited by ulimit. In particular, we want a .note.gnu.build-id and a .note.tag to be included in a core to match core files with executable files.
This revision is now accepted and ready to land.Dec 18 2018, 11:08 AM
MaskRay updated this revision to Diff 178740.Dec 18 2018, 11:16 AM
MaskRay removed subscribers: grimar, krytarowski.

Update comments

This revision was automatically updated to reflect the committed changes.