heap stack bss 와 같은 메모리 영역에서 bss 메모리 영역에 대

mr8의 이미지

지금 보안관련해서 bss 영역을 어떻게 이용해 볼까 생각중인데

예를들어, busybox같은 엠베디드용 쉘에서 bss 영역에 버퍼 메모리를 할당
하는 정책이 있던데, 아직 소스분석이 완전치 못한 상황이라서 이해가 어려워서
도움을 요청합니다.

bss 영역에 메모리 버퍼를 할당하는 방법이 존재하는 한다것은 알겠는데(busybox의 예)

현재 짧은 지식으로 초기화 되지 않은 전역 static 변수가 bss 영역에 담기는 것으로 알고 있는데, 커널이 자동으로 0으로 초기화 시켜주고...

제가 알고 싶은 부분은, 메모리 버퍼를 bss 영역에 할당하는 방법입니다.

busybox에서 제시하는 bss 영역에 메모리 버퍼 할당이 차후 busybox를
이용해 엠베디드 작업을 수행할때~

전역/로컬/초기화등등에 상관없이 메모리 버퍼가 bss 영역에 담기는 것인지
아니면 단순히 busbox 소스자체의 영역할당인지 궁금합니다.

aqwerf의 이미지

mr8 wrote:
제가 알고 싶은 부분은, 메모리 버퍼를 bss 영역에 할당하는 방법입니다.

busybox에서 제시하는 bss 영역에 메모리 버퍼 할당이 차후 busybox를
이용해 엠베디드 작업을 수행할때~

전역/로컬/초기화등등에 상관없이 메모리 버퍼가 bss 영역에 담기는 것인지
아니면 단순히 busbox 소스자체의 영역할당인지 궁금합니다.

busybox에서의 bss에 memory buffer할당은 특별한 것은 없습니다.

static int buffer[10]; 처럼 static 으로 버퍼를 잡아 bss에 잡히도록 하는것입니다. 이렇게 하면 항상 bss section에 잡히게 됩니다.

이와 같이 bss에 잡으면 malloc 처럼 heap에 필요시 마다 allocation하는 것보다 다음과 같은 장점이 있을겁니다.
- allocation overhead가 작다.
- 뒷처리(free)가 필요없다.

물론 이와 같이 bss에 잡으면 초기에 모든 메모리가 할당되어 memory가 많이 소요된다는 단점이 있지만 MMU가 있는 linux에서는 사용전까지는 실제로 메모리에 할당이 되지 않으므로 memory 용량은 malloc에 비하여 큰 차이가 나지 않아 결국 overhead가 적다는 장점이 생기게 됩니다. MMU가 없다면 메모리가 실제로 초기에 할당이 되므로 malloc이 훨씬 낫구요.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.