[PATCH] D30291: Handle section header flags redefinitions similar to GAS
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 23 05:20:53 PST 2017
Christof Douma via Phabricator <reviews at reviews.llvm.org> writes:
> - MCSection *ELFSection = getContext().getELFSection(
> + MCSectionELF *ELFSection = getContext().getELFSection(
> SectionName, Type, Flags, Size, GroupName, UniqueID, Associated);
> + // Sections are not identified by flags. Check if there is a mismatch in the
> + // flags requested and the flags in the section returned. If the mismatch is
> + // in OS or CPU specific flags, just add them. For any other mismatch warn
> + // the user that we are ignoring the new flags.
> + const unsigned overrideMask = (ELF::SHF_MASKOS | ELF::SHF_MASKPROC);
> + unsigned curFlags = ELFSection->getFlags();
> + curFlags |= Flags & overrideMask;
> + Flags |= curFlags & overrideMask;
> + ELFSection->setFlags(curFlags);
> + if (curFlags != Flags)
> + Warning(loc, "ignoring override of non-target sepecific section flags");
> +
> getStreamer().SwitchSection(ELFSection, Subsection);
Are you should this is an intentional behaviour? It is hard to see why
it is a good thing for MASKPROC and MASKOS to be special.
> if (getContext().getGenDwarfForAssembly()) {
>
>
> Index: test/MC/ELF/section-override-flags.s
> ===================================================================
> --- /dev/null
> +++ test/MC/ELF/section-override-flags.s
> @@ -0,0 +1,36 @@
> +// RUN: llvm-mc -filetype=obj -triple arm-pc-linux-gnu %s -o %t 2>&1 | FileCheck -check-prefix=DIAG %s
> +// RUN: llvm-readobj -s %t | FileCheck %s
> +
> +// REQUIRES: arm-registered-target
Just move the test to an ARM subdirectory.
> +// Test we handle overriding OS and PROC specific flags on the builtin .text section
> +.section .text,"0x200006",%progbits
> +.section .text,"0x40000006",%progbits
The distinction of builtin versus regular is also odd. The ELF spec has
no such terms.
> +// CHECK: Section {
> +// CHECK: Name: .text
> +// CHECK-NEXT: Type: SHT_PROGBITS (0x1)
> +// CHECK-NEXT: Flags [ (0x40200006)
> +// CHECK-NEXT: SHF_ALLOC (0x2)
> +// CHECK-NEXT: SHF_EXECINSTR (0x4)
> +// CHECK-NEXT: ]
> +
> +//Attempt to override flags that are not target specific should be ignored
> +.section foo,"ax",%progbits
> +.section foo,"0x7",%progbits
> +.section foo,"0x10000007",%progbits
> +
> +// DIAG: warning: ignoring override of non-target sepecific section flags
> +// DIAG: warning: ignoring override of non-target sepecific section flags
Test the location.
Cheers,
Rafael
More information about the llvm-commits
mailing list