Stream: cranelift

Topic: PIE warnings when linking


view this post on Zulip ThatsNoMoon (Oct 14 2021 at 23:49):

hiya, I'm making a toy compiler with cranelift, and I'm running into this error

/usr/sbin/ld: out.o: warning: relocation against `exit@@GLIBC_2.2.5' in read-only section `.text'
/usr/sbin/ld: warning: creating DT_TEXTREL in a PIE

I can, I guess, just ignore these, since my executable works anyway, but I'd like to address it eventually. what's the best way to do that? from what I can gather, it seems I need cranelift to generate calls to library functions differently, but I'm not sure how to accomplish that. or maybe I need to do something else entirely, not sure. I'm just linking with gcc out.o -o out, but I did try -fno-pie and it produced the same error

view this post on Zulip Chris Fallin (Oct 15 2021 at 00:07):

Hi @ThatsNoMoon, I'm not completely sure how the linkage works in the static-AOT case, but @bjorn3 might know better (how does cg_clif generate external symbol refs)?

view this post on Zulip bjorn3 (Oct 15 2021 at 08:14):

cg_clif simply uses declare_function with Linkage::Import.

view this post on Zulip bjorn3 (Oct 15 2021 at 08:15):

https://github.com/bjorn3/rustc_codegen_cranelift/blob/b2fed29e1a421c9eb9ebe188933db13ab1819925/src/abi/mod.rs#L71

Cranelift based backend for rustc. Contribute to bjorn3/rustc_codegen_cranelift development by creating an account on GitHub.

view this post on Zulip ThatsNoMoon (Oct 15 2021 at 16:49):

bjorn3 said:

cg_clif simply uses declare_function with Linkage::Import.

that's also what I did... do you think I might need to link differently? I wish I knew more about how linking works lol

view this post on Zulip bjorn3 (Oct 16 2021 at 11:32):

Is the code available somewhere?

view this post on Zulip bjorn3 (Oct 16 2021 at 14:18):

Do you set the is_pic flag when building the TargetIsa?

view this post on Zulip bjorn3 (Oct 16 2021 at 14:18):

https://github.com/bjorn3/rustc_codegen_cranelift/blob/b2fed29e1a421c9eb9ebe188933db13ab1819925/src/lib.rs#L239

Cranelift based backend for rustc. Contribute to bjorn3/rustc_codegen_cranelift development by creating an account on GitHub.

view this post on Zulip ThatsNoMoon (Oct 22 2021 at 21:19):

sorry for the late reply, I had to fix a lot of other things before I could get back to this, but that fixed it! thanks!


Last updated: Oct 23 2024 at 20:03 UTC