Re: libpari-gmp.so.2.13.0 not being built with RUNPATH

Jeffrey Walton <[email protected]>
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <CAH8yC8m0uqQLxL=qB_Lb1oqC0vo-sFY5zVTQTvu+260WnhR-Bw@mail.gmail.com>
On Thu, Dec 31, 2020 at 9:43 PM Jeffrey Walton <[email protected]> wrote:
> ...
> gcc  -o "/home/jwalton/Build-Scripts/pari-2.13.0/Olinux-x86_64"/libpari-gmp.so.2.13.0
> -shared  -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer  -g2 -O2
> -fsanitize=address -fno-omit-frame-pointer -march=native -fPIC
> -pthread -I/home/jwalton/ok2delete-asan/include -DNDEBUG -DTEST_ASAN=1
> -fPIC -Wl,-shared,-soname=libpari-gmp.so.7  mpker.o mpinl.o alglin1.o
> alglin2.o alglin3.o aprcl.o arith1.o arith2.o base1.o base2.o base3.o
> base4.o base5.o bb_group.o bb_hnf.o bern.o bibli1.o bibli2.o bit.o
> bnflog.o bnfunits.o buch1.o buch2.o buch3.o buch4.o char.o concat.o
> crvwtors.o dirichlet.o ecpp.o ellanal.o elliptic.o ellisog.o
> ellpadic.o ellpadiclambdamu.o ellsea.o elltors.o F2v.o F2x.o F2xqE.o
> FF.o Fle.o Flv.o Flx.o FlxqE.o Flxq_log.o FlxX.o FpE.o FpV.o FpX.o
> FpX_factor.o FpXQX_factor.o FpXX.o galconj.o gen1.o gen2.o gen3.o
> Hensel.o hnf_snf.o hyperell.o hypergeom.o ifactor1.o kummer.o lfun.o
> lfunquad.o lfunutils.o lll.o map.o matperm.o mellininv.o mftrace.o
> modsym.o msfarey.o nffactor.o perm.o polarit1.o polarit2.o polarit3.o
> polclass.o polmodular.o prime.o Qfb.o qfisom.o qfsolve.o QX_factor.o
> random.o RgV.o RgX.o rootpol.o Ser.o subcyclo.o subfield.o subgroup.o
> trans1.o trans2.o trans3.o volcano.o zetamult.o ZG.o ZV.o ZX.o anal.o
> compile.o default.o es.o eval.o forprime.o gplib.o hash.o init.o
> intnum.o members.o paricfg.o pariinl.o parse.o readline.o str.o
> sumiter.o algebras.o elldata.o ellfromeqn.o forperm.o forsubset.o
> galois.o galpol.o genus2red.o groupid.o krasner.o mpqs.o part.o
> ratpoints.o stark.o thue.o mt.o single.o plotport.o plottty.o -lc -lm
> -L/home/jwalton/ok2delete-asan/lib -lgmp    -lm
>
> And:
>
>     $ find . -name libpari-gmp.so.2.13.0
>     ./pari-2.13.0/Olinux-x86_64/libpari-gmp.so.2.13.0
>     $ readelf -d pari-2.13.0/Olinux-x86_64/libpari-gmp.so.2.13.0 |
> grep -E 'RPATH|RUNPATH'
>     $
>
> No RPATH or RUNPATH. Without the RPATH or RUNPATH, then the wrong
> libraries will be loaded at runtime by the dynamic linker.
>
> Here's what I expect to see (using GMP as an example):
>
>     $ readelf -d ~/ok2delete-asan/lib/libgmp.so.10.4.1 | grep -E 'RPATH|RUNPATH'
>      0x000000000000001d (RUNPATH)            Library runpath:
> [$ORIGIN/../lib:/home/jwalton/ok2delete-asan/lib]
> ...
> I am fairly certain the recipe for libpari-gmp.so.2.13.0 needs to be
> fixed. It must use LDFLAGS. There may be other problems, but this one
> is the first that needs to be fixed.

There were two problems. First, my LDFLAGS were not used in the
dynamic library recipe. Second, something blew away my LIBS.

Here's the patch I used to fix Makefile.SH:
https://github.com/noloader/Build-Scripts/blob/master/patch/parigp.patch.
I also had to use XXX_LIBS because the build gear was blowing away my
LIBS.

With the patch installed the RUNPATH is expected:

$ readelf -d pari-2.13.0/Olinux-x86_64/libpari-gmp.so.2.13.0 | grep -E
'RPATH|RUNPATH'
 0x000000000000001d (RUNPATH)            Library runpath:
[$ORIGIN/../lib:/home/jwalton/ok2delete-asan/lib]

I've got some scripts to do better auditing. I should be able to run
them shortly.

Jeff
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.