This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Ensure output section is also not empty in addStartEndSymbols()
AbandonedPublic

Authored by andrewng on Nov 17 2021, 9:51 AM.

Diff Detail

Event Timeline

andrewng created this revision.Nov 17 2021, 9:51 AM
andrewng requested review of this revision.Nov 17 2021, 9:51 AM
MaskRay added inline comments.Nov 17 2021, 6:33 PM
lld/test/ELF/linkerscript/pre_init_array_empty.test
1 ↗(On Diff #387971)

preinit-array-empty.test

6 ↗(On Diff #387971)
7 ↗(On Diff #387971)

Use llvm-readelf -s to check the value of __preinit_array_start.

This makes better use of a test case: not just check that the link succeeds, also catches unintended value change in the future. You can add a comment that as long as __preinit_array_start=__preinit_array_end, the exact value doesn't matter.

andrewng updated this revision to Diff 388269.Nov 18 2021, 11:07 AM

Updated to address review comments.

However, I have also uncovered a situation where an empty .preinit_array section can be emitted and in this case, this patch would result in the value of __preinit_array_start and __preinit_array_end not matching the address of the .preinit_array section. I have created D114179 as an alternative to this patch which copes with this scenario.

andrewng abandoned this revision.Nov 19 2021, 3:48 AM

Abandoned in favour of D114179.