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

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

CVSweb <webmaster@jp.NetBSD.org>