1. Host System이 제공하는 것들

  1) Cross Compiler

  2) Linker

  3) Source-level Debugger


  Target Embedded System이 제공하는 것들 

  1) Dynamic Loader

  2) Link Loader

  3) Monitor

  4) Debug Agent




2. Linker 와 Linking Process

 


  [ 위 그림 설명 ]

 1. Developer가 Program을 C/C++ Source Files과 Header Files로 작성하여 만듬 + Make Utility를 사용하기 위해 Makefiles를 작성

 2. 그 Program들의 일부는 Assembly Language로 작성되기도 한다 ( Assembly Language : low level programming language )

 3. Compiler + Assembler는 소스 코드로부터 기계어와 프로그램 데이터를 포함하고 있는 Object 파일을 생성

 4. Archive Utility는 Object file들을 연결해서 라이브러리들을 생성

 5. Linker는 이 Object files들을 입력받아 실행가능한 이미지나 다른 Object files들과 함께 링크과정에서 사용될 수 있는 Object files들을 만든다

 6. Linker command File은 Object files들을 어떻게 결합하고 바이너리 프로그램과 프로그램 데이터를 Target system에 있는 Memory의 어느곳에 배치할지 링커에게 알려줌

 



  ■ Linker의 주기능

    = Object files 들을 결합 -> 재배치 가능한 Object files  or  Shared Object files   or  최종 Executable Image




 

  ■ Global Symbols (전역심볼)

    = 전역 변수 외부 참조함수. 한 소스파일에 있는 코드가 다른 소스파일에 정의된 변수를 참조 가능 

    = Final Executable Image에서 Symbol은 Memory의 address 위치를 참조한다

     

  ■ Symbol Table 

     = Compiler가 Symbol Table을 만듬

    = Compiler가 만든 Object file의 주소 맵핑 정보가 담겨있음 

     = Global symbols들과 External Symbols 들도 담겨 있다.  ( Linker가 제대로 작동하기 위해 필요 )

 

    cf) Compile Error = C 문장의 Error    //    Linker Error = File 혹은 Global variables를 찾을 수 없는 Error


  ■ Symbol Resolution & Relocation

     1) Symbol Resolution : Linker가 각 Object file들을 검색하며 External symbols들을 정의하는 작업 (어디에서 쓰였는지) 

     2) Symbol Relocation : Linker가 Symbol들의 실제 address로 mapping하는 작업

                               이 때, 여러 object files가 합쳐지며 많은 Symbol의 상대 오프셋이 변경된다.

     3) Relocation Table : 어디에 relocation action들이 적용되었는지를 보여준다

                             이 Table을 통해 Linker는 프로그램 코드 중 어디에서 재배치 동작을 수행해야 할지 결정한다. 심볼의 실제 주소를 알아냄



3. Executable and Linking Format

   ■ Object File의 세 종류

      1) Re-locatable file : 여러 Object files를 합친 것. 심볼의 해결되지 않은 External Symbol을 포함 할 수 있다는 점이 큰 차이점.

                         다른 object file들과 링크됨


      2) Shared object File : 다른 Shared object file이나 Re-locatable object files과 link  

                           Dynamic Linking을 통한 Executable Image로 사용됨

  

  3) Executable Image File : 실행을 위해 program을 적절히 유지시킴



   ■ Object File의 형식


 Object file header

 파일크기, Binary Code, Data size, Object files 생성하기 위해 사용한 Soruce file name 등이 담겨있음

 Text Segment

 Machine - architecture - specific binary Instructions & Data 

 Data Segment 

 Relocation Information

 Symbol Table & Symbol Relocation Table

 Symbol Table 

 Debugging information

 Debugging Information



   * ELF (Object File 중 하나. 요즘 많이 쓰인다)


I. Linkable file

 ELF header

 시작 때 쓰임. 파일의 구성 : object file type, version, program, section header table's offet ..

 Program-header Table

 (optional)

 system이 어떻게 process image를 만들어 내는지 말함

 Section 1 Data

 Section : Executable File이 볼 수 있는 정보들을 담고 있음 

 (instruction, data, symbol table, relocation information)

 Section 2 Data

  .....

 Section n Data

 Section - header table

 Section들의 정보. section name, type, size, property...

 

II. Executable File


 ELF header

 Program-header Table

 Segment 1 Data

 Segment 2 Data

 ....

 Segment n Data

 Section-header table

 (optional)

 

 * Executable File 과 Linkable File이 어떻게 연관되어 있는지 나타내는 그림




4. Mapping Executable Images into Target Embedded Systems

   = Linker command(안에 linker directives) file 에서 살펴보자

   = Linker command file의 목표는 Target system에 정확하고 효율적으로 Executable image를 만드는 것이다

  

   ■ MEMORY directive 

     = Target System의 memory map을 표현하는데 쓰임

     = memory map list 들은 target system에서의 메모리 타입을 나타내며 저장이나 Executable image들을 실행시킬 수 있는 address range도 나타낸다


   ■ Section directive

     = Linker가 Symbol Resolution을 할 때 어디를 사용해야하는지 알려줌


 

'Engineering > Embedded System' 카테고리의 다른 글

1. Embedded? Real Time?  (0) 2016.03.09

+ Recent posts