This is an archive of the discontinued LLVM Phabricator instance.

[MC] Set defaults based on section names and support name suffixes
ClosedPublic

Authored by phosek on Feb 21 2017, 3:07 PM.

Details

Summary

Set correct default flags and section type based on its name for .text, .data, .bss, .init_array, .fini_array, .preinit_array, .tdata, and .tbss and support section name suffixes for .data.*, .rodata.*, .text.*, .bss.*, .tdata.* and .tbss.* which matches the behavior of GAS.

This addresses PR31888.

Diff Detail

Repository
rL LLVM

Event Timeline

phosek created this revision.Feb 21 2017, 3:07 PM

Isn't PROGBITS the default type anyway?

The GNU behavior is not startswith(".text"); it's == ".text" || startswith(".text."). Exactly analogous to the .bss cases I reported earlier.

phosek edited the summary of this revision. (Show Details)

Isn't PROGBITS the default type anyway?

The GNU behavior is not startswith(".text"); it's == ".text" || startswith(".text."). Exactly analogous to the .bss cases I reported earlier.

The .text case is handled by a directive handler (line 57) which only supports the exact match which is why this is being handled separately.

The point is you are matching ".textfoo" whereas GNU only matches ".text.foo". And I was talking about ".section .text", not ".text".,

The point is you are matching ".textfoo" whereas GNU only matches ".text.foo". And I was talking about ".section .text", not ".text".,

Got it! I'll expand the implementation to match the GAS behavior for other sections and expand the test.

phosek updated this revision to Diff 89966.Feb 27 2017, 8:05 PM
phosek retitled this revision from [MC] Mark sections whose names starts with .text as AX to [MC] Set defaults based on section names and support name suffixes.
phosek edited the summary of this revision. (Show Details)
mcgrathr accepted this revision.Mar 3 2017, 12:39 PM

It looks right to me. It would be more in keeping with the existing code to merge into each existing if rather than adding another whose then statement is identical, but that's a trivial thing.

This revision is now accepted and ready to land.Mar 3 2017, 12:39 PM
phosek updated this revision to Diff 94109.Apr 4 2017, 1:31 PM

Updated to use the new hasPrefix function. I'm fine using the existing code, my only concern are the duplicated checks for each if then condition, is that fine with you?

rafael accepted this revision.Apr 4 2017, 1:48 PM
This revision was automatically updated to reflect the committed changes.