Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm glad to tell you something about Part 28 #74

Open
TikaFlow opened this issue May 30, 2024 · 0 comments
Open

I'm glad to tell you something about Part 28 #74

TikaFlow opened this issue May 30, 2024 · 0 comments

Comments

@TikaFlow
Copy link

TikaFlow commented May 30, 2024

Hi, doctor:

I'm not sure if you're still following this repo, but I sincerely want to give you some response.

in Part-28, you mentioned that:

One annoyance is that I'm still calling the external C compiler cc to do the linking.
...
I assume that it should be possible to do a similar command on current Linux, but so far my Google-fu isn't enough to work this out. If you read this and know the answer, let me know!

Now I know how to link without using gcc:

Assuming we have a obj file named out.o, we can execute the following command to generate an executable file:

$ ld -o out out.o /lib/x86_64-linux-gnu/crt1.o -lc -dynamic-linker /lib64/ld-linux-x86-64.so.2
  • crt1.o is a starter which calls main
  • -lc link libc or other libs if we need
  • ld-linux-x86-64.so.2 helps to load dynamic libs

If ld-linux-x86-64.so.2 or crt1.o is not found, you may find them by locate or any other command.

I don't know if additional parameters will be needed in the future, but they do work for now.


If you see this message, please tell me it works.

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant