This is an archive of the discontinued LLVM Phabricator instance.

[lld][ELF] Do not emit warning for NOLOAD output sections
ClosedPublic

Authored by leonardchan on May 22 2023, 12:55 PM.

Details

Summary

Much of NOLOAD's intended use is to explicitly change the type of an output section, so we shouldn't flag these as warnings.

Diff Detail

Event Timeline

leonardchan created this revision.May 22 2023, 12:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2023, 12:55 PM
leonardchan requested review of this revision.May 22 2023, 12:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2023, 12:55 PM
peter.smith accepted this revision.May 23 2023, 1:25 AM

Thanks very much for posting the alternative patch. One small suggestion to update the comment.

I had been thinking about whether it was worth distinguishing between (NOLOAD) and (TYPE=SHT_NOBITS), i.e. error for the latter but do nothing for the former. However GNU ld does not diagnose either case, and as TYPE=SHT_NOBITS is likely to be an expert level feature, it is probably best leaving as is.

Best to wait a bit to see if MaskRay has any comments as well.

lld/ELF/OutputSections.cpp
118–119

I think the comment is worth updating. For example

The (NOLOAD) changes the section type to SHT_NOBITS, the intention is that the contents at that address is provided by some other means. Some projects (e.g. https://github.com/ClangBuiltLinux/linux/issues/1597) rely on the behavior. Other types get an error.
This revision is now accepted and ready to land.May 23 2023, 1:25 AM
leonardchan marked an inline comment as done.
MaskRay accepted this revision.May 23 2023, 12:32 PM
MaskRay added inline comments.
lld/test/ELF/linkerscript/noload.s
25

Check that there is no warning. An exact message can easily get stale.

This revision was automatically updated to reflect the committed changes.
leonardchan marked an inline comment as done.