← Documents Documentation/userspace-api/ELF.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API

Linux 고유 ELF 동작

Linux가 여러 PT_INTERP, PT_GNU_STACK, PT_GNU_PROPERTY header 중 어느 것을 사용하는지 설명합니다.

Source pathDocumentation/userspace-api/ELF.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

ELF.rst:1-34

Linux가 여러 PT_INTERP, PT_GNU_STACK, PT_GNU_PROPERTY header 중 어느 것을 사용하는지 설명합니다.

원문의 ABI symbol, error code, source path, 수치, code와 줄 좌표를 보존해 전문을 번역했습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 =================================
4 Linux-specific ELF idiosyncrasies
5 =================================
6
7 Definitions
8 ===========
9
10 "First" program header is the one with the smallest offset in the file:
11 e_phoff.
12
13 "Last" program header is the one with the biggest offset in the file:
14 e_phoff + (e_phnum - 1) * sizeof(Elf_Phdr).
15
16 PT_INTERP
17 =========
18
19 First PT_INTERP program header is used to locate the filename of ELF
20 interpreter. Other PT_INTERP headers are ignored (since Linux 2.4.11).
21
22 PT_GNU_STACK
23 ============
24
25 Last PT_GNU_STACK program header defines userspace stack executability
26 (since Linux 2.6.6). Other PT_GNU_STACK headers are ignored.
27
28 PT_GNU_PROPERTY
29 ===============
30
31 ELF interpreter's last PT_GNU_PROPERTY program header is used (since
32 Linux 5.8). If interpreter doesn't have one, then the last PT_GNU_PROPERTY
33 program header of an executable is used. Other PT_GNU_PROPERTY headers
34 are ignored.
35

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Program header 순서 정의

1-15

이 문서에서 첫 번째 program header는 file 안 offset이 가장 작은 header이며 그 위치는 `e_phoff`입니다.

마지막 program header는 file 안 offset이 가장 큰 header이며 위치는 `e_phoff + (e_phnum - 1) * sizeof(Elf_Phdr)`입니다.

ELF header 위치
항목설명
Firste_phoff
Laste_phoff + (e_phnum - 1) * sizeof(Elf_Phdr)

문서에서 사용하는 first와 last의 정확한 의미입니다.

.. SPDX-License-Identifier: GPL-2.0

=================================
Linux-specific ELF idiosyncrasies
=================================

Definitions
===========

"First" program header is the one with the smallest offset in the file:
e_phoff.

"Last" program header is the one with the biggest offset in the file:
e_phoff + (e_phnum - 1) * sizeof(Elf_Phdr).

PT_INTERP

16-21

첫 번째 `PT_INTERP` program header를 사용해 ELF interpreter filename을 찾습니다. Linux 2.4.11부터 나머지 `PT_INTERP` header는 무시합니다.

PT_INTERP
=========

First PT_INTERP program header is used to locate the filename of ELF
interpreter. Other PT_INTERP headers are ignored (since Linux 2.4.11).

PT_GNU_STACK

22-27

마지막 `PT_GNU_STACK` program header가 userspace stack의 executability를 정의합니다. Linux 2.6.6부터 나머지 `PT_GNU_STACK` header는 무시합니다.

PT_GNU_STACK
============

Last PT_GNU_STACK program header defines userspace stack executability
(since Linux 2.6.6). Other PT_GNU_STACK headers are ignored.

PT_GNU_PROPERTY

28-34

Linux 5.8부터 ELF interpreter의 마지막 `PT_GNU_PROPERTY` program header를 사용합니다. Interpreter에 이 header가 없으면 executable의 마지막 `PT_GNU_PROPERTY` header를 사용하고, 그 밖의 header는 무시합니다.

Linux ELF 선택 규칙
Program header선택
PT_INTERP첫 번째
PT_GNU_STACK마지막
PT_GNU_PROPERTYInterpreter의 마지막, 없으면 executable의 마지막

같은 type이 여러 개일 때 실제로 사용하는 header입니다.

PT_GNU_PROPERTY
===============

ELF interpreter's last PT_GNU_PROPERTY program header is used (since
Linux 5.8). If interpreter doesn't have one, then the last PT_GNU_PROPERTY
program header of an executable is used. Other PT_GNU_PROPERTY headers
are ignored.