Skip to content
Search

GNU Binutils

lastmod 2021-12-09created 2014-09-2517 edits

Detailed list of GNU Binary Utilities

The GNU Binary Utilities, or GNU Binutils, are a collection of programming tools for manipulating various kinds of object file formats. The current version was written from scratch by programmers at Cygnus Solutions using the BFD library. They are typically used together with GCC, make, and GDB.

Dynamic libraries (so) and static libraries (a)

static library

Applied at compile time. The extension is .a. Instead of using shared library routines during compilation, the program is compiled so that it holds a copy of the library routines in the program source.
It is created as follows.

gcc -c source1.c source2.c # Object 코드 만들
ar r libStatic.a source1.o source2.o # 라이브러리 만들기
ranlib libStatic.a # 라이브러리 자체 루틴 정보추가 과정
ar rs libStatic.a source1.o source2.o # 라이브러리 만들기 + 인덱스 만들기 통합 명령
# 이후 각 루틴의 Signature가 exturn 형태로 선언된 헤더파일을 만든다.
gcc -I ../include -L ../lib -o main main.c -lstatic # -lstatic: 정적 라이브러리 링크

Note that if you must link a static library, you can add the .a file as shown below.

gcc -I ../include -L ../lib -o main main.c libStatic.a

Dynamic library

Easy to develop with, and the extension is .so. No recompilation needed when the library changes. When used by more than one process, it reduces memory usage and executable size.
It is created as follows.

gcc -c -fpic source1.c source2.c # 재배치 코드 생성. (-fpic, -fPIC: 공유를 위한 위치 독립적 생성)
gcc -shared -o libDynamic.so source1.o source2.o # 공유 라이브러리 생성. (인덱스 과정 불필요)
gcc -I ../include -L ../lib -o main main.c -ldynamic # 정적 라이브러리 생성과 동일. (*.a 와 *.so 가 있다면 *.so 선택적 수행)

(Note that the -fpic and -fPIC options are different. See here for details.)

Useful commands and usage

  • ldconfig: View libraries linked to a process
  • ldd: Check where libraries are located (may vary by target configuration).

Setting library paths

If libraries are located in multiple places, you can configure them in advance as follows.

$ cd /etc/local/lib
$ vi /etc/ld.so.conf
$ include /etc/ld.so.conf.d/*.conf  # /etc/ld.so.conf.d 의 모든 conf 를 include

Project List

  • ld - the GNU linker.
  • as - the GNU assembler.
  • addr2line - Converts addresses into filenames and line numbers.
  • ar - A utility for creating, modifying and extracting from archives.
  • c++filt - Filter to demangle encoded C++ symbols.
  • dlltool - Creates files for building and using DLLs.
  • gold - A new, faster, ELF only linker, still in beta test.
  • gprof - Displays profiling information.
  • nlmconv - Converts object code into an NLM.
  • nm - Lists symbols from object files.
  • objcopy - Copies and translates object files.
  • objdump - Displays information from object files.
  • ranlib - Generates an index to the contents of an archive.
  • readelf - Displays information from any ELF format object file.
  • size - Lists the section sizes of an object or archive file.
  • strings - Lists printable strings from files.
  • strip - Discards symbols.
  • windmc - A Windows compatible message compiler.
  • windres - A compiler for Windows resource files.
  • ltrace - A library call tracer

See also

Favorite site

References


  1. Devanix.tistory_com.7z ↩

  2. Using_static_and_shared_libraries_across_platforms.pdf ↩

author Zer0 sitemap