From efa8076c29f8306f3b683d9423e0164e9c9af870 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 1 May 2014 22:44:42 +0000 Subject: [PATCH] [PECOFF] Drop stdcall's atsign suffix only. You can omit @number suffix when specifying /export option, but you can do that only for stdcall functions. llvm-svn: 207809 --- lld/lib/ReaderWriter/PECOFF/EdataPass.cpp | 6 ++++-- lld/test/pecoff/Inputs/export.obj.yaml | 10 ++++++++++ lld/test/pecoff/export.test | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lld/lib/ReaderWriter/PECOFF/EdataPass.cpp b/lld/lib/ReaderWriter/PECOFF/EdataPass.cpp index a0475301c866..8d6424138e72 100644 --- a/lld/lib/ReaderWriter/PECOFF/EdataPass.cpp +++ b/lld/lib/ReaderWriter/PECOFF/EdataPass.cpp @@ -46,7 +46,9 @@ static void assignOrdinals(PECOFFLinkingContext &ctx) { ctx.getDllExports().swap(exports); } -static StringRef removeAtSignSuffix(StringRef sym) { +static StringRef removeStdcallSuffix(StringRef sym) { + if (!sym.startswith("_")) + return sym; StringRef trimmed = sym.rtrim("0123456789"); if (sym.size() != trimmed.size() && trimmed.endswith("@")) return trimmed.drop_back(); @@ -63,7 +65,7 @@ static bool getExportedAtoms(PECOFFLinkingContext &ctx, MutableFile *file, std::vector &ret) { std::map definedAtoms; for (const DefinedAtom *atom : file->defined()) - definedAtoms[removeAtSignSuffix(atom->name())] = atom; + definedAtoms[removeStdcallSuffix(atom->name())] = atom; std::set exports; for (PECOFFLinkingContext::ExportDesc desc : ctx.getDllExports()) { diff --git a/lld/test/pecoff/Inputs/export.obj.yaml b/lld/test/pecoff/Inputs/export.obj.yaml index c1c8fcd300b4..cd961862e411 100644 --- a/lld/test/pecoff/Inputs/export.obj.yaml +++ b/lld/test/pecoff/Inputs/export.obj.yaml @@ -7,6 +7,10 @@ sections: Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 4 SectionData: B800000000506800000000680000000050E80000000050E800000000 + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 2147483648 + SectionData: 2f6578706f72743a6578706f7274666e334032353600 # /export:exportfn3@256 symbols: - Name: .text Value: 0 @@ -38,4 +42,10 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: exportfn3@256 + Value: 16 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL ... diff --git a/lld/test/pecoff/export.test b/lld/test/pecoff/export.test index 7195d07cbbdd..ed3a88a855ae 100644 --- a/lld/test/pecoff/export.test +++ b/lld/test/pecoff/export.test @@ -39,3 +39,4 @@ CHECK4: DLL name: export.test.tmp4.dll CHECK4: Ordinal RVA Name CHECK4-NEXT: 5 0x2008 exportfn1 CHECK4-NEXT: 6 0x2010 exportfn2 +CHECK4-NEXT: 7 0x2010 exportfn3@256