JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
man pages section 1: User Commands     Oracle Solaris 11.1 Information Library
search filter icon
search icon

Document Information

Preface

Introduction

User Commands

acctcom(1)

adb(1)

addbib(1)

admin(1)

alias(1)

allocate(1)

amt(1)

appcert(1)

apptrace(1)

apropos(1)

ar(1)

arch(1)

as(1)

asa(1)

at(1)

atq(1)

atrm(1)

audioconvert(1)

audioctl(1)

audioplay(1)

audiorecord(1)

audiotest(1)

auths(1)

auto_ef(1)

awk(1)

banner(1)

basename(1)

basename(1B)

batch(1)

bc(1)

bdiff(1)

bfs(1)

bg(1)

biff(1B)

break(1)

builtin(1)

cal(1)

calendar(1)

case(1)

cat(1)

cd(1)

cdc(1)

cdrw(1)

chdir(1)

checkeq(1)

checknr(1)

chgrp(1)

chkey(1)

chmod(1)

chown(1)

chown(1B)

ckdate(1)

ckgid(1)

ckint(1)

ckitem(1)

ckkeywd(1)

ckpath(1)

ckrange(1)

ckstr(1)

cksum(1)

cktime(1)

ckuid(1)

ckyorn(1)

clear(1)

cmp(1)

col(1)

comb(1)

comm(1)

command(1)

compress(1)

continue(1)

cp(1)

cpio(1)

cpp(1)

cputrack(1)

crle(1)

crontab(1)

csh(1)

csplit(1)

ct(1C)

ctags(1)

ctrun(1)

ctstat(1)

ctwatch(1)

cu(1C)

cut(1)

date(1)

dc(1)

deallocate(1)

decrypt(1)

delta(1)

deroff(1)

df(1B)

dhcpinfo(1)

diff(1)

diff3(1)

diffmk(1)

digest(1)

digestp(1)

dircmp(1)

dirname(1)

dirs(1)

dis(1)

disown(1)

dispgid(1)

dispuid(1)

dos2unix(1)

dpost(1)

du(1)

du(1B)

dump(1)

dumpcs(1)

dumpkeys(1)

echo(1)

echo(1B)

ed(1)

edit(1)

egrep(1)

eject(1)

elfdump(1)

elfedit(1)

elffile(1)

elfsign(1)

elfwrap(1)

encrypt(1)

enhance(1)

env(1)

eqn(1)

errange(1)

errdate(1)

errgid(1)

errint(1)

erritem(1)

error(1)

errpath(1)

errstr(1)

errtime(1)

erruid(1)

erryorn(1)

eval(1)

ex(1)

exec(1)

exit(1)

expand(1)

export(1)

exportfs(1B)

expr(1)

expr(1B)

exstr(1)

factor(1)

false(1)

fastboot(1B)

fasthalt(1B)

fc(1)

fg(1)

fgrep(1)

file(1)

file(1B)

filebench(1)

filep(1)

filesync(1)

filofaxp(1)

find(1)

finger(1)

fmt(1)

fmtmsg(1)

fold(1)

for(1)

foreach(1)

franklinp(1)

from(1B)

ftp(1)

function(1)

gcore(1)

gencat(1)

geniconvtbl(1)

genmsg(1)

get(1)

getconf(1)

getfacl(1)

getlabel(1)

getopt(1)

getoptcvt(1)

getopts(1)

gettext(1)

gettxt(1)

getzonepath(1)

glob(1)

goto(1)

gprof(1)

grep(1)

groups(1)

groups(1B)

grpck(1B)

hash(1)

hashcheck(1)

hashmake(1)

hashstat(1)

head(1)

helpdate(1)

helpgid(1)

helpint(1)

helpitem(1)

helppath(1)

helprange(1)

helpstr(1)

helptime(1)

helpuid(1)

helpyorn(1)

hist(1)

history(1)

hostid(1)

hostname(1)

i386(1)

i486(1)

iconv(1)

if(1)

indxbib(1)

install(1B)

ipcrm(1)

ipcs(1)

isainfo(1)

isalist(1)

jobs(1)

join(1)

jsh(1)

kbd(1)

kdestroy(1)

keylogin(1)

keylogout(1)

kill(1)

kinit(1)

klist(1)

kmdb(1)

kmfcfg(1)

kpasswd(1)

krb5-config(1)

ksh(1)

ksh88(1)

ksh93(1)

ktutil(1)

kvno(1)

lari(1)

last(1)

lastcomm(1)

ld(1)

ldapadd(1)

ldapdelete(1)

ldaplist(1)

ldapmodify(1)

ldapmodrdn(1)

ldapsearch(1)

ldd(1)

ld.so.1(1)

let(1)

lex(1)

lgrpinfo(1)

limit(1)

line(1)

list_devices(1)

listusers(1)

llc2_autoconfig(1)

llc2_config(1)

llc2_stats(1)

ln(1)

ln(1B)

loadkeys(1)

locale(1)

localedef(1)

logger(1)

logger(1B)

login(1)

logname(1)

logout(1)

look(1)

lookbib(1)

lorder(1)

ls(1)

ls(1B)

m4(1)

mac(1)

mach(1)

machid(1)

madv.so.1(1)

mail(1)

Mail(1B)

mail(1B)

mailcompat(1)

mailp(1)

mailq(1)

mailstats(1)

mailx(1)

make(1S)

makekey(1)

man(1)

mconnect(1)

mcs(1)

mdb(1)

mesg(1)

mkdir(1)

mkmsgs(1)

mkstr(1B)

mktemp(1)

moe(1)

more(1)

mp(1)

mpss.so.1(1)

msgcc(1)

msgcpp(1)

msgcvt(1)

msgfmt(1)

msggen(1)

msgget(1)

mt(1)

mv(1)

nawk(1)

nc(1)

ncab2clf(1)

ncakmod(1)

neqn(1)

netcat(1)

newform(1)

newgrp(1)

newsp(1)

newtask(1)

nice(1)

nl(1)

nm(1)

nohup(1)

notify(1)

nroff(1)

od(1)

on(1)

onintr(1)

optisa(1)

pack(1)

packagemanager(1)

page(1)

pagesize(1)

pargs(1)

passwd(1)

paste(1)

patch(1)

pathchk(1)

pax(1)

pcat(1)

pcred(1)

perl(1)

pfbash(1)

pfcsh(1)

pfexec(1)

pfiles(1)

pfksh(1)

pflags(1)

pfsh(1)

pftcsh(1)

pfzsh(1)

pg(1)

pgrep(1)

pkcs11_inspect(1)

pkg(1)

pkgdepend(1)

pkgdiff(1)

pkgfmt(1)

pkginfo(1)

pkglint(1)

pkgmerge(1)

pkgmk(1)

pkgmogrify(1)

pkgparam(1)

pkgproto(1)

pkgrecv(1)

pkgrepo(1)

pkgsend(1)

pkgsign(1)

pkgtrans(1)

pkill(1)

pklogin_finder(1)

pktool(1)

plabel(1)

pldd(1)

plgrp(1)

plimit(1)

pmadvise(1)

pmap(1)

pm-updatemanager(1)

popd(1)

ppgsz(1)

ppriv(1)

pr(1)

praliases(1)

prctl(1)

preap(1)

print(1)

printenv(1B)

printf(1)

priocntl(1)

proc(1)

prof(1)

profiles(1)

projects(1)

prs(1)

prt(1)

prun(1)

ps(1)

ps(1B)

psig(1)

pstack(1)

pstop(1)

ptime(1)

ptree(1)

pushd(1)

pvs(1)

pwait(1)

pwd(1)

pwdx(1)

radadrgen(1)

ranlib(1)

rcapstat(1)

rcp(1)

read(1)

readonly(1)

red(1)

refer(1)

regcmp(1)

rehash(1)

remote_shell(1)

remsh(1)

renice(1)

repeat(1)

reset(1B)

return(1)

rksh(1)

rksh88(1)

rlogin(1)

rm(1)

rmail(1)

rmdel(1)

rmdir(1)

rmformat(1)

rmmount(1)

rmumount(1)

roffbib(1)

roles(1)

rpcgen(1)

rpm2cpio(1)

rsh(1)

runat(1)

rup(1)

rup(1C)

ruptime(1)

rusage(1B)

rusers(1)

rwho(1)

sact(1)

sar(1)

sccs(1)

sccs-admin(1)

sccs-cdc(1)

sccs-comb(1)

sccs-delta(1)

sccsdiff(1)

sccs-get(1)

sccs-help(1)

sccshelp(1)

sccs-prs(1)

sccs-prt(1)

sccs-rmdel(1)

sccs-sact(1)

sccs-sccsdiff(1)

sccs-unget(1)

sccs-val(1)

scp(1)

script(1)

sdiff(1)

sed(1)

sed(1B)

select(1)

set(1)

setenv(1)

setfacl(1)

setlabel(1)

setpgrp(1)

settime(1)

sftp(1)

sh(1)

shcomp(1)

shell_builtins(1)

shift(1)

shutdown(1B)

size(1)

sleep(1)

soelim(1)

sort(1)

sortbib(1)

sotruss(1)

source(1)

sparc(1)

spell(1)

spellin(1)

split(1)

srchtxt(1)

ssh(1)

ssh-add(1)

ssh-agent(1)

ssh-http-proxy-connect(1)

ssh-keygen(1)

ssh-keyscan(1)

ssh-socks5-proxy-connect(1)

stop(1)

strchg(1)

strconf(1)

strings(1)

strip(1)

stty(1)

stty(1B)

sum(1)

sum(1B)

sun(1)

suspend(1)

svcprop(1)

svcs(1)

switch(1)

symorder(1)

sys-suspend(1)

sysV-make(1)

t300(1)

t300s(1)

t4014(1)

t450(1)

tabs(1)

tail(1)

talk(1)

tar(1)

tbl(1)

tcopy(1)

tee(1)

tek(1)

telnet(1)

test(1)

test(1B)

tftp(1)

time(1)

timemanp(1)

times(1)

timesysp(1)

timex(1)

tip(1)

touch(1)

touch(1B)

tplot(1)

tput(1)

tr(1)

tr(1B)

trap(1)

troff(1)

true(1)

truss(1)

tset(1B)

tsort(1)

tty(1)

type(1)

typeset(1)

ul(1)

ulimit(1)

umask(1)

unalias(1)

uname(1)

uncompress(1)

unexpand(1)

unget(1)

unhash(1)

unifdef(1)

uniq(1)

units(1)

unix2dos(1)

unlimit(1)

unpack(1)

unset(1)

unsetenv(1)

until(1)

updatehome(1)

uptime(1)

userattr(1)

users(1B)

uucp(1C)

uudecode(1C)

uuencode(1C)

uuglist(1C)

uulog(1C)

uuname(1C)

uupick(1C)

uustat(1C)

uuto(1C)

uux(1C)

vacation(1)

val(1)

valdate(1)

valgid(1)

valint(1)

valpath(1)

valrange(1)

valstr(1)

valtime(1)

valuid(1)

valyorn(1)

vc(1)

vedit(1)

ver(1)

vgrind(1)

vi(1)

view(1)

vipw(1B)

volcheck(1)

volrmmount(1)

w(1)

wait(1)

wc(1)

what(1)

whatis(1)

whence(1)

whereis(1B)

which(1)

while(1)

who(1)

whoami(1B)

whocalls(1)

whois(1)

write(1)

xargs(1)

xgettext(1)

xstr(1)

yacc(1)

yes(1)

ypcat(1)

ypmatch(1)

yppasswd(1)

ypwhich(1)

zcat(1)

zlogin(1)

zonename(1)

zonestat(1)

elfedit

- examine or edit ELF files

Synopsis

elfedit [-adr] [-e cmd] [-L path]
     [-o default | simple | num] [infile] [outfile]

Description

elfedit is a tool for examining or modifying the contents of an existing ELF object. Specifically, elfedit is used to modify the ELF metadata contained in the object. Access is provided to most of the ELF data contained in an object, including the ELF header, section header table, program header table, dynamic section, hardware and software capabilities, string tables, and symbol tables.

Syntax

elfedit processes commands from the command line (-e option) or from standard input. If standard input is a terminal, elfedit provides terminal editing capabilities, as well as extensive command completion. ELF uses many standard symbolic names for special integer values and bit masks. elfedit is aware of most possible completions for such names. You can press TAB at any point while entering an elfedit command to cause elfedit to display a usage message and any known completions for the text at the current cursor.

elfedit functionality is organized in the form of modules. Each module delivers a set of commands, focused on related functionality. A command is specified by combining the module and command names with a colon (:) delimiter, with no intervening white space. For example, dyn:runpath refers to the runpath command provided by the dyn module. Module names must be unique. The command names within a given module are unique within that module, but the same command names can be used in more than one module.

Some modules designate one of their commands to be the default command for that module. This command is run when the user specifies only a module name. Most elfedit modules supply a command named dump, which produces the same information displayed by the elfdump utility for the part of the ELF file covered by the module. It is common for a module to specify dump as its default command.

The syntax used to execute an elfedit command is intended to be familiar to anyone who uses UNIX command line utilities. It consists of white space delimited tokens. The first token is the command name. Options, which are arguments that start with the hyphen (-) character follow the command. Plain arguments (operands) follow the options. There can be 0 or more options and operands for a given command, but if they are present, options always precede plain arguments. The special option, --, (two hyphens) can be used to delimit the end of the options. When it is encountered, any remaining arguments are considered to be plain arguments even if they start with a -.

The interpretation of the characters in an elfedit token depends on the style of quoting used:

Unquoted

Outside of single (') or double (“) quotes, backslash (\) acts as an escape character. When a backslash character is seen, elfedit ignores it, and treats the character following it literally (even if the following character is itself a backslash). This feature can be used to insert a white space character into a string argument to a command without having it split the string into two separate tokens. Similarly, it can be used to insert a quote or backslash as a literal character.

Single Quotes

Within single quotes ('), white space characters do not delimit tokens, and are interpreted as literal characters within the token. Double quote (“) and backslash (\) characters are interpreted as literal characters, and have no special meaning.

Double Quotes

Within double quotes (“), white space characters do not delimit tokens. Single quote characters are interpreted literally and do not have a quoting function. Backslash (\) is an escape character which operates similarly to the way it is used in the C programming language within a string literal:

\a

alert (bell)

\b

backspace

\f

form feed

\n

newline

\r

return

\t

horizontal tab

\v

vertical tab

\\

backslash

\'

single quote

\”

double quote

\ooo

An octal constant, where ooo is one to three octal digits (0...7)

Any other character following a backslash is an error.

The core commands belong to an internal module named sys. All other modules are packaged as dynamically loadable sharable objects. elfedit loads modules on demand, when a command that requires it is executed, or as the result of executing the sys:load command. Due to its special built in status, and because its commands are used heavily, elfedit allows you to specify commands from the sys module without including the sys: prefix, for example, load rather than sys:load. To access a command from any other module, you must specify the full module:cmd form.

elfedit is delivered with the following standard modules:

cap

Capabilities Section

dyn

Dynamic Section

ehdr

ELF Header

phdr

Program Header Array

shdr

Section Header Array

str

String Table Section

sym

Symbol Table Section

syminfo

Syminfo Section

sys

Core built in elfedit commands

Status And Command Documentation

Status And Command Documentation

The status (sys:status) command displays information about the current elfedit session:

Included with every elfedit module is extensive online documentation for every command, in a format similar to UNIX manual pages. The help (sys:help) command is used to display this information. To learn more about elfedit, start elfedit and use the help command without arguments:

% elfedit
> help

elfedit displays a welcome message with more information about elfedit, and on how to use the help system.

To obtain summary information for a module:

> help module

To obtain the full documentation for a specific command provided by a module:

> help module:command

Using the dyn module and dyn:runpath commands as examples:

> help dyn
> help dyn:runpath

help (sys:help) can be used to obtain help on itself:

> help help

Module Search Path

elfedit modules are implemented as sharable objects which are loaded on demand. When a module is required, elfedit searches a module path in order to locate the sharable object that implements the module. The path is a sequence of directory names delimited by colon (:) characters. In addition to normal characters, the path can also contain any of the following tokens:

%i

Expands to the current instruction set architecture (ISA) name (sparc, sparcv9, i386, amd64).

%I

Expands to the 64-bit ISA. This is the same thing as %i for 64-bit versions of elfedit, but expands to the empty string for 32-bit versions.

%o

Expands to the old value of the path being modified. This is useful for appending or prepending directories to the default path.

%r

Root of file system tree holding the elfedit program, assuming that elfedit is installed as usr/bin/elfedit within the tree. On a standard system, this is simply the standard system root directory (/). On a development system, where the copy of elfedit can be installed elsewhere, the use of %r can be used to ensure that the matching set of modules are used.

%%

Expands to a single % character

The default module search path for elfedit is:

%r/usr/lib/elfedit/%I

Expanding the tokens, this is:

/usr/lib/elfedit

32-bit elfedit

/usr/lib/elfedit/sparcv9

64-bit elfedit (sparc)

/usr/lib/elfedit/amd64

64-bit elfedit (x86)

The default search path can be changed by setting the ELFEDIT_PATH environment variable, or by using the -L command line option. If you specify both, the -L option supersedes the environment variable.

Options

The following options are supported:

-a

Enable autoprint mode. When autoprint is enabled, elfedit prints the modified values that result when the ELF file is modified. This output is shown in the current output style, which can be changed using the -o option. The default output style is the style used by the elfdump(1) utility. autoprint mode is the default when elfedit is used interactively (when stdin and stdout are terminals). Therefore, the -a option only has meaning when elfedit is used in non-interactive contexts. To disable autoprint in an interactive session, use the elfedit command:

> set a off
-d

If set, this option causes elfedit to issue informational messages describing its internal operations and details of the ELF object being processed. This can be useful when a deep understanding of the operation being carried out is desired.

-e cmd

Specifies an edit command. Multiple -e options can be specified. If edit commands are present on the command line, elfedit operates in batch mode. After opening the file, elfedit executes each command in the order given, after which the modified file is saved and elfedit exits. Batch mode is useful for performing simple operations from shell scripts and makefiles.

-L path

Sets default path for locating elfedit modules. Modules are described in Module Search Path section of this manual page..

-o default | simple | num

The style used to display ELF data. This option establishes the current style for the session. It can be changed from within the elfedit session by using the set (sys:set) command, or by providing -o options to the individual commands executed within the session.

default

The default style is to display output in a format intended for human viewing. This style is similar to that used by the elfdump utility.

num

Integer values are always shown in integer form. Strings are shown as the integer offset into the containing string table.

simple

When displaying strings from within the ELF file, only the string is displayed. Integer values are displayed as symbolic constants if possible, and in integer form otherwise. No titles, headers, or other supplemental output is shown.

-r

Read-only mode. The input file is opened for read-only access, and the results of the edit session are not saved. elfedit does not allow the outfile argument when -r is specified. Read-only mode is highly recommended when there is no intention to modify the file. In addition to providing extra protection against accidental modification, it allows for the examination of files for which the user does not have write permission.

Operands

The following operands are supported:

infile

Input file containing an ELF object to process.

This can be an executable (ET_EXEC), shared object (ET_DYN), or relocatable object file, (ET_REL). Archives are not directly supported. To edit an object in an archive, you must extract the object, edit the copy, and then insert it back into the archive.

If no infile is present, elfedit runs in a limited mode that only allows executing commands from the sys: module. This mode is primarily to allow access to the command documentation available from the help (sys:help) command.

If infile is present, and no outfile is given, elfedit edits the file in place, and writes the results into the same file, causing the original file contents to be overwritten. It is usually recommended that elfedit not be used in this mode, and that an output file be specified. Once the resulting file has been tested and validated, it can be moved into the place of the original file.

The -r option can be used to open infile for read-only access. This can be useful for examining an existing file that you do not wish to modify.

outfile

Output file. If both infile and outfile are present, infile is opened for read-only access, and the modified object contents are written to outfile.

Usage

When supported by the system, elfedit runs as a 64-bit application, capable of processing files greater than or equal to 2 Gbytes (2^31 bytes).

At startup, elfedit uses libelf to open the input file and cache a copy of its contents in memory for editing. It can then execute one or more commands. A session finishes by optionally writing the modified object to the output file, and then exiting.

If no infile is present, elfedit runs in a limited mode that only allows executing commands from the sys module. This mode is primarily to allow access to the command documentation available from the help (sys:help) command.

If one or more -e options are specified, the commands they supply are executed in the order given. elfedit adds implicit calls to write (sys:write) and quit (sys:quit) immediately following the given commands, causing the output file to be written and the elfedit process to exit. This form of use is convenient in shell scripts and makefiles.

If no -e options are specified, elfedit reads commands from stdin and executes them in the order given. The caller must explicitly issue the write (sys:write) and quit (sys:quit) commands to save their work and exit when running in this mode.

Exit Status

The following exit values are returned:

0

Successful completion.

1

A fatal error occurred.

2

Invalid command line options were specified.

Examples

In the following examples, interactive use of elfedit is shown with the shell prompt (%) and the elfedit prompt (>). Neither of these characters should be entered by the user.

Example 1 Changing the Runpath of an Executable

The following example presupposes an executable named prog, installed in a bin directory that has an adjacent lib directory for sharable objects. The following command sets the runpath of that executable to the lib directory:

elfedit -e 'dyn:runpath $ORIGIN/../lib'

The use of single quotes with the argument to the -e option is necessary to ensure that the shell passes the entire command as a single argument to elfedit.

Alternatively, the same operation can be done using elfedit in its non-batch mode:

% elfedit prog
> dyn:runpath $ORIGIN/../lib
     index  tag         value
       [30]  RUNPATH     0x3e6      $ORIGIN/../lib
> write
> quit

The addition or modification of elements such as runpath or needed entries might only be achievable when padding exists within the objects. See Notes.

Example 2 Removing a Hardware Capability Bit

Objects that require optional hardware support to run are built with a capability section that contains a mask of bits specifying which capabilities they need. The runtime linker (ld.so.1) checks this mask against the attributes of the running system to determine whether a given object is able to be run by the current system. Programs that require abilities not available on the system are prevented from running.

This check prevents a naive program that does not explicitly check for the hardware support it requires from crashing in a confusing manner. However, it can be inconvenient for a program that is written to explicitly check the system capabilities at runtime. Such a program might have optimized code to use when the hardware supports it while providing a generic fallback version that can be run, albeit more slowly, otherwise. In this case, the hardware compatibility mask prevents such a program from running on the older hardware. In such a case, removing the relevant bit from the mask allows the program to run.

The following example removes the AV_386_SSE3 hardware capability from an x86 binary that uses the SSE3 CPU extension. This transfers responsibility for validating the ability to use SSE3 from the runtime linker to the program itself:

elfedit -e 'cap:hw1 -and -cmp sse3' prog

Example 3 Reading Information From an Object

elfedit can be used to extract specific targeted information from an object. The following shell command reads the number of section headers contained in the file /usr/bin/ls:

% SHNUM=`elfedit -r -onum -e 'ehdr:e_shnum' /usr/bin/ls`
% echo $SHNUM
29

You might get a different value, depending on the version of Solaris and type of machine that you are using. The -r option causes the file to be opened read-only, allowing a user with ordinary access permissions to open the file, and protecting against accidental damage to an important system executable. The num output style is used in order to obtain only the desired value, without any extraneous text.

Similarly, the following extracts the symbol type of the symbol unlink from the C runtime library:

% TYPE=`elfedit -r -osimple -e 'sym:st_type unlink' \
      /lib/libc.so`
% echo $TYPE
STT_FUNC

Example 4 Specifying ASLR Settings For An Executable

The default Address Space Layout Randomization (ASLR) behavior for an executable is specified with the DT_SUNW_ASLR dynamic section entry. The following demonstrates how to enable or disable ASLR for the specified program.

% elfedit prog
> dyn:sunw_aslr enable
     index  tag              value
      [40]  SUNW_ASLR       0x2           ENABLE
> dyn:sunw_aslr disable
     index  tag              value
      [40]  SUNW_ASLR       0x1           DISABLE

Environment Variables

ELFEDIT_PATH

Alters the default module search path. Module search paths are discussed in the Module Search Path section of this manual page.

LD_NOEXEC_64

Suppresses the automatic execution of the 64-bit elfedit. By default, the 64-bit version of elfedit runs if the system is 64-bit capable.

PAGER

Interactively delivers output from elfedit to the screen. If not set, more is used. See more(1).

Files

/usr/lib/elfedit

Default directory for elfedit modules that are loaded on demand to supply editing commands.

~/.teclarc

Personal tecla customization file for command line editing. See tecla(5).

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
system/linker
Interface Stability
Committed

See Also

dump(1), elfdump(1), ld.so.1(1), more(1), nm(1), pvs(1), sxadm(1M), elf(3ELF), libelf(3LIB), tecla(5), attributes(5)

Linker and Libraries Guide

Warnings

elfedit is designed to be a tool for testing and development of the ELF system. It offers the ability to examine and change nearly every piece of ELF metadata in the object. It quietly allows edits that can produce an invalid or unusable ELF file. The user is expected to have knowledge of the ELF format and of the rules and conventions that govern them. The Linker and Libraries Guide can be helpful when using elfedit.

elfedit allows the user to alter the ELF metadata in an object, but cannot understand or alter the code of the actual program. Setting ELF attributes such as types, sizes, alignments, and so forth in a manner that does not agree with the actual contents of the file is therefore likely to yield a broken and unusable output object. Such changes might be useful for testing of linker components, but should be avoided otherwise.

Higher level operations, such as the use of the dyn:runpath command to change the runpath of an object, are safe, and can be carried out without the sort of risk detailed in this section.

Notes

Not every ELF operation supported by elfedit can be successfully carried out on every ELF object. elfedit is constrained by the existing sections found in the file.

One area of particular interest is that elfedit might not be able to modify the runpath of a given object. To modify a runpath, the following must be true:

Older objects do not have the extra space necessary to complete such operations. The space necessary to do so was introduced in the Solaris Express Community Edition release.

When an operation fails, the detailed information printed using the -d (debug) option can be very helpful in uncovering the reason why.

elfedit modules follow a convention by which commands that directly manipulate a field in an ELF structure have the same name as the field, while commands that implement higher level concepts do not. For instance, the command to manipulate the e_flags field in the ELF header is named ehdr:e_flags. Therefore, you generally find the command to modify ELF fields by identifying the module and looking for a command with the name of the field.