This is an archive of the discontinued LLVM Phabricator instance.

Fix ARM __cxa_end_cleanup() and gc-sections.
ClosedPublic

Authored by logan on Dec 17 2015, 7:42 AM.

Details

Summary

This commit adds SHF_ALLOC and SHF_EXECINSTR section flags to
.text.__cxa_end_cleanup section. This fixes a link error when we are
using integrated-as and ld.gold (with -Wl,--gc-sections and
-Wl,--fatal-warnings.)

Detailed Explanation:

  1. There might be some issue with LLVM integrated-as, so that there is no default section flags for text sections. (This will be fixed in an independent commit.)
  1. ld.gold will skip the external symbols in the section without SHF_ALLOC. This is the reason why .text.cxa_end_cleanup_impl section is discarded even though it is referenced by cxa_end_cleanup().

This commit workaround the problem by specifying the section flag
explicitly.

Fix http://llvm.org/PR21292

Diff Detail

Event Timeline

logan updated this revision to Diff 43144.Dec 17 2015, 7:42 AM
logan retitled this revision from to Fix ARM __cxa_end_cleanup() and gc-sections..
logan updated this object.
logan added a subscriber: cfe-commits.
echristo accepted this revision.Dec 17 2015, 2:48 PM
echristo edited edge metadata.

This works for me as a workaround, a comment about what's going on here would probably be good.

-eric

This revision is now accepted and ready to land.Dec 17 2015, 2:48 PM
logan added a comment.Dec 20 2015, 7:28 AM

@echristo: IMO, I prefer not to add such comment for two reasons:

  1. It will obscure the main idea of this piece of code.
  1. It is common to specify the section flags (compilers will emit these flags by default as well), so it is unlikely to be removed in the future.

Besides, one can always figure out the reason by checking the commit logs.

Sure, I don't care enough either way :)

-eric

logan closed this revision.Dec 22 2015, 6:42 AM

Thanks! Committed as rL256241.