Discussion:
elfedit: invalid option -- e
(too old to reply)
n***@gmail.com
2020-07-20 03:32:20 UTC
Permalink
Hi Everyone,

I'm trying to build Perl 5.32.0 from sources on Solaris 11.3 i86pc. Perl screws up runpath options in LDFLAGS so I need to fix them using elfedit(1). Perl won't fix their bug so waiting is not an option; see https://github.com/Perl/perl5/issues/17978.

I have two runpaths as follows. '$ORIGIN' is a literal and includes the dollar sign. Also see https://blogs.oracle.com/solaris/avoiding-ldlibrarypath%3a-the-options-v2.

RUNPATH="\$ORIGIN/../lib:/export/home/jwalton/tmp/ok2delete/lib"

When I run elfedit manually the runpaths are changed. When elfedit is scripted I get:

elfedit: invalid option -- e
Usage: elfedit <option(s)> elffile(s)
Update the ELF header of ELF files
The options are:
--input-mach <machine> Set input machine type to <machine>
--output-mach <machine> Set output machine type to <machine>
...

There's not much to the script. It finds programs and shared libraries, and runs elfedit on them.

What am I doing wrong here?

==========

THIS_RUNPATH="\$ORIGIN/../lib:/export/home/jwalton/tmp/ok2delete/lib"
echo "Using \"$THIS_RUNPATH\""

# Non-anemic grep
GREP=/usr/gnu/bin/grep

# Find find programs and libraries using the shell wildcard. Some programs
# and libraries are _not_ executable and get missed in the do loop.
IFS="" find . -type f -name '*' -print | while read -r file
do
# Quick smoke test. Object files have ELF signature.
if [[ $(echo "$file" | $GREP -E '\.o$') ]]; then continue; fi

# Check for ELF signature
sig=$(cut -b 2-4 "$file" | head -n 1)
if [[ "x$sig" != "xELF" ]]; then continue; fi
echo "$file" | sed 's/^\.\///g'

chmod a+w "$file"

elfedit -e "dyn:rpath $THIS_RUNPATH" "$file"
elfedit -e "dyn:runpath $THIS_RUNPATH" "$file"

chmod go-w "$file"
done
Jeffrey Walton
2020-07-20 10:14:03 UTC
Permalink
Post by n***@gmail.com
elfedit: invalid option -- e
Usage: elfedit <option(s)> elffile(s)
Update the ELF header of ELF files
--input-mach <machine> Set input machine type to <machine>
--output-mach <machine> Set output machine type to <machine>
...
This problem was due to GNU's editelf in /usr/gnu/bin. /usr/gnu/bin was on-path first to get a non-anemic awk, sed and grep in my script.

Once I switched to /usr/bin/editelf, everything worked as expected.

Jeff
Post by n***@gmail.com
Hi Everyone,
I'm trying to build Perl 5.32.0 from sources on Solaris 11.3 i86pc. Perl screws up runpath options in LDFLAGS so I need to fix them using elfedit(1). Perl won't fix their bug so waiting is not an option; see https://github.com/Perl/perl5/issues/17978.
I have two runpaths as follows. '$ORIGIN' is a literal and includes the dollar sign. Also see https://blogs.oracle.com/solaris/avoiding-ldlibrarypath%3a-the-options-v2.
RUNPATH="\$ORIGIN/../lib:/export/home/jwalton/tmp/ok2delete/lib"
elfedit: invalid option -- e
Usage: elfedit <option(s)> elffile(s)
Update the ELF header of ELF files
--input-mach <machine> Set input machine type to <machine>
--output-mach <machine> Set output machine type to <machine>
...
There's not much to the script. It finds programs and shared libraries, and runs elfedit on them.
What am I doing wrong here?
==========
THIS_RUNPATH="\$ORIGIN/../lib:/export/home/jwalton/tmp/ok2delete/lib"
echo "Using \"$THIS_RUNPATH\""
# Non-anemic grep
GREP=/usr/gnu/bin/grep
# Find find programs and libraries using the shell wildcard. Some programs
# and libraries are _not_ executable and get missed in the do loop.
IFS="" find . -type f -name '*' -print | while read -r file
do
# Quick smoke test. Object files have ELF signature.
if [[ $(echo "$file" | $GREP -E '\.o$') ]]; then continue; fi
# Check for ELF signature
sig=$(cut -b 2-4 "$file" | head -n 1)
if [[ "x$sig" != "xELF" ]]; then continue; fi
echo "$file" | sed 's/^\.\///g'
chmod a+w "$file"
elfedit -e "dyn:rpath $THIS_RUNPATH" "$file"
elfedit -e "dyn:runpath $THIS_RUNPATH" "$file"
chmod go-w "$file"
done
Jeffrey Walton
2020-07-20 10:15:39 UTC
Permalink
Post by Jeffrey Walton
Post by n***@gmail.com
elfedit: invalid option -- e
Usage: elfedit <option(s)> elffile(s)
Update the ELF header of ELF files
--input-mach <machine> Set input machine type to <machine>
--output-mach <machine> Set output machine type to <machine>
...
This problem was due to GNU's editelf in /usr/gnu/bin. /usr/gnu/bin was on-path first to get a non-anemic awk, sed and grep in my script.
Once I switched to /usr/bin/editelf, everything worked as expected.
s/editelf/elfedit/g

Loading...