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

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

CVSweb <webmaster@jp.NetBSD.org>