elfnote

Display or modify the contents of an ELF note (QNX)

Syntax:

elfnote [-pv] [-n name] [-t type] [-m value [-F fmt]] [-S num [-L]]
        file [outfile]

Runs on:

QNX Neutrino, Linux, Mac, Microsoft Windows

Options:

-F n
Treat the -m option's argument as a numeric value.
-L
For a QNX note of type QNT_STACK, use lazy stack allocation.
-m value
Modify the contents of the note.
-n name
The note name to match.
-p
Display (“print”) the notes. If you also use the -t to specify a note type, elfnote displays only that type of notes; otherwise elfnote displays all the notes. If you specify the -m option, elfnote displays the value before modification.
-S num
The stack size. This option implies -n QNX and -t QNT_STACK.
-t type
The note type to match. Acceptable values are numbers or the following QNT_* types (defined in <elfdefinitions.h>), in which case -n QNX is implied:
  • QNT_DEBUG_FULLPATH
  • QNT_DEBUG_RELOC
  • QNT_STACK
  • QNT_GENERATOR
  • QNT_DEFAULT_LIB
  • QNT_CORE_SYSINFO
  • QNT_CORE_INFO
  • QNT_CORE_STATUS
  • QNT_CORE_GREG
  • QNT_CORE_FPREG
  • QNT_LINK_MAP — you can use coreinfo to display this note in core files.

You typically use elfnote to modify QNT_STACK, as described below.

-v
Be extra verbose.

Description:

The elfnote utility displays or modifies the contents of a note in an Executable and Linkable Format file.

When you're modifying the contents of a note, you must specify both -t and -n. The value passed to -m is a hexadecimal representation of raw data. Therefore, if the note description contains (for example) numeric types, you must convert them to target endian order and represent them in hexadecimal format.

Note:
  • You can't change the size of a note, only its contents.
  • Setting a stack size that's insufficient for the startup of the process, including space for arguments and environment variables (limited by _SC_ARG_MAX or ARG_MAX), may cause unexpected early failures of the process execution.

Examples:

Set stacksize to 128 KB, and allocate it at thread creation time:

elfnote -S 128k file

Specify a stack size of 128 KB, lazy allocated:

elfnote -S 128k -L file

Assume you have a binary containing a note with a name SP_NOTE and type 9, consisting of the four 32-bit values, 100, 200, 300 and 400. Display the note:

elfnote -p -n SP_NOTE file
Note name = SP_NOTE, type = 9
        hex         : 64000000c80000002c01000090010000

Change the values to 16, 32, 48 and 64:

elfnote -n SP_NOTE -t 9 -F n -m 16,32,48,64 file

Display the changed note:

elfnote -p -n SP_NOTE file
Note name = SP_NOTE, type = 9
        hex         : 10000000200000003000000040000000

Change the value back to the original by specifying a hex string:

elfnote -n SP_NOTE -t 9 -m 64000000c80000002c01000090010000 file

Display the result again:

elfnote -p -n SP_NOTE file
Note name = SP_NOTE, type = 9
        hex         : 64000000c80000002c01000090010000