NetBSD Documentation:Vendor-specific ELF Note Elements |
Various operating system vendors are shipping ELF binaries and those binaries expect different system call interfaces. In order to help operating systems correctly determine whether or not they can run an ELF program, and how to run it (e.g. what OS emulation to use), some operating system vendors have begun marking their ELF binaries with vendor-specific note elements, and placing those notes in the binaries' PT_NOTE sections.
This page is meant to be a repository of knowledge about vendor-specific note elements used in binaries PT_NOTE sections for operating system identification. It contains the following information:
If your operating system uses vendor-specific note elements to mark its binaries and is not listed here, please send mail to Chris Demetriou with information about those notes.
Name Size 4 bytes (integer) Desc Size 4 bytes (integer) Type 4 bytes (usually interpreted as an integer) Name variable size, padded to a 4 byte boundary Desc variable size, padded to a 4 byte boundary
The Name Size and Desc Size fields are integers (in the byte order specified by the binary's ELF header) which specify the size of the Name and Desc fields (excluding padding).
The Name field specifies the vendor who defined the format of the Note. Typically, vendors use names which are related to their project and/or company names. For instance, the GNU Project uses "GNU" as its name. No two vendors should use the same ELF Note Name, lest there be confusion when trying to interpret the meanings of notes.
The Type field is vendor specific, but it is usually treated as an integer which identifies the type of the note.
The Desc field is vendor specific, and usually contains data which depends on the note type.
Note Name String Organization ---------------- ------------ "NetBSD\0" The NetBSD Project 0x4e 0x65 0x74 0x42 0x53 0x44 0x00 (length 7) "GNU\0" The GNU Project 0x47 0x4e 0x55 0x00 (length 4)
The format of the NetBSD OS Version note is:
Name Size: 7 Desc Size: 4 Type: 4-byte integer containing the value 0x01 Name: "NetBSD\0" (padded to 8 bytes) Desc: 4-byte integer containing the NetBSD OS version constant
The format of the NetBSD Emulation Name note is:
Name Size: 7 Desc Size: variable Type: 4-byte integer containing the value 0x02 Name: "NetBSD\0" (padded to 8 bytes) Desc: NUL-terminated string naming the emulation to be used to run the binary (padded to the next 4-byte boundary)
Name Size: 4 Desc Size: 16 Type: 4-byte integer containing the value 0x01 Name: "GNU\0" Desc: Four 4-byte integers containing, in order: OS (0 = Linux, 1 = Hurd, 2 = Solaris) Major, Minor, and Teeny (of earliest OS version that supports this ABI)For more documentation on the GNU C Library's use of ELF notes, consult the sources: abi-tags and csu/abi-note.S.
An example of GNU assembler input which will create a PT_NOTE section during final link is:
.section ".note.ident", "a" .p2align 2 .long 1f - 0f # name size (not including padding) .long 3f - 2f # desc size (not including padding) .long 0x01234567 # type 0: .asciz "NaMe" # name 1: .p2align 2 2: .long 0x76543210 # desc .long 0x89abcdef 3: .p2align 2
That example will create a section called ".note.ident", marked "allocate" (so that it will be turned into a PT_NOTE section during final link), which contains a single note. That note has a type of 0x012345678, has the name "NaMe\0", and has a desc value consisting of two 4-byte integers, 0x76543210 and 0x89abcdef.
crtbegin.c
contains this section
for native NetBSD applications. The example below creates such a section
on NetBSD/alpha. (Other ports may use slightly different assembler syntax,
but, except for endian variations, they all use the same bits.)
.section ".note.netbsd.ident", "a" .long 2f-1f .long 4f-3f .long 1 1: .asciz "NetBSD" 2: .p2align 2 3: .long 199905 4: .p2align 2
|
|