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

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

CVSweb <webmaster@jp.NetBSD.org>