리눅스 가상 주소 할당 관련

erasmooth의 이미지

mm_struct에서 start_code, start_data 등의 가상메모리 영역 변수와
vm_area_struct의 vm_start, vm_end
그리고
ELF 파일의 헤더에 기록되어 있는 SECTION 시작가상주소의 관계가 어떻게 되나요?

ELF의 section 시작가상주소는 link 시에 미리 정해지는 것이고
ELF가 RAM에 로드될 시에 이 가상주소가 PAGE FRAME주소와 함께 PAGE TABLE에 기록되어 나중에 태스크가 참조하여 변환이 이루어지는 것으로 알고 있습니다.
그렇다면 이미 실행이미지는 로드 되기도 전에 가상주소가 할당되어 있는 것인데
커널이 태스크 생성 시 만든 가상주소공간(mm_struct)에서 사용가능한 영역 할당(vm_area_struct)을 하는 의미가 없어지는거 같습니다.

kerino의 이미지

>ELF의 section 시작가상주소는 link 시에 미리 정해지는 것이고
>ELF가 RAM에 로드될 시에 이 가상주소가 PAGE FRAME주소와 함께 PAGE TABLE에 기록되어 나중에 태스크가 참조하여 변환이 이루어지는 것으로 알고 있습니다.
>그렇다면 이미 실행이미지는 로드 되기도 전에 가상주소가 할당되어 있는 것인데
>커널이 태스크 생성 시 만든 가상주소공간(mm_struct)에서 사용가능한 영역 할당(vm_area_struct)을 하는 의미가 없어지는거 같습니다.

ELF section 시작가상주소(?)는 ELF image내의 offset을 가르킬 뿐, 메모리에 loading 되는 가상주소를 의미하지 않습니다.
code에 해당하는 vma 를 확인해 볼 수는 있겠으나 모든 vma가 ELF image의 section에 1:1 매핑되지는 않습니다.
실제 ELF image가 메모리에 loading 될 경우에, ELF의 code section에 해당하는 vma 뿐만 아니라 stack, heap 혹은 device를 위한 vma들이 할당됩니다.

또한, ELF image가 loading되어 코드 수행중에 process가 생성되거나 쓰레드가 생성된다면 vma와 ELF 섹션은 많이 다른 형태가 되겠지요.

실제 타겟상에서 프로그램을 실행시켜 maps 정보를 확인하면 도움이 되실것 같습니다.

#> cat /proc/pid/maps

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.