요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
1
.. SPDX-License-Identifier: GPL-2.0
3
==================================
4
x86-specific ELF Auxiliary Vectors
5
==================================
7
This document describes the semantics of the x86 auxiliary vectors.
9
Introduction
10
============
12
ELF Auxiliary vectors enable the kernel to efficiently provide
13
configuration-specific parameters to userspace. In this example, a program
14
allocates an alternate stack based on the kernel-provided size::
16
#include <sys/auxv.h>
17
#include <elf.h>
18
#include <signal.h>
19
#include <stdlib.h>
20
#include <assert.h>
21
#include <err.h>
23
#ifndef AT_MINSIGSTKSZ
24
#define AT_MINSIGSTKSZ 51
25
#endif
27
....
28
stack_t ss;
30
ss.ss_sp = malloc(ss.ss_size);
31
assert(ss.ss_sp);
33
ss.ss_size = getauxval(AT_MINSIGSTKSZ) + SIGSTKSZ;
34
ss.ss_flags = 0;
36
if (sigaltstack(&ss, NULL))
37
err(1, "sigaltstack");
40
The exposed auxiliary vectors
41
=============================
43
AT_SYSINFO is used for locating the vsyscall entry point. It is not
44
exported on 64-bit mode.
46
AT_SYSINFO_EHDR is the start address of the page containing the vDSO.
48
AT_MINSIGSTKSZ denotes the minimum stack size required by the kernel to
49
deliver a signal to user-space. AT_MINSIGSTKSZ comprehends the space
50
consumed by the kernel to accommodate the user context for the current
51
hardware configuration. It does not comprehend subsequent user-space stack
52
consumption, which must be added by the user. (e.g. Above, user-space adds
53
SIGSTKSZ to AT_MINSIGSTKSZ.)
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
ELF auxiliary vector와 alternate stack 예제
1-39이 `GPL-2.0` 문서는 x86-specific ELF auxiliary vector semantics를 설명합니다. auxiliary vector는 kernel이 configuration-specific parameter를 userspace에 효율적으로 전달하게 합니다.
다음 program은 kernel이 제공한 `AT_MINSIGSTKSZ`에 userspace의 `SIGSTKSZ`를 더해 alternate signal stack size를 정하고 `sigaltstack()`으로 등록합니다.
#include <sys/auxv.h>
#include <elf.h>
#include <signal.h>
#include <stdlib.h>
#include <assert.h>
#include <err.h>
#ifndef AT_MINSIGSTKSZ
#define AT_MINSIGSTKSZ 51
#endif
....
stack_t ss;
ss.ss_sp = malloc(ss.ss_size);
assert(ss.ss_sp);
ss.ss_size = getauxval(AT_MINSIGSTKSZ) + SIGSTKSZ;
ss.ss_flags = 0;
if (sigaltstack(&ss, NULL))
err(1, "sigaltstack");
노출되는 x86 auxiliary vector
40-53| vector | semantics |
|---|---|
| `AT_SYSINFO` | vsyscall entry point 위치를 찾습니다. 64-bit mode에서는 export하지 않습니다. |
| `AT_SYSINFO_EHDR` | vDSO를 포함하는 page의 시작 address입니다. |
| `AT_MINSIGSTKSZ` | kernel이 current hardware configuration의 user context를 수용하며 signal을 userspace에 전달하는 데 필요한 최소 stack size입니다. |
`AT_MINSIGSTKSZ`는 이후 userspace stack consumption을 포함하지 않습니다. caller가 이를 추가해야 하며 앞의 예제는 `SIGSTKSZ`를 더합니다.
요약과 해설
elf_auxvec.rst:1-53x86 ELF auxiliary vector는 vsyscall/vDSO 위치와 signal delivery에 필요한 최소 stack size를 userspace에 전달합니다. `AT_MINSIGSTKSZ`는 kernel context 공간만 포함하므로 application이 자체 stack consumption을 더해야 합니다.