This is an archive of the discontinued LLVM Phabricator instance.

[LLD] Avoid empty .eh_frame sections
ClosedPublic

Authored by kettenis on Apr 23 2017, 6:50 AM.

Details

Reviewers
ruiu
rafael
Summary

Since D30335: [LLD] Add terminator to .eh_frame sections got reverted, here is a new attempt to address the issue that prompted me to look into the unterminated .eh_frame section issue. This is that strip on OpenBSD does not correctly handle an empty .eh_frame section and produces broken binaries in that case. Currently lld creates such an empty .eh_frame section, despite the fact that the OpenBSD crtend.o explicitly inserts a terminator. The Linux LSB "standard":

https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html#EHFRAME

explicitly says that

The .eh_frame section shall contain 1 or more Call Frame Information (CFI) records.

This diff includes a test that specifically tests the issue I'm seeing on OpenBSD.

Diff Detail

Event Timeline

kettenis created this revision.Apr 23 2017, 6:50 AM
ruiu accepted this revision.Apr 24 2017, 10:15 AM

LGTM. I think this is fine, but I'll give Rafael a chance to take a look. Please wait for a few days before submitting.

lld/ELF/SyntheticSections.cpp
548–551
this->Size = (Off == 0) ? 4 : Off;
This revision is now accepted and ready to land.Apr 24 2017, 10:15 AM
kettenis closed this revision.May 24 2017, 8:33 AM

Committed r301931