bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/25236] New: common symbol: don't consider definitions in shared


From: i at maskray dot me
Subject: [Bug ld/25236] New: common symbol: don't consider definitions in shared objects
Date: Sat, 30 Nov 2019 22:34:00 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=25236

            Bug ID: 25236
           Summary: common symbol: don't consider definitions in shared
                    objects
           Product: binutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: i at maskray dot me
  Target Milestone: ---

Originally reported at https://bugs.llvm.org//show_bug.cgi?id=43748 but it
turns out to be related to openmpi and GNU ld.
This affects the libopenmpi-dev package on Debian (it has patches to enable
symbol versioning).

(The Fortran declaration in ompi/include/mpif-f08-types.h is problematic.
character, dimension(1, 1), bind(C, name="mpi_fortran_argvs_null_") ::
MPI_ARGVS_NULL)


cat > a.s <<e
 .globl mpi_fortran_argvs_null_
 .comm mpi_fortran_argvs_null_,1,16
e
cat > b.s <<e
 .globl mpi_fortran_argvs_null_
 .comm mpi_fortran_argvs_null_,8,16
e
as a.s -o a.o                # st_size(mpi_fortran_argvs_null_) = 1
gcc -shared b.s -o b.so      # st_size(mpi_fortran_argvs_null_) = 8

# The GNU ld output takes st_size (8) in b.so into consideration.
ld.bfd -shared a.o b.so --version-script =(printf 'OMPI_2.0.0 {global:
mpi_fortran_argvs_null_;};') -o a.so
% readelf -W --dyn-syms a.so | grep mpi_fortran_argvs_null_
     1: 0000000000002000     8 OBJECT  GLOBAL DEFAULT    9
mpi_fortran_argvs_null_
# Note that .gnu.version marks  mpi_fortran_argvs_null_ as a local version
(VER_NDX_LOCAL).
% readelf -WV a.so

Version symbols section '.gnu.version' contains 3 entries:
 Addr: 00000000000001d6  Offset: 0x0001d6  Link: 3 (.dynsym)
  000:   0 (*local*)       0 (*local*)       2 (OMPI_2.0.0)
...


# gold and lld set st_size to 1, ignoring the definition in b.so
% readelf -W --dyn-syms a.gold.so | grep mpi_fortran_argvs_null_
     5: 0000000000002000     1 OBJECT  GLOBAL DEFAULT   10
mpi_fortran_argvs_null_@@OMPI_2.0.0
% readelf -W --dyn-syms a.lld.so | grep mpi_fortran_argvs_null_
     1: 0000000000003390     1 OBJECT  GLOBAL DEFAULT   10
mpi_fortran_argvs_null_@@OMPI_2.0.0

GNU ld and gold are a bit tolerant in that they allow shared definitions with
the local version (VER_NDX_LOCAL).

cat > c.s <<e
 cmp %r13, mpi_fortran_argvs_null_@gotpcrel(%rip)
e
as c.s -o c.o

% ld.bfd a.so c.o
ld.bfd: warning: b.so, needed by a.so, not found (try using -rpath or
-rpath-link)
ld.bfd: warning: cannot find entry symbol _start; defaulting to
0000000000401000
% ld.lld a.so c.o
ld.lld: error: corrupt input file: version definition index 0 for symbol
mpi_fortran_argvs_null_ is out of bounds
>>> defined in a.so

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]