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

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

CVSweb <webmaster@jp.NetBSD.org>