[llvm] r289785 - Allow ELF section flags to be specified numerically
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 15 01:49:45 PST 2016
On Wed, Dec 14, 2016 at 11:59 PM, Prakhar Bahuguna via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: prakhar
> Date: Thu Dec 15 01:59:15 2016
> New Revision: 289785
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289785&view=rev
> Log:
> Allow ELF section flags to be specified numerically
>
> Summary:
> GAS already allows flags for sections to be specified directly as a
> numeric value. This functionality is particularly useful for setting
> processor or application-specific values that may not be directly
> supported or understood by LLVM. This patch allows LLVM to use numeric
> section flag values verbatim if specified by the assembly file.
>
> Reviewers: grosbach, rafael, t.p.northover, rengolin
>
> Subscribers: llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D27451
>
> Added:
> llvm/trunk/test/MC/ELF/section-numeric-flag.s
> Modified:
> llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
>
> Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=289785&r1=289784&r2=289785&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
> +++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Thu Dec 15 01:59:15 2016
> @@ -264,6 +264,10 @@ bool ELFAsmParser::ParseSectionName(Stri
> static unsigned parseSectionFlags(StringRef flagsStr, bool *UseLastGroup) {
> unsigned flags = 0;
>
> + // If a valid numerical value is set for the section flag, use it verbatim
> + if (!flagsStr.getAsInteger(0, flags))
> + return flags;
> +
> for (char i : flagsStr) {
> switch (i) {
> case 'a':
>
> Added: llvm/trunk/test/MC/ELF/section-numeric-flag.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/section-numeric-flag.s?rev=289785&view=auto
> ==============================================================================
> --- llvm/trunk/test/MC/ELF/section-numeric-flag.s (added)
> +++ llvm/trunk/test/MC/ELF/section-numeric-flag.s Thu Dec 15 01:59:15 2016
> @@ -0,0 +1,37 @@
> +// RUN: llvm-mc -filetype=obj %s -o - \
> +// RUN: | llvm-readobj -s -t | FileCheck %s
> +
> + .section .text, "0x806", %progbits, unique, 0
> + .section .comment, "0x21"
> +
> +
> +// CHECK: Section {
> +// CHECK: Name: .text (1)
We generally try to avoid the part in parenthesis ( (1) here) because
it's not guaranteed to be stable and may cause hassle down the road.
--
Davide
"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
More information about the llvm-commits
mailing list