<div dir="ltr">Hi Ahmad,<br><br>I just tried a toy shared library example and it seems to work fine.<br><br><font face="monospace">$ cat test_lib.c <br><br>int foo(int a, int b) { return a * b; }<br><br></font><div><font face="monospace">$ cat CMakeLists.txt <br>project(Ahmad)<br><br>add_library(ahmad SHARED test_lib.c)<br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">$ mkdir gbuild && cd gbuild</font></div><div><font face="monospace">$ cmake .. -GNinja -DCMAKE_C_COMPILER=$(readlink -f ~/go/bin/gclang)</font></div><div><font face="monospace">$ ninja</font></div><div><font face="monospace">$ ~/go/bin/get-bc libahmad.so<br>$ llvm-dis-11 libahmad.so.bc -o=- <br>; ModuleID = 'libahmad.so.bc'<br>source_filename = "llvm-link"<br>target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"<br>target triple = "x86_64-pc-linux-gnu"<br><br>; Function Attrs: noinline nounwind optnone uwtable<br>define i32 @foo(i32 %0, i32 %1) #0 {<br> %3 = alloca i32, align 4<br> %4 = alloca i32, align 4<br> store i32 %0, i32* %3, align 4<br> store i32 %1, i32* %4, align 4<br> %5 = load i32, i32* %3, align 4<br> %6 = load i32, i32* %4, align 4<br> %7 = mul nsw i32 %5, %6<br> ret i32 %7<br>}<br>...</font></div><div><br></div><div>-Jakub</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 23, 2021 at 4:55 PM Ahmad Nouralizadeh Khorrami <<a href="mailto:ahmad.llvm@gmail.com">ahmad.llvm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">So, is static linking the only solution? In some cases, static linking is difficult!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 24 Apr 2021 at 01:16, Jakub (Kuba) Kuderski <<a href="mailto:kubakuderski@gmail.com" target="_blank">kubakuderski@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I haven't used gllvm with shared objects and don't know the details. But on high-level, I think that even if your build system produces multiple binaries/libraries, you should be able to extract bitcode out of each of them, and later link it manually. This obviously won't work for libraries that you can't build by yourself. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 23, 2021 at 4:40 PM Ahmad Nouralizadeh Khorrami <<a href="mailto:ahmad.llvm@gmail.com" target="_blank">ahmad.llvm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Jakub,<div>Thanks! IIUC, both gllvm and wllvm work on statically linked objects. I mean they work when everything is contained in the linked bitfile. Therefore, probably, they won't solve the problem?!</div><div>Regards.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 24 Apr 2021 at 00:43, Jakub (Kuba) Kuderski <<a href="mailto:kubakuderski@gmail.com" target="_blank">kubakuderski@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Ahmad,<br><br>Maybe gllvm would work for this use case? There was a similar thread in 2019: <a href="https://lists.llvm.org/pipermail/llvm-dev/2019-January/129587.html" target="_blank">https://lists.llvm.org/pipermail/llvm-dev/2019-January/129587.html</a>.<br><br>-Jakub</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 23, 2021 at 4:02 PM Ahmad Nouralizadeh Khorrami via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div>Typical whole program IR level analyses are done by means of module passes. The modules should be linked before the analysis process.</div><div>In some rare cases, the analysis needs to be performed across the whole user level code. In other words, suppose that the bitcode files for the program and all shared libraries are available. Also, suppose that the libraries can not be linked, statically. Is it possible to run an analysis (e.g., taint analysis or constant propagation) on the whole user level software stack (at the IR level)? If not, is there any better approach?</div><div>Regards.</div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>Jakub Kuderski</div></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>Jakub Kuderski</div></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div>Jakub Kuderski</div></div>