Annotation of htdocs/docs/kernel/elf-notes.html, revision 1.16
1.1 dsieger 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
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>
19: <div id="header">
20: <div class="topNavigation">
1.6 dsieger 21: <span>» </span><a href="../../docs/guide/en/">
22: The Guide</a> |
1.3 dsieger 23: <a href="http://man.NetBSD.org/">Manual pages</a> |
1.8 kano 24: <a href="../../mailinglists/">
1.6 dsieger 25: Mailing lists</a> and
1.3 dsieger 26: <a href="http://mail-index.NetBSD.org/">Archives</a> |
27: <a href="http://cvsweb.NetBSD.org/">CVS repository</a> |
1.6 dsieger 28: <a href="http://www.NetBSD.org/cgi-bin/sendpr.cgi?gndb=netbsd">Report</a>
29: or
1.9 kano 30: <a href="../../support/query-pr.html">
31: query</a> a bug |
1.6 dsieger 32: <a href="../../docs/software/packages.html">
33: Software Packages
34: </a>
1.3 dsieger 35: </div>
36: <div class="centralHeader">
1.15 spz 37: <a href="../../"><img alt="[NetBSD Logo]" width="506" height="90" src="../../images/NetBSD-headerlogo.png"></a><div class="headerTools"><div id="headerSearch">
38: <div id="header-cse-search-form" style="width: 24%;">Google custom search</div>
39: <script src="http://www.google.com/jsapi" type="text/javascript"></script><script type="text/javascript">
40: google.load('search', '1', {language : 'en'});
41: google.setOnLoadCallback(function() {
42: var header_customSearchControl = new google.search.CustomSearchControl('006277936787196004968:mbdhrauy1wm');
43: header_customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
44: var header_options = new google.search.DrawOptions();
45: header_options.enableSearchboxOnly("http://google.com/cse?cx=006277936787196004968:mbdhrauy1wm");
46: header_customSearchControl.draw('header-cse-search-form', header_options);
47: }, true);
48: </script><link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css">
49: </div></div>
1.3 dsieger 50: </div>
51: <div class="navBar">
1.6 dsieger 52: <span class="doNotDisplay">
53: Navigation:
54: </span><a href="../../">
55: Home</a> |
56: <a href="../../about/">
57: About</a> |
1.12 hubertf 58: <a href="../../gallery/">
59: Gallery</a> |
1.6 dsieger 60: <a href="../../releases/">
61: Download</a> |
62: <a href="../../docs/">
63: Documentation</a> |
64: <a href="../../support/">
65: Support</a> |
66: <a href="../../community/">
67: Community</a> |
68: <a href="../../ports/">
69: Ports</a>
1.3 dsieger 70: </div>
71: </div>
72: <div id="content"><div class="fullWidth"><div class="rowOfBoxes">
73: <h1>NetBSD Documentation: Vendor-specific ELF Note Elements</h1>
1.1 dsieger 74: <h3 class="title"><a name="introduction"></a></h3>
75: <ul>
76: <li><a href="#introduction-sub">Introduction</a></li>
77: <li><a href="#note-format">Format of an ELF Note Element</a></li>
78: <li><a href="#note-names">Known ELF Note Names</a></li>
79: <li><a href="#note-contents">Vendor-specific ELF Notes</a></li>
80: <li><a href="#note-creation">Creating ELF PT_NOTE Sections</a></li>
81: <li><a href="#netbsd-note">Creating a NetBSD ELF PT_NOTE Section</a></li>
82: </ul>
83: <hr>
84: <h3 class="title"></h3>
85: <h4 class="title">
86: <a name="introduction-sub"></a>Introduction (<a href="#introduction">top</a>)
87: </h4>
88: <p>
89: Various operating system vendors are shipping ELF binaries and those
90: binaries expect different system call interfaces. In order to help
91: operating systems correctly determine whether or not they can run an
92: ELF program, and how to run it (e.g. what OS emulation to use), some
93: operating system vendors have begun marking their ELF binaries with
94: vendor-specific note elements, and placing those notes in the
95: binaries' <code class="constant">PT_NOTE</code> sections.
96: </p>
97: <p>
98: This page is meant to be a repository of knowledge about vendor-specific
99: note elements used in binaries <code class="constant">PT_NOTE</code> sections for operating system
100: identification.
101: </p>
102:
103: <p>
104: If your operating system uses vendor-specific note elements to
105: mark its binaries and is not listed here, please send mail to
1.11 dsieger 106: <a class="ulink" href="mailto:cgd@NetBSD.org" target="_top">Chris Demetriou</a>
1.1 dsieger 107: with information about those notes.
108: </p>
109:
110: <h4 class="title">
111: <a name="note-format"></a>Format of an ELF Note Element (<a href="#introduction">top</a>)
112: </h4>
113:
114: <p>
115: All ELF Note elements have the same basic structure:
116: </p>
117: <div class="variablelist"><dl>
118: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
119: <dd>4 bytes (integer)</dd>
120: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
121: <dd>4 bytes (integer)</dd>
122: <dt><span class="term"><code class="varname">Type</code></span></dt>
123: <dd>4 bytes (usually interpreted as an integer)</dd>
124: <dt><span class="term"><code class="varname">Name</code></span></dt>
125: <dd>variable size, padded to a 4 byte boundary</dd>
126: <dt><span class="term"><code class="varname">Desc</code></span></dt>
127: <dd>variable size, padded to a 4 byte boundary</dd>
128: </dl></div>
129: <p>
130: </p>
131:
132: <p>
133: The "Name Size" and "Desc Size" fields are integers (in the byte order
134: specified by the binary's ELF header) which specify the size of the
135: "Name" and "Desc" fields (excluding padding).
136: </p>
137:
138: <p>
139: The "Name" field specifies the vendor who defined the format of the Note.
140: Typically, vendors use names which are related to their project and/or
141: company names. For instance, the GNU Project uses "GNU" as its name.
142: No two vendors should use the same ELF Note Name, lest there be confusion
143: when trying to interpret the meanings of notes.
144: </p>
145:
146: <p>
147: The "Type" field is vendor specific, but it is usually treated as an
148: integer which identifies the type of the note.
149: </p>
150:
151: <p>
152: The "Desc" field is vendor specific, and usually contains data which
153: depends on the note type.
154: </p>
155:
156: <h4 class="title">
157: <a name="note-names"></a>Known ELF Note Names (<a href="#introduction">top</a>)
158: </h4>
159:
160: <p>
161: The following are the strings known to be used as ELF Note Names, along
162: with the organizations that use them. Names with lengths that are
163: not a multiples of 4 are padded in the note, but only the given length
164: should be checked.
165: </p>
166:
167: <div class="segmentedlist"><table border="0">
168: <thead><tr class="segtitle">
169: <th>Note Name String</th>
170: <th>Byte encoding of string</th>
171: <th>Length</th>
172: <th>Organization</th>
173: </tr></thead>
174: <tbody>
175: <tr class="seglistitem">
176: <td class="seg"><code class="code">"NetBSD\0"</code></td>
177: <td class="seg"><code class="code">0x4e 0x65 0x74 0x42 0x53 0x44 0x00</code></td>
178: <td class="seg">7</td>
1.11 dsieger 179: <td class="seg"><a class="xref" href="#note-contents-netbsd" title="The NetBSD Project">The NetBSD Project</a></td>
1.1 dsieger 180: </tr>
181: <tr class="seglistitem">
182: <td class="seg"><code class="code">"GNU\0"</code></td>
183: <td class="seg"><code class="code">0x47 0x4e 0x55 0x00</code></td>
184: <td class="seg">4</td>
1.11 dsieger 185: <td class="seg"><a class="xref" href="#note-contents-gnu" title="The GNU Project">The GNU Project</a></td>
1.1 dsieger 186: </tr>
187: </tbody>
188: </table></div>
189:
190: <h4 class="title">
191: <a name="note-contents"></a>Vendor-specific ELF Notes (<a href="#introduction">top</a>)
192: </h4>
193:
194: <p>
195: This section contains information about the formats of ELF notes which
196: vendors use in their <code class="constant">PT_NOTE</code> sections, and is split up by vendor.
197: </p>
198:
1.15 spz 199: <div class="sect4" title="The NetBSD Project">
1.1 dsieger 200: <div class="titlepage"><div><div><h5 class="title">
201: <a name="note-contents-netbsd"></a>The NetBSD Project</h5></div></div></div>
202:
203:
204: <p>
205: There are two vendor-specific ELF Notes for NetBSD, an OS Version note and
206: an Emulation Name note.
207: The former is used to indicate what OS Version
208: native binaries were built with, and can be used to identify native
209: binaries.
210: The latter is used to mark binaries (both native an non-native) with
211: a name that indicates which set of binary emulation code is to be used
212: when they are run.
213: </p>
214: <p>
215: The format of the NetBSD OS Version note is:
216:
217: </p>
218: <div class="variablelist"><dl>
219: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
220: <dd>7</dd>
221: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
222: <dd>4</dd>
223: <dt><span class="term"><code class="varname">Type</code></span></dt>
224: <dd>4-byte integer containing the value <code class="code">0x01</code>
225: </dd>
226: <dt><span class="term"><code class="varname">Name</code></span></dt>
227: <dd>
228: <code class="code">"NetBSD\0"</code> (padded to 8 bytes)</dd>
229: <dt><span class="term"><code class="varname">Desc</code></span></dt>
230: <dd>4-byte integer containing the NetBSD OS version constant</dd>
231: </dl></div>
232: <p>
233: </p>
234:
235: <p>
236: The format of the NetBSD Emulation Name note is:
237: </p>
238: <div class="variablelist"><dl>
239: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
240: <dd>7</dd>
241: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
242: <dd>variable</dd>
243: <dt><span class="term"><code class="varname">Type</code></span></dt>
244: <dd>4-byte integer containing the value <code class="code">0x02</code>
245: </dd>
246: <dt><span class="term"><code class="varname">Name</code></span></dt>
247: <dd>
248: <code class="code">"NetBSD\0"</code> (padded to 8 bytes)</dd>
249: <dt><span class="term"><code class="varname">Desc</code></span></dt>
250: <dd>
251: <code class="code">NUL</code>-terminated string naming the
252: emulation to be used to run the binary
253: (padded to the next 4-byte boundary)</dd>
254: </dl></div>
255: <p>
256: </p>
257: </div>
258:
1.15 spz 259: <div class="sect4" title="The GNU Project">
1.1 dsieger 260: <div class="titlepage"><div><div><h5 class="title">
261: <a name="note-contents-gnu"></a>The GNU Project</h5></div></div></div>
262:
263:
264: <p>
265: Starting with glibc 2.1, the GNU project will be using a single ELF Note
266: to indicate which GNU operating system and which version of that system
267: a binary was built for. The format of that note is:
268: </p>
269: <div class="variablelist"><dl>
270: <dt><span class="term"><code class="varname">Name Size</code></span></dt>
271: <dd>4</dd>
272: <dt><span class="term"><code class="varname">Desc Size</code></span></dt>
273: <dd>16</dd>
274: <dt><span class="term"><code class="varname">Type</code></span></dt>
275: <dd>4-byte integer containing the value <code class="code">0x01</code>
276: </dd>
277: <dt><span class="term"><code class="varname">Name</code></span></dt>
278: <dd><code class="code">"GNU\0"</code></dd>
279: <dt><span class="term"><code class="varname">Desc</code></span></dt>
280: <dd>
281: Four 4-byte integers containing, in order:
1.15 spz 282: <div class="orderedlist"><ol class="orderedlist" type="1">
283: <li class="listitem">OS (0 = Linux, 1 = Hurd, 2 = Solaris)</li>
284: <li class="listitem">Major</li>
285: <li class="listitem">Minor</li>
286: <li class="listitem">Teeny</li>
1.1 dsieger 287: </ol></div>
288: The major, minor and teeny versions are that of the earliest OS version that supports this ABI.
289: </dd>
290: </dl></div>
291: <p>
292: </p>
293:
294: <p>
295: For more documentation on the GNU C Library's use of ELF notes,
296: consult the sources:
1.11 dsieger 297: <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 298: and
1.11 dsieger 299: <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 300: </p>
301: </div>
302:
303: <h4 class="title">
304: <a name="note-creation"></a>Creating ELF <code class="constant">PT_NOTE</code> Sections (<a href="#introduction">top</a>)
305: </h4>
306:
307: <p>
308: If you're using the GNU binutils 2.8 or greater to create your binaries,
309: you can generate <code class="constant">PT_NOTE</code> sections in your final object files.
310: To create a <code class="constant">PT_NOTE</code> section, create a section in one of your object
311: files (for systems which generate <code class="constant">PT_NOTE</code> entries by default, this
312: is typically the runtime startup code) with a name starting
313: with ".note" and having the "allocate" property set.
314: Put properly formed ELF Notes entries in that section.
315: When final linking is done, all sections which have names starting
316: with ".note" and which are marked "allocate" will be put into <code class="constant">PT_NOTE</code>
317: sections in the final object file.
318: </p>
319: <p>
320: An example of GNU assembler input which will create a <code class="constant">PT_NOTE</code> section
321: during final link is:
322: </p>
323: <pre class="programlisting">
324: .section ".note.ident", "a"
325: .p2align 2
326: .long 1f - 0f # name size (not including padding)
327: .long 3f - 2f # desc size (not including padding)
328: .long 0x01234567 # type
329: 0: .asciz "NaMe" # name
330: 1: .p2align 2
331: 2: .long 0x76543210 # desc
332: .long 0x89abcdef
333: 3: .p2align 2
334: </pre>
335:
336: <p>
337: That example will create a section called ".note.ident", marked
338: "allocate" (so that it will be turned into a
339: <code class="constant">PT_NOTE</code> section during final link), which
340: contains a single note. That note has a <code class="varname">type</code> of
341: <code class="code">0x012345678</code>, has the <code class="varname">name</code>
342: <code class="code">"NaMe\0"</code>, and has a <code class="varname">desc</code> value
343: consisting of two 4-byte integers, <code class="code">0x76543210</code> and
344: <code class="code">0x89abcdef</code>.
345: </p>
346:
347: <h4 class="title">
348: <a name="netbsd-note"></a>Creating a NetBSD ELF <code class="constant">PT_NOTE</code> Section (<a href="#introduction">top</a>)
349: </h4>
350:
351: <p>
352: The NetBSD kernel will return ENOEXEC if an ELF binary does not contain
353: a recognized <code class="constant">PT_NOTE</code> section. Normally, <code class="filename">crtbegin.c</code>
354: contains this section
355: for native NetBSD applications. The example below creates such a section
1.10 martin 356: on NetBSD/sparc. (Other ports may use slightly different assembler syntax,
357: for example arm uses %note - since @ starts a comment,
1.1 dsieger 358: but, except for endian variations, they all use the same bits.)
359: </p>
360: <pre class="programlisting">
1.10 martin 361: .section ".note.netbsd.ident", "", @note
1.1 dsieger 362: .long 2f-1f
363: .long 4f-3f
364: .long 1
365: 1: .asciz "NetBSD"
366: 2: .p2align 2
1.10 martin 367: 3: .long 499003600
1.1 dsieger 368: 4: .p2align 2
369: </pre>
1.3 dsieger 370: </div></div></div>
371: <div class="navfoot"></div>
1.13 mishka 372: <div id="footer"><div id="footerContent"><center>
1.3 dsieger 373: <span class="footfeed"><a href="http://www.NetBSD.org/cgi-bin/feedback.cgi">
374: Contact</a> |
1.9 kano 375: </span><span class="footcopy"><a href="../../about/disclaimer.html">
1.3 dsieger 376: Disclaimer</a> |
377:
1.16 ! darcy 378: <span class="copyright">Copyright © 1994-2012 The NetBSD Foundation, Inc. </span>ALL RIGHTS RESERVED.<br>NetBSD<sup>®</sup> is a registered trademark of The NetBSD
1.3 dsieger 379: Foundation, Inc.</span>
1.13 mishka 380: </center></div></div>
1.1 dsieger 381: </div></body>
382: </html>
CVSweb <webmaster@jp.NetBSD.org>