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