[llvm-dev] lld-link fails to link 32bits assembly functions but 64bits pass

Shi, Steven via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 18 06:54:34 PST 2019


Hi Martin,
OK, It was my fault. I didn't set correct target when run the preprocess. Thank you very much!


Thanks
Steven 

> -----Original Message-----
> From: Martin Storsjö [mailto:martin at martin.st]
> Sent: Monday, February 18, 2019 5:07 PM
> To: Shi, Steven <steven.shi at intel.com>
> Cc: Rui Ueyama <ruiu at google.com>; 'Peter Smith'
> <peter.smith at linaro.org>; 'llvm-dev at lists.llvm.org' <llvm-
> dev at lists.llvm.org>; Gao, Liming <liming.gao at intel.com>
> Subject: RE: [llvm-dev] lld-link fails to link 32bits assembly functions but
> 64bits pass
> 
> On Mon, 18 Feb 2019, Shi, Steven wrote:
> 
> > Hi Martin,
> > Thank you for the hint.
> >
> >> For 32 bit windows, functions with cdecl calling convention (the default
> >> in C) are decorated with an underscore prefix. So you'd need to update
> >> your nasm source file to define the symbol _Foo instead of Foo. (Most
> >> assembly files use some sort of macro for wrapping this detail.)
> > Yes, my assembly files do use prefix macro (ASM_PFX) for wrapping the
> > underscore. We use the __USER_LABEL_PREFIX__ to control the prefix
> macro
> > expand to be "_" as below. I find the __USER_LABEL_PREFIX__ has been
> > predefined by clang-cl, but it is defined as nothing. That is why my
> > prefix macro expands to be nothing. Do you know why the clang-cl
> > predefines the __USER_LABEL_PREFIX__ as nothing?
> 
> It looks to me like __USER_LABEL_PREFIX__ is properly defined to an
> underscore when preprocessing with clang-cl:
> 
> $ cat userprefix.c
> __USER_LABEL_PREFIX__
> $ bin/clang-cl -E userprefix.c -m32
> # 1 "userprefix.c"
> # 1 "<built-in>" 1
> # 1 "<built-in>" 3
> # 331 "<built-in>" 3
> # 1 "<command line>" 1
> # 1 "<built-in>" 2
> # 1 "userprefix.c" 2
> _
> $ bin/clang-cl -E userprefix.c
> # 1 "userprefix.c"
> # 1 "<built-in>" 1
> # 1 "<built-in>" 3
> # 334 "<built-in>" 3
> # 1 "<command line>" 1
> # 1 "<built-in>" 2
> # 1 "userprefix.c" 2
> 
> $
> 
> So as long as I specify a x86 32 bit target, __USER_LABEL_PREFIX__ expands
> correctly to an underscore. Where do you observe differing behaviour? If
> you use (clang-)cl to preprocess your assembler files, you need make sure
> you run that preprocessor with the right target.
> 
> // Martin



More information about the llvm-dev mailing list