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

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

CVSweb <webmaster@jp.NetBSD.org>