사용자 도구

사이트 도구


c_ctr0

모든 프로그램은 그 프로그램의 시작점(entry point)을 가지고 있다. 예를 들어, c, c++, java 언어의 시작점은 main() 이며, c#의 경우에는 Main()이 된다. 대부분의 언어는 1개의 시작점을 가지고 있게 되며, 어떤 언어들은 다수개의 시작점을 갖기도 한다. 프로그램의 시작점 이전에는 과연 무슨 일들이 일어나고 어떤 녀석들이 있을까?

c언어를 살펴 본다면, ctr0 (c runtime zero)라고 하는 녀석이 있다. 이 녀석은 main()가 시작되기 이전에, c 프로그래밍에 필요한 이것저것들을 초기화하는 역활을 담당한다. 위키디피아의 설명을 빌리자면, ctr0는 다음과 같은 역할을 한다.

crt0 (also known as c0) is a set of execution startup routines linked into a C program that performs any initialization work required before calling the program's main function.

crt0 contains the most basic parts of the runtime library. As such, the exact work it performs depends on the program's compiler, operating system and C standard library implementation. Beside the initialization work required by the environment and toolchain, crt0 can perform additional operations defined by the programmer, such as executing C++ global constructors and C functions carrying the GCC's attribute.

위의 설명과 같이 crt0는 런타임 라이브러리(runtime library) 프로그램 라이브러리(program library)와는 틀린 거다 헤깔리지 말자 – 이다 (혹은 일부분이다). 런타임 라이브러리는 프로그램이 실행되는 런타임 환경을 제공하기 위해 사용 되기에 컴파일러, 운영체제, 사용하는 c 언어 라이브러리에 따라서 달라 질 수 있다. 예를 들어, 런타임 라이브러리는 메모리 관리나 에러처리를 위한 내부함수을 제공한다.

c_ctr0.txt · 마지막으로 수정됨: 2015/04/14 09:57 (바깥 편집)