This is an archive of the discontinued LLVM Phabricator instance.

Print numeric section flag for OS/processor specific bits

Authored by prakhar on Dec 20 2016, 6:11 AM.



When outputting assembly, any OS or processor-specific flags cannot be
represented by symbolic letters, so these are lost in the generated
assembly. This patch therefore prints out the flags in numeric form if
any of these bits are set. This is compatible with how GAS handles
unknown flags, and allows the generation of assembly that can be read by

Event Timeline

prakhar updated this revision to Diff 82103.Dec 20 2016, 6:11 AM
prakhar retitled this revision from to Print numeric section flag for OS/processor specific bits.
prakhar updated this object.
prakhar added reviewers: grosbach, rengolin.
prakhar added a subscriber: llvm-commits.
prakhar set the repository for this revision to rL LLVM.Dec 20 2016, 6:13 AM
rengolin requested changes to this revision.Dec 22 2016, 10:34 AM
rengolin edited edge metadata.

Wait, but we do know those flags, so it doesn't make sense to handle as unknown just because GAS does it.

We should support reading both numeric and textual versions, but it makes no sense to emit unknown.

This revision now requires changes to proceed.Dec 22 2016, 10:34 AM

None of the other target-specific flags have textual representations though, and the y symbol for ARM pure code was a proposal that was ultimately rejected. Hence, if these flags are present in the code, their information will be lost in the assembler output as they do not have a textual representation. It is therefore safer to default to a numeric representation that is already understood by both toolchains if these flags are present.

Ping for this review

@rengolin Ping again for this review

Hi Phrakar. I think you mean that there are no processor or OS specific flags with textual representation. But yes, SHF_ARM_PURECODE is the first of its kind. Makes me wonder if we are better of not having a textual representation at all for the flag.


I believe that the right style is to give the whole if-else has curly braces ("{", "}") or none. Since you need it at the else clause, you have to add it here as well.

prakhar updated this revision to Diff 85873.Jan 26 2017, 1:39 AM
prakhar edited edge metadata.

Style and formatting fix

prakhar marked an inline comment as done.Jan 26 2017, 1:43 AM

Yes, since no other OS/processor specific flag has a text equivalent, it might be better to not emit one for purecode at all. This is independent of the fact that these flags are being lost in the assembler output as LLVM currently does not emit them in numeric form.

prakhar abandoned this revision.Feb 21 2017, 12:32 AM

Abandoning as this is now being handled in