This is an archive of the discontinued LLVM Phabricator instance.

[MC][ELF] compute entity size for explicit sections
ClosedPublic

Authored by nickdesaulniers on Oct 9 2018, 5:25 PM.

Details

Summary

Global variables might declare themselves to be in explicit sections.
Calculate the entity size always to prevent assembler warnings
"entity size for SHF_MERGE not specified" when sections are to be
marked merge-able.

Fixes PR31828.

Diff Detail

Repository
rL LLVM

Event Timeline

nickdesaulniers created this revision.Oct 9 2018, 5:25 PM
nickdesaulniers retitled this revision from [MC][ELF] compute entity size for global variables to [MC][ELF] compute entity size for explicit sections.Oct 9 2018, 5:36 PM
nickdesaulniers edited the summary of this revision. (Show Details)
  • prefer temporary to local
rnk accepted this revision.Oct 10 2018, 1:20 PM

lgtm

This revision is now accepted and ready to land.Oct 10 2018, 1:20 PM
This revision was automatically updated to reflect the committed changes.

Thanks for the code review.

This seems to be failing for other arch's: http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/4325/steps/ninja%20check%201/logs/FAIL%3A%20LLVM%3A%3Asection_mergeable_size.ll

@rnk , does the CHECK need to match the full line, or is the .text appearing in the test cases problematic?

@MaskRay fixed in r344206. Thanks!

fhahn added a subscriber: fhahn.Oct 11 2018, 3:42 AM

Looks like the test fails on MacOS: http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/54057/console

Error message:

LLVM ERROR: Global variable 'a' has an invalid section specifier '.init.rodata': mach-o section specifier requires a segment and section separated by a comma.

Not sure how to work around this, short of making it target specific?

Thanks for the report, and sorry for adding a red test on OSX. The name of the section is not the important part (it could be called "foo") of the test, just that it have a custom section. The IR from the test is from real code from the Linux kernel. If the format from the error a segment and section separated by a comma is valid on Linux, then that should be fine. But I guess then this issue pops up again for Windows, or anywhere else that doesn't use ELF? So this probably should be made into an ELF only test.

I'll look into how to do that, but appreciate any tips.

I should probably remove my added test file, and merge the test case into test/MC/ELF/entsize.ll.

I should probably remove my added test file, and merge the test case into test/MC/ELF/entsize.ll.

SGTM, if the code can be tested using llvm-mc.