Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

elfedit: invalid option -- e

38 views
Skip to first unread message

nolo...@gmail.com

unread,
Jul 19, 2020, 11:32:22 PM7/19/20
to
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

unread,
Jul 20, 2020, 6:14:04 AM7/20/20
to
> 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>
> ...

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

Jeffrey Walton

unread,
Jul 20, 2020, 6:15:40 AM7/20/20
to
On Monday, July 20, 2020 at 6:14:04 AM UTC-4, Jeffrey Walton wrote:
> > 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>
> > ...
>
> 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
0 new messages