Annotation of htdocs/docs/kernel/elf-notes.html, revision 1.39

1.17      jym         1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1.1       dsieger     2: <html>
                      3: <head>
                      4: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
                      5: <meta name="generator" content="Website XSL Stylesheet V2.6.0">
                      6: <link rel="home" href="../../." title="Welcome to The NetBSD Project: Of course it runs NetBSD.">
                      7: <link rel="up" href="../../docs/kernel/." title="NetBSD Documentation: Kernel">
                      8: <link rel="previous" href="../../docs/kernel/porting-freebsd-net.html" title="Notes on porting FreeBSD network drivers to NetBSD">
                      9: <link rel="next" href="../../docs/mirror.html" title="NetBSD Mirror FAQ">
                     10: <link rel="first" href="../../docs/kernel/lazyfpu.html" title="NetBSD Documentation: How lazy FPU context switch works">
1.11      dsieger    11: <link rel="stylesheet" href="../../global.css" type="text/css">
1.1       dsieger    12: 
                     13: 
                     14: 
                     15: <title>NetBSD Documentation: Vendor-specific ELF Note Elements</title>
                     16: </head>
                     17: <body class="website"><div class="webpage">
1.3       dsieger    18: <a name="docs-kernel-elf-notes"></a><div id="top"><a href="#mainContent" class="doNotDisplay doNotPrint">Skip to main content.</a></div>
1.30      maya       19: <div id="centralHeader"><div id="logo">
1.21      jym        20: <a href="../../"><img alt="[NetBSD Logo]" src="../../images/NetBSD-smaller.png"></a><div id="name"><a href="../../">
1.19      jym        21:          The NetBSD Project
1.21      jym        22:        </a></div>
                     23: <div id="slogan"><a href="../../">
1.19      jym        24:          &#8220;Of course it runs NetBSD&#8221;
1.21      jym        25:        </a></div>
1.30      maya       26: </div></div>
1.31      maya       27: <input id="hamburger" type="checkbox"><label class="menuicon" for="hamburger"><span></span></label><div id="navBar" role="navigation">
1.6       dsieger    28: <span class="doNotDisplay">
                     29:          Navigation:
1.17      jym        30:        </span><ul>
                     31: <li><a href="../../">
                     32:          Home</a></li>
                     33: <li>
                     34: <a href="../../">
1.20      wiz        35:          News &amp; Media</a><ul>
1.17      jym        36: <li><a href="../../changes/">
                     37:            Recent changes</a></li>
1.33      maya       38: <li><a href="//blog.NetBSD.org/">
1.17      jym        39:            NetBSD blog</a></li>
                     40: <li><a href="../../gallery/events.html">
                     41:            Events</a></li>
                     42: <li><a href="../../changes/rss.html">
                     43:            Feeds</a></li>
                     44: </ul>
                     45: </li>
                     46: <li>
                     47: <a href="../../about/">
                     48:          About</a><ul>
                     49: <li><a href="../../about/">
                     50:            NetBSD</a></li>
1.38      maya       51: <li><a href="../../people/developers.html">
                     52:            NetBSD developers</a></li>
1.17      jym        53: <li><a href="../../gallery/">
                     54:            Advocacy</a></li>
                     55: </ul>
                     56: </li>
                     57: <li>
                     58: <a href="../../docs/">
                     59:          Documentation</a><ul>
                     60: <li><a href="../../docs/misc/index.html">
                     61:            FAQ &amp; HOWTOs</a></li>
                     62: <li><a href="../../docs/guide/en/">
                     63:            The Guide</a></li>
1.34      maya       64: <li><a href="http://man.NetBSD.org/">
1.17      jym        65:            Manual pages</a></li>
1.33      maya       66: <li><a href="//wiki.NetBSD.org/">
1.17      jym        67:            Wiki</a></li>
                     68: </ul>
                     69: </li>
                     70: <li>
                     71: <a href="../../support/">
                     72:          Support</a><ul>
                     73: <li><a href="../../support/send-pr.html">
                     74:            Problem report guide</a></li>
                     75: <li><a href="../../cgi-bin/sendpr.cgi?gndb=netbsd">
                     76:            Report a bug</a></li>
                     77: <li><a href="../../support/query-pr.html">
                     78:            Query bug database</a></li>
                     79: <li><a href="../../support/security/">
                     80:            Security</a></li>
                     81: </ul>
                     82: </li>
                     83: <li>
                     84: <a href="../../community/">
                     85:          Community</a><ul>
1.36      leot       86: <li><a href="//blog.NetBSD.org/">
                     87:            Blog</a></li>
1.17      jym        88: <li><a href="../../mailinglists/">
                     89:            Mailing lists</a></li>
1.33      maya       90: <li><a href="//mail-index.NetBSD.org/">
1.17      jym        91:            List archives</a></li>
                     92: </ul>
                     93: </li>
                     94: <li>
                     95: <a href="../../developers/">
                     96:          Developers</a><ul>
1.35      maya       97: <li><a href="http://cvsweb.NetBSD.org/">
1.17      jym        98:            Browse source</a></li>
1.33      maya       99: <li><a href="//nxr.NetBSD.org/">
1.17      jym       100:            Cross-reference</a></li>
1.33      maya      101: <li><a href="//releng.NetBSD.org/">
1.17      jym       102:            Release engineering</a></li>
1.33      maya      103: <li><a href="//wiki.NetBSD.org/projects/">
1.17      jym       104:            Projects list</a></li>
                    105: </ul>
                    106: </li>
                    107: <li>
                    108: <a href="../../ports/">
                    109:          Ports</a><ul>
                    110: <li><a href="../../ports/history.html">
                    111:            History</a></li>
                    112: <li><a href="../../ports/emulators.html">
                    113:            Emulators</a></li>
                    114: </ul>
                    115: </li>
                    116: <li>
1.33      maya      117: <a href="//www.pkgsrc.org/">
1.17      jym       118:          Packages</a><ul>
1.34      maya      119: <li><a href="http://www.pkgsrc.se/">
1.17      jym       120:            Browse packages</a></li>
1.33      maya      121: <li><a href="//releng.NetBSD.org/index-pkgsrc.html">
1.17      jym       122:            Release engineering</a></li>
                    123: </ul>
                    124: </li>
                    125: </ul>
1.3       dsieger   126: </div>
                    127: <div id="content"><div class="fullWidth"><div class="rowOfBoxes">
                    128: <h1>NetBSD Documentation: Vendor-specific ELF Note Elements</h1>
1.1       dsieger   129: <h3 class="title"><a name="introduction"></a></h3>
                    130: <ul>
                    131: <li><a href="#introduction-sub">Introduction</a></li>
                    132: <li><a href="#note-format">Format of an ELF Note Element</a></li>
                    133: <li><a href="#note-names">Known ELF Note Names</a></li>
                    134: <li><a href="#note-contents">Vendor-specific ELF Notes</a></li>
                    135: <li><a href="#note-creation">Creating ELF PT_NOTE Sections</a></li>
                    136: <li><a href="#netbsd-note">Creating a NetBSD ELF PT_NOTE Section</a></li>
                    137: </ul>
                    138: <hr>
                    139: <h3 class="title"></h3>
                    140:     <h4 class="title">
1.39    ! maya      141: <a name="introduction-sub"></a>Introduction</h4>
1.1       dsieger   142:       <p>
                    143:        Various operating system vendors are shipping ELF binaries and those
                    144:        binaries expect different system call interfaces.  In order to help
                    145:        operating systems correctly determine whether or not they can run an
                    146:        ELF program, and how to run it (e.g. what OS emulation to use), some
                    147:        operating system vendors have begun marking their ELF binaries with
                    148:        vendor-specific note elements, and placing those notes in the
                    149:        binaries' <code class="constant">PT_NOTE</code> sections.
                    150:       </p>
                    151:       <p>
                    152:        This page is meant to be a repository of knowledge about vendor-specific
                    153:        note elements used in binaries <code class="constant">PT_NOTE</code> sections for operating system
                    154:        identification.
                    155:       </p>
                    156: 
                    157:       <p>
                    158:        If your operating system uses vendor-specific note elements to
                    159:        mark its binaries and is not listed here, please send mail to
1.24      mbalmer   160:        <a class="ulink" href="mailto:netbsd-docs@NetBSD.org" target="_top">NetBSD documentation list</a>
1.1       dsieger   161:        with information about those notes.
                    162:       </p>
                    163:     
                    164:       <h4 class="title">
1.39    ! maya      165: <a name="note-format"></a>Format of an ELF Note Element</h4>
1.1       dsieger   166: 
                    167:       <p>
                    168:        All ELF Note elements have the same basic structure:
                    169:        </p>
1.22      tron      170: <div class="variablelist"><dl class="variablelist">
1.1       dsieger   171: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
                    172: <dd>4 bytes (integer)</dd>
                    173: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
                    174: <dd>4 bytes (integer)</dd>
                    175: <dt><span class="term"><code class="varname">Type</code></span></dt>
                    176: <dd>4 bytes (usually interpreted as an integer)</dd>
                    177: <dt><span class="term"><code class="varname">Name</code></span></dt>
                    178: <dd>variable size, padded to a 4 byte boundary</dd>
                    179: <dt><span class="term"><code class="varname">Desc</code></span></dt>
                    180: <dd>variable size, padded to a 4 byte boundary</dd>
                    181: </dl></div>
                    182: <p>
                    183:       </p>
                    184:       
                    185:       <p>
                    186:        The "Name Size" and "Desc Size" fields are integers (in the byte order
                    187:        specified by the binary's ELF header) which specify the size of the
                    188:        "Name" and "Desc" fields (excluding padding).
                    189:       </p>
                    190:     
                    191:       <p>
                    192:        The "Name" field specifies the vendor who defined the format of the Note.
                    193:        Typically, vendors use names which are related to their project and/or
                    194:        company names.  For instance, the GNU Project uses "GNU" as its name.
                    195:        No two vendors should use the same ELF Note Name, lest there be confusion
                    196:        when trying to interpret the meanings of notes.
                    197:       </p>
                    198:       
                    199:       <p>
                    200:        The "Type" field is vendor specific, but it is usually treated as an
                    201:        integer which identifies the type of the note.
                    202:       </p>
                    203:       
                    204:       <p>
                    205:        The "Desc" field is vendor specific, and usually contains data which
                    206:        depends on the note type.
                    207:       </p>
                    208:     
                    209:       <h4 class="title">
1.39    ! maya      210: <a name="note-names"></a>Known ELF Note Names</h4>
1.1       dsieger   211: 
                    212:       <p>
                    213:        The following are the strings known to be used as ELF Note Names, along
                    214:        with the organizations that use them.  Names with lengths that are
                    215:        not a multiples of 4 are padded in the note, but only the given length
                    216:        should be checked.
                    217:       </p>
                    218:       
                    219:       <div class="segmentedlist"><table border="0">
                    220: <thead><tr class="segtitle">
                    221: <th>Note Name String</th>
                    222: <th>Byte encoding of string</th>
                    223: <th>Length</th>
                    224: <th>Organization</th>
                    225: </tr></thead>
                    226: <tbody>
                    227: <tr class="seglistitem">
                    228:          <td class="seg"><code class="code">"NetBSD\0"</code></td>
                    229:          <td class="seg"><code class="code">0x4e 0x65 0x74 0x42 0x53 0x44 0x00</code></td>
                    230:          <td class="seg">7</td>
1.11      dsieger   231:          <td class="seg"><a class="xref" href="#note-contents-netbsd" title="The NetBSD Project">The NetBSD Project</a></td>
1.1       dsieger   232:        </tr>
                    233: <tr class="seglistitem">
1.25      mbalmer   234:          <td class="seg"><code class="code">"PaX\0"</code></td>
                    235:          <td class="seg"><code class="code">0x50 0x61 0x58 0x00</code></td>
                    236:          <td class="seg">4</td>
                    237:          <td class="seg">specific to <a class="xref" href="#note-contents-netbsd" title="The NetBSD Project">The NetBSD Project</a> ? </td>
                    238:        </tr>
                    239: <tr class="seglistitem">
1.1       dsieger   240:          <td class="seg"><code class="code">"GNU\0"</code></td>
                    241:          <td class="seg"><code class="code">0x47 0x4e 0x55 0x00</code></td>
                    242:          <td class="seg">4</td>
1.11      dsieger   243:          <td class="seg"><a class="xref" href="#note-contents-gnu" title="The GNU Project">The GNU Project</a></td>
1.1       dsieger   244:        </tr>
                    245: </tbody>
                    246: </table></div>
                    247:     
                    248:     <h4 class="title">
1.39    ! maya      249: <a name="note-contents"></a>Vendor-specific ELF Notes</h4>
1.1       dsieger   250:       
                    251:     <p>
                    252:       This section contains information about the formats of ELF notes which
                    253:       vendors use in their <code class="constant">PT_NOTE</code> sections, and is split up by vendor.
                    254:     </p>
                    255: 
1.22      tron      256:     <div class="sect4">
1.1       dsieger   257: <div class="titlepage"><div><div><h5 class="title">
                    258: <a name="note-contents-netbsd"></a>The NetBSD Project</h5></div></div></div>
                    259:       
                    260:       
                    261:       <p>
1.25      mbalmer   262:        There are four vendor-specific ELF Notes for NetBSD and the
                    263:        PaX note also included in this list, as currently it is
                    264:        not know wether it is used with other operating systems
                    265:        as well.</p>
                    266: 
                    267:       <p>The OS Version note 
                    268:        is used to indicate what OS Version
1.1       dsieger   269:        native binaries were built with, and can be used to identify native
1.25      mbalmer   270:        binaries.</p>
1.1       dsieger   271:       <p>
1.25      mbalmer   272:        The format is:
1.1       dsieger   273:        
                    274:        </p>
1.22      tron      275: <div class="variablelist"><dl class="variablelist">
1.1       dsieger   276: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
                    277: <dd>7</dd>
                    278: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
                    279: <dd>4</dd>
                    280: <dt><span class="term"><code class="varname">Type</code></span></dt>
                    281: <dd>4-byte integer containing the value <code class="code">0x01</code>
                    282: </dd>
                    283: <dt><span class="term"><code class="varname">Name</code></span></dt>
                    284: <dd>
                    285: <code class="code">"NetBSD\0"</code> (padded to 8 bytes)</dd>
                    286: <dt><span class="term"><code class="varname">Desc</code></span></dt>
                    287: <dd>4-byte integer containing the NetBSD OS version constant</dd>
                    288: </dl></div>
                    289: <p>
                    290:       </p>
                    291: 
                    292:       <p>
1.25      mbalmer   293:        The Emulation Name note is used to mark binaries (both native an non-native) with
                    294:        a name that indicates which set of binary emulation code is to be used
                    295:        when they are run.</p>
                    296:       <p>
                    297:        The format is:
1.1       dsieger   298:        </p>
1.22      tron      299: <div class="variablelist"><dl class="variablelist">
1.1       dsieger   300: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
                    301: <dd>7</dd>
                    302: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
                    303: <dd>variable</dd>
                    304: <dt><span class="term"><code class="varname">Type</code></span></dt>
                    305: <dd>4-byte integer containing the value <code class="code">0x02</code>
                    306: </dd>
                    307: <dt><span class="term"><code class="varname">Name</code></span></dt>
                    308: <dd>
                    309: <code class="code">"NetBSD\0"</code> (padded to 8 bytes)</dd>
                    310: <dt><span class="term"><code class="varname">Desc</code></span></dt>
                    311: <dd>
                    312: <code class="code">NUL</code>-terminated string naming the
                    313:            emulation to be used to run the binary
                    314:            (padded to the next 4-byte boundary)</dd>
                    315: </dl></div>
                    316: <p>
                    317:       </p>
1.24      mbalmer   318: 
                    319:       <p>
1.25      mbalmer   320:        The PaX note encodes execution protection and addrss space
                    321:        layout randomization flags.</p>
                    322:       <p>
                    323:        The format is:
1.24      mbalmer   324:        
                    325:        </p>
                    326: <div class="variablelist"><dl class="variablelist">
                    327: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
                    328: <dd>4</dd>
                    329: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
                    330: <dd>4</dd>
                    331: <dt><span class="term"><code class="varname">Type</code></span></dt>
                    332: <dd>4-byte integer containing the value <code class="code">0x03</code>
                    333: </dd>
                    334: <dt><span class="term"><code class="varname">Name</code></span></dt>
1.25      mbalmer   335: <dd><code class="code">"PaX\0"</code></dd>
1.24      mbalmer   336: <dt><span class="term"><code class="varname">Desc</code></span></dt>
                    337: <dd>4-byte bitmask with the following bits:
                    338:            <div class="segmentedlist"><table border="0">
                    339: <thead><tr class="segtitle">
                    340: <th>Bit</th>
                    341: <th>Meaning</th>
                    342: </tr></thead>
                    343: <tbody>
                    344: <tr class="seglistitem">
                    345:                <td class="seg"><code class="code">0x01</code></td>
                    346:                <td class="seg">Force enable Mprotect</td>
                    347:              </tr>
                    348: <tr class="seglistitem">
                    349:                <td class="seg"><code class="code">0x02</code></td>
                    350:                <td class="seg">Force disable Mprotect</td>
                    351:              </tr>
                    352: <tr class="seglistitem">
                    353:                <td class="seg"><code class="code">0x04</code></td>
                    354:                <td class="seg">Force enable Segvguard</td>
                    355:              </tr>
                    356: <tr class="seglistitem">
                    357:                <td class="seg"><code class="code">0x08</code></td>
                    358:                <td class="seg">Force disable Segvguard</td>
                    359:              </tr>
                    360: <tr class="seglistitem">
                    361:                <td class="seg"><code class="code">0x10</code></td>
                    362:                <td class="seg">Force enable ASLR</td>
                    363:              </tr>
                    364: <tr class="seglistitem">
                    365:                <td class="seg"><code class="code">0x20</code></td>
                    366:                <td class="seg">Force disable ASLR</td>
                    367:              </tr>
                    368: </tbody>
                    369: </table></div>
                    370:            </dd>
                    371: </dl></div>
                    372: <p>
                    373:       </p>
                    374: 
                    375:       <p>
1.25      mbalmer   376:        The Architecture Note encodes machine architecture details.</p>
                    377:       <p>
                    378:        The format is:
1.24      mbalmer   379:        
                    380:        </p>
                    381: <div class="variablelist"><dl class="variablelist">
                    382: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
                    383: <dd>7</dd>
                    384: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
                    385: <dd>variable</dd>
                    386: <dt><span class="term"><code class="varname">Type</code></span></dt>
                    387: <dd>4-byte integer containing the value <code class="code">0x05</code>
                    388: </dd>
                    389: <dt><span class="term"><code class="varname">Name</code></span></dt>
                    390: <dd>
                    391: <code class="code">"NetBSD\0"</code> (padded to 8 bytes)</dd>
                    392: <dt><span class="term"><code class="varname">Desc</code></span></dt>
                    393: <dd>A string describing the architecture the binary was
                    394:                      compiled for (for example used on ARM to distinguish
                    395:                      hardware floating point ABI and softfloat)</dd>
                    396: </dl></div>
                    397: <p>
                    398:       </p>
                    399: 
                    400:       <p>
1.25      mbalmer   401:        The Code Model Note encodes code model details.</p>
                    402:       <p>
                    403:        The format is:
1.24      mbalmer   404:        
                    405:        </p>
                    406: <div class="variablelist"><dl class="variablelist">
                    407: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
                    408: <dd>7</dd>
                    409: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
                    410: <dd>variable</dd>
                    411: <dt><span class="term"><code class="varname">Type</code></span></dt>
                    412: <dd>4-byte integer containing the value <code class="code">0x06</code>
                    413: </dd>
                    414: <dt><span class="term"><code class="varname">Name</code></span></dt>
                    415: <dd>
                    416: <code class="code">"NetBSD\0"</code> (padded to 8 bytes)</dd>
                    417: <dt><span class="term"><code class="varname">Desc</code></span></dt>
                    418: <dd>A string describing the code model the binary was
                    419:                      compiled for. Used for example on sparc64 to tell
                    420:                      binaries compiled with -mcmodel=medlow apart from
1.25      mbalmer   421:                      standard (-mcmodel=medmid) ones, because the former
1.24      mbalmer   422:                      are not eligible for top-down virtual memory
                    423:                      layout.</dd>
                    424: </dl></div>
                    425: <p>
                    426:       </p>
                    427: 
1.1       dsieger   428:     </div>
                    429: 
1.22      tron      430:     <div class="sect4">
1.1       dsieger   431: <div class="titlepage"><div><div><h5 class="title">
                    432: <a name="note-contents-gnu"></a>The GNU Project</h5></div></div></div>
                    433:       
                    434: 
                    435:       <p>
                    436:        Starting with glibc 2.1, the GNU project will be using a single ELF Note
                    437:        to indicate which GNU operating system and which version of that system
                    438:        a binary was built for.  The format of that note is:
                    439:        </p>
1.22      tron      440: <div class="variablelist"><dl class="variablelist">
1.1       dsieger   441: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
                    442: <dd>4</dd>
                    443: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
                    444: <dd>16</dd>
                    445: <dt><span class="term"><code class="varname">Type</code></span></dt>
                    446: <dd>4-byte integer containing the value <code class="code">0x01</code>
                    447: </dd>
                    448: <dt><span class="term"><code class="varname">Name</code></span></dt>
                    449: <dd><code class="code">"GNU\0"</code></dd>
                    450: <dt><span class="term"><code class="varname">Desc</code></span></dt>
                    451: <dd>
                    452:              Four 4-byte integers containing, in order:
1.15      spz       453:              <div class="orderedlist"><ol class="orderedlist" type="1">
                    454: <li class="listitem">OS (0 = Linux, 1 = Hurd, 2 = Solaris)</li>
                    455: <li class="listitem">Major</li>
                    456: <li class="listitem">Minor</li>
                    457: <li class="listitem">Teeny</li>
1.1       dsieger   458: </ol></div>
                    459:              The major, minor and teeny versions are that of the earliest OS version that supports this ABI.
                    460:            </dd>
                    461: </dl></div>
                    462: <p>
                    463:       </p>
                    464: 
                    465:       <p>
                    466:        For more documentation on the GNU C Library's use of ELF notes,
                    467:        consult the sources:
1.11      dsieger   468:        <a class="ulink" href="http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/abi-tags?cvsroot=glibc" target="_top">abi-tags</a>
1.1       dsieger   469:        and
1.11      dsieger   470:        <a class="ulink" href="http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/csu/abi-note.S?cvsroot=glibc" target="_top">csu/abi-note.S</a>.
1.1       dsieger   471:       </p>
                    472:     </div>
                    473:   
                    474:       <h4 class="title">
1.39    ! maya      475: <a name="note-creation"></a>Creating ELF <code class="constant">PT_NOTE</code> Sections</h4>
1.1       dsieger   476: 
                    477:       <p>
                    478:        If you're using the GNU binutils 2.8 or greater to create your binaries,
                    479:        you can generate <code class="constant">PT_NOTE</code> sections in your final object files.
                    480:        To create a <code class="constant">PT_NOTE</code> section, create a section in one of your object
                    481:        files (for systems which generate <code class="constant">PT_NOTE</code> entries by default, this
                    482:        is typically the runtime startup code) with a name starting
                    483:        with ".note" and having the "allocate" property set.
                    484:        Put properly formed ELF Notes entries in that section.
                    485:        When final linking is done, all sections which have names starting
                    486:        with ".note" and which are marked "allocate" will be put into <code class="constant">PT_NOTE</code>
                    487:        sections in the final object file.
                    488:       </p>
                    489:       <p>
                    490:        An example of GNU assembler input which will create a <code class="constant">PT_NOTE</code> section
                    491:        during final link is:
                    492:       </p>
                    493: <pre class="programlisting">
                    494:     .section ".note.ident", "a"
                    495:     .p2align 2
                    496:     .long 1f - 0f           # name size (not including padding)
                    497:     .long 3f - 2f           # desc size (not including padding)
                    498:     .long 0x01234567        # type
                    499: 0:  .asciz "NaMe"          # name
                    500: 1:  .p2align 2
                    501: 2:  .long 0x76543210        # desc
                    502:     .long 0x89abcdef
                    503: 3:  .p2align 2
                    504: </pre>
                    505: 
                    506: <p>
                    507:   That example will create a section called ".note.ident", marked
                    508:   "allocate" (so that it will be turned into a
                    509:   <code class="constant">PT_NOTE</code> section during final link), which
                    510:   contains a single note.  That note has a <code class="varname">type</code> of
                    511:   <code class="code">0x012345678</code>, has the <code class="varname">name</code>
                    512:   <code class="code">"NaMe\0"</code>, and has a <code class="varname">desc</code> value
                    513:   consisting of two 4-byte integers, <code class="code">0x76543210</code> and
                    514:   <code class="code">0x89abcdef</code>.
                    515: </p>
                    516:     
                    517:       <h4 class="title">
1.39    ! maya      518: <a name="netbsd-note"></a>Creating a NetBSD ELF <code class="constant">PT_NOTE</code> Section</h4>
1.1       dsieger   519:       
                    520:       <p>
                    521:        The NetBSD kernel will return ENOEXEC if an ELF binary does not contain
                    522:        a recognized <code class="constant">PT_NOTE</code> section. Normally, <code class="filename">crtbegin.c</code>
                    523:        contains this section
                    524:        for native NetBSD applications. The example below creates such a section
1.10      martin    525:        on NetBSD/sparc. (Other ports may use slightly different assembler syntax,
                    526:        for example arm uses %note - since @ starts a comment,
1.1       dsieger   527:        but, except for endian variations, they all use the same bits.)
                    528:       </p>
                    529: <pre class="programlisting">
1.10      martin    530:         .section ".note.netbsd.ident", "", @note
1.1       dsieger   531:         .long   2f-1f
                    532:         .long   4f-3f
                    533:         .long   1
                    534: 1:      .asciz "NetBSD"
                    535: 2:      .p2align 2
1.10      martin    536: 3:      .long   499003600
1.1       dsieger   537: 4:      .p2align 2
                    538: </pre>
1.3       dsieger   539:     </div></div></div>
                    540: <div class="navfoot"></div>
1.13      mishka    541: <div id="footer"><div id="footerContent"><center>
1.33      maya      542: <span class="footfeed"><a href="//www.NetBSD.org/cgi-bin/feedback.cgi">
1.3       dsieger   543:          Contact</a> |
1.9       kano      544:       </span><span class="footcopy"><a href="../../about/disclaimer.html">
1.3       dsieger   545:       Disclaimer</a> |
                    546: 
1.37      jakllsch  547:       <span class="copyright">Copyright © 1994-2018 The NetBSD Foundation, Inc. </span>ALL RIGHTS RESERVED.<br>NetBSD<sup>®</sup> is a registered trademark of The NetBSD
1.3       dsieger   548:        Foundation, Inc.</span>
1.13      mishka    549: </center></div></div>
1.1       dsieger   550: </div></body>
                    551: </html>

CVSweb <webmaster@jp.NetBSD.org>