[llvm-dev] lld-link fails to link uefi binary because of undefined symbol _fltused
James Y Knight via llvm-dev
llvm-dev at lists.llvm.org
Fri Jul 5 06:35:08 PDT 2019
This is expected behavior -- if you use floating point operations in a
source file, the _fltused symbol is mentioned in order to run the
floating-point-environment initialization routine from the MS CRT.
If you want to make a standalone binary, not linking against the CRT, you
can simply define "int _fltused = 0;" in some source file, within extern
"C" {} if you're in C++. (Note that the definition of the symbol doesn't
actually matter, since it's normally only used as a trigger to pull in the
initialization function.)
On Fri, Jul 5, 2019 at 9:13 AM Shi, Steven via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hi Rui, Peter,
>
> We meet a problem to use lld-link to generate uefi binary. It is related
> to the lld-link force to use float point lib symbol: _fltused. Uefi binary
> doesn’t use any external float point lib and we don’t know how to tell
> lld-link not to emit the float point lib symbol. Below is a simplified
> example to reproduce this issue. Please give me some advice. Thanks!
>
>
>
>
>
> $ cat main.c
>
> double v=0;
>
> void mainfunction(){
>
> v+=1;
>
> }
>
> $ ~/llvm-project/releaseinstall/bin/clang -c -Oz -flto -target
> x86_64-unknown-windows main.c -o main.ir
>
> $ ~/llvm-project/releaseinstall/bin/lld-link /machine:X64 /DLL
> /ENTRY:mainfunction main.ir /OUT:main.dll
>
> lld-link: error: undefined symbol: _fltused
>
> >>> referenced by lto.tmp
>
>
>
> Thanks
>
> Steven
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190705/89af48e6/attachment.html>
More information about the llvm-dev
mailing list