[COFF] Autoexport symbols as data if they don't point to an executable section

This was already taken care of for the output def file.

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

llvm-svn: 317367
This commit is contained in:
Martin Storsjo 2017-11-03 20:58:20 +00:00
parent 34eb96b03f
commit dc95dbfcab
2 changed files with 14 additions and 0 deletions

View File

@ -1244,6 +1244,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
Export E;
E.Name = Def->getName();
E.Sym = Def;
if (Def->getChunk() &&
!(Def->getChunk()->getPermissions() & IMAGE_SCN_MEM_EXECUTE))
E.Data = true;
Config->Exports.push_back(E);
});
}

View File

@ -4,17 +4,28 @@
# RUN: lld-link -lldmingw -dll -out:%t.dll -entry:DllMainCRTStartup@12 %t.obj -implib:%t.lib
# RUN: llvm-readobj -coff-exports %t.dll | FileCheck %s
# RUN: llvm-readobj %t.lib | FileCheck -check-prefix=IMPLIB %s
# CHECK-NOT: Name: DllMainCRTStartup
# CHECK: Name: dataSym
# CHECK: Name: foobar
# IMPLIB: Symbol: __imp__dataSym
# IMPLIB-NOT: Symbol: _dataSym
# IMPLIB: Symbol: __imp__foobar
# IMPLIB: Symbol: _foobar
.global _foobar
.global _DllMainCRTStartup@12
.global _dataSym
.text
_DllMainCRTStartup@12:
ret
_foobar:
ret
.data
_dataSym:
.int 4
# Test specifying -export-all-symbols, on an object file that contains
# dllexport directive for some of the symbols.