링킹 (Linking)

: 링킹은 여러 목적 파일(object file)들을 연결하여 실행 가능한 프로그램을 만드는 과정입니다.

링킹의 목적

링킹의 종류

Untitled

링킹

링킹 과정 (linking time)

  1. 심볼 해결(Symbol Resolution)
  2. 재배치(Relocation)
$ gcc -Wall -Werror -O2 -std=c99 -o helloworld helloworld.o

//ldd 명령어를 사용하면 실행 파일에 어떤 라이브러리가 연결되어 있는지 확인할 수 있습니다.
$ ldd helloworld
linux-vdso.so.1 (0x00007ffe34d1a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f24dacbb00)
/lib64/ld-linux-x86-64.so.2 (0x00007f24db25c000)

Binary File

ELF (Executable and Linkable Format)

: .o file a.out file .so file 을 위한 표준 파일 형식입니다. (Generic name = ELF binaries) - Object 파일도 ELF 파일이다.

ELF Object

File Format

Untitled


Linker Symbol


Untitled

Local Symbol