Re: ifunc function in home-build glibc, executables linked against that libm.a and PIE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jan 19, 2013 at 10:36 AM, Toon Moene <toon@xxxxxxxxx> wrote:
>
> gfortran -g -Wl,-M  master.o C_code.o _odb_glue.o -Wl,--start-group
> -L/scratch/harmonie/hm_home/trunk/lib/linux.gfortran.mpi/src -lxrd -lxla
> -ltfl -ltal -lsur -larp -lald -lbla -lmpa -lmse -lsurfex -lbip -lsat -luti
> -lodb -lodbport -lCCMA -lECMA -Wl,--end-group dummies.o \
>          -L/scratch/harmonie/hm_home/trunk/lib/linux.gfortran.mpi/src
> -lodbdummy -L/scratch/harmonie/hm_home/trunk/lib/linux.gfortran.mpi/src
> -lrgb -lgribex -lbufr -L/home/harmonie/grib_api -lgrib_api_f90 -lgrib_api
> -lnetcdff -lnetcdf -llapack -lblas -lmpi_f90 -lmpi_f77 -lmpi -lpthread
> /home/toon/myglibc/lib/libm.a -o
> /scratch/harmonie/hm_home/trunk/lib/linux.gfortran.mpi/src/MASTERODB >
> /scratch/harmonie/hm_home/trunk/lib/linux.gfortran.mpi/src/load.map
> /usr/bin/ld: dynamic STT_GNU_IFUNC symbol `cos' with pointer equality in
> `/home/toon/myglibc/lib/libm.a(s_sin.o)' can not be used when making an
> executable; recompile with -fPIE and relink with -pie
> collect2: error: ld returned 1 exit status

I have no idea why this is happening to you but I can tell you what it
means.  The symbol "cos" has been defined as an IFUNC symbol in your
library.  That means that the actual value of "cos" will be selected
at runtime, presumably with a version of "cos" that will execute
quickly on the processor as detected at runtime.  Furthermore, some
piece of code in the library is using "cos" in some way other than
simply calling it, e.g., taking the address of the function.  As it
happens, taking the address of an IFUNC function in code not compiled
with -fpie or -fpic is problematic, because that code will produce
different addresses in different shared libraries, meaning that
function pointer equality will not work.  The linker is telling you
about this problem, and telling you to fix it by recompiling with
-fpie.

I think the right fix for you is going to be to recompile the contents
of libm.a with the -fpie option.  In general since your C library is
using IFUNC symbols, and apparently using them in ways other than
calling them, it should be compiled with -fpie.  I don't know why your
library makes "cos" an IFUNC symbol; I don't see that in the glibc
sources I happen to have on hand.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux