Closed
Description
I tried this code:
#[link(name = "api-ms-win-core-synch-l1-2-0", kind = "raw-dylib", import_name_type = "undecorated")]
extern "system" {
pub fn WakeByAddressSingle(address: *const c_void);
}
In WIndws x86, the symbol name that should be generated should be: __imp__WakeByAddressSingle@4
But, the symbol name of the rust generation is: __imp_WakeByAddressSingle
.
When generating the lib, the symbol name should remain __imp__WakeByAddressSingle@4
, just set the IMPORT_OBJECT_HEADER::NameType
property to IMPORT_NAME_UNDECORATE
. Then the linker will automatically convert the name to WakeByAddressSingle
.
// Windows SDK(winnt.h)
typedef struct IMPORT_OBJECT_HEADER {
WORD Sig1; // Must be IMAGE_FILE_MACHINE_UNKNOWN
WORD Sig2; // Must be IMPORT_OBJECT_HDR_SIG2.
WORD Version;
WORD Machine;
DWORD TimeDateStamp; // Time/date stamp
DWORD SizeOfData; // particularly useful for incremental links
union {
WORD Ordinal; // if grf & IMPORT_OBJECT_ORDINAL
WORD Hint;
} DUMMYUNIONNAME;
WORD Type : 2; // IMPORT_TYPE
WORD NameType : 3; // IMPORT_NAME_TYPE
WORD Reserved : 11; // Reserved. Must be zero.
} IMPORT_OBJECT_HEADER;