OSDN Git Service

[MC] Handle discardable COFF sections in assembly
authorReid Kleckner <rnk@google.com>
Wed, 14 Sep 2016 22:41:50 +0000 (22:41 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 14 Sep 2016 22:41:50 +0000 (22:41 +0000)
commita984fc7c9a486a5000fd5bc2a193e82f3cee5660
tree4b96d8bea4dda69da616787ea93b4796781f5ae2
parenta364825f51384b1a5a532e4759551219549bd6bd
[MC] Handle discardable COFF sections in assembly

Summary:
This fixes a dumpbin warning on objects produced by the MC assembler
when starting from text. All .debug$S sections are supposed to be marked
IMAGE_SCN_MEM_DISCARDABLE. The main, non-COMDAT .debug$S section had
this set, but any comdat ones were not being marked discardable because
there was no .section flag for it.

This change does two things:

- If the section name starts with .debug, implicitly mark the section as
  discardable. This means we do the same thing as gas on .s files with
  DWARF from GCC, which is important.

- Adds the 'D' flag to the .section directive on COFF to explicitly say
  a section is discardable. We only emit this flag if the section name
  does not start with .debug. This allows the user to explicitly tweak
  their section flags without worrying about magic section names.

The only thing you can't do in this scheme is to create a
non-discardable section with a name starting with ".debug", but
hopefully users don't need that.

Reviewers: majnemer, rafael

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D24582

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281554 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/MC/MCSectionCOFF.h
lib/MC/MCParser/COFFAsmParser.cpp
lib/MC/MCSectionCOFF.cpp
test/MC/COFF/section.s