From 61763b2022cc83062c88c05f34ac4d199ddbaf3a Mon Sep 17 00:00:00 2001 From: maniyar1 <32717947+maniyar1@users.noreply.github.com> Date: Tue, 28 Jun 2022 07:51:38 -0400 Subject: [PATCH] ld: add page (#7922) --- pages/common/ld.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 pages/common/ld.md diff --git a/pages/common/ld.md b/pages/common/ld.md new file mode 100644 index 0000000000..fee46172e1 --- /dev/null +++ b/pages/common/ld.md @@ -0,0 +1,16 @@ +# ld + +> Link object files together. +> More information: . + +- Link a specific object file with no dependencies into an executable: + +`ld {{path/to/file.o}} --output {{path/to/output_executable}}` + +- Link two object files together: + +`ld {{path/to/file1.o}} {{path/to/file2.o}} --output {{path/to/output_executable}}` + +- Dynamically link an x86_64 program to glibc (file paths change depending on the system): + +`ld --output {{path/to/output_executable}} --dynamic-linker /lib/ld-linux-x86-64.so.2 /lib/crt1.o /lib/crti.o -lc {{path/to/file.o}} /lib/crtn.o`