COFF: Fix import symbol name mangling.
For IMPORT_NAME_NOPREFIX symbols, we should remove only one prefix character. llvm-svn: 241854
This commit is contained in:
parent
39d9efb772
commit
a841bb0f5d
|
|
@ -249,6 +249,12 @@ MachineTypes ObjectFile::getMachineType() {
|
|||
return IMAGE_FILE_MACHINE_UNKNOWN;
|
||||
}
|
||||
|
||||
StringRef ltrim1(StringRef S, const char *Chars) {
|
||||
if (!S.empty() && strchr(Chars, S[0]))
|
||||
return S.substr(1);
|
||||
return S;
|
||||
}
|
||||
|
||||
std::error_code ImportFile::parse() {
|
||||
const char *Buf = MB.getBufferStart();
|
||||
const char *End = MB.getBufferEnd();
|
||||
|
|
@ -273,10 +279,10 @@ std::error_code ImportFile::parse() {
|
|||
ExtName = Name;
|
||||
break;
|
||||
case IMPORT_NAME_NOPREFIX:
|
||||
ExtName = Name.ltrim("?@_");
|
||||
ExtName = ltrim1(Name, "?@_");
|
||||
break;
|
||||
case IMPORT_NAME_UNDECORATE:
|
||||
ExtName = Name.ltrim("?@_");
|
||||
ExtName = ltrim1(Name, "?@_");
|
||||
ExtName = ExtName.substr(0, ExtName.find('@'));
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
# CHECK: Import {
|
||||
# CHECK: Symbol: sym4 (0)
|
||||
# CHECK: Symbol: sym3 (1)
|
||||
# CHECK: Symbol: _sym3 (1)
|
||||
# CHECK: Symbol: sym1 (2)
|
||||
# CHECK: Symbol: (2)
|
||||
# CHECK: }
|
||||
|
|
@ -51,7 +51,7 @@ symbols:
|
|||
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
ComplexType: IMAGE_SYM_DTYPE_FUNCTION
|
||||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
||||
- Name: _sym3
|
||||
- Name: __sym3
|
||||
Value: 0
|
||||
SectionNumber: 0
|
||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
|
|
|
|||
Loading…
Reference in New Issue