Bug 17375 – colliding modules detected with binutils 2.28 linker and shared libraries
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-05-06T17:49:56Z
Last change time
2017-12-16T15:09:47Z
Assigned to
No Owner
Creator
Martin Nowak
Comments
Comment #0 by code — 2017-05-06T17:49:56Z
Happens with shared libraries on Arch Linux w/ binutils 2.28.
Apparently copy relocated moduleinfos now end up as data symbols instead of bss.
Comment #1 by dlang-bugzilla — 2017-05-06T20:04:06Z
On Arch Linux, this is reproducible with binutils 2.28.0, but not reproducible with 2.27.
Comment #2 by dlang-bugzilla — 2017-05-07T00:02:45Z
Bisecting binutils points to:
9acc85a62eb76c270724bba15c889d2d05567b6a is the first bad commit
commit 9acc85a62eb76c270724bba15c889d2d05567b6a
Author: Alan Modra <[email protected]>
Date: Wed Dec 28 17:04:15 2016 +1030
Use dynrelro for symbols in relro sections too
PR ld/20995
bfd/
* elflink.c (elf_link_add_object_symbols): Mark relro sections
in dynamic objects SEC_READONLY.
ld/
* testsuite/ld-elf/pr20995c.s: New test file.
* testsuite/ld-elf/pr20995-2so.r: Likewise.
* testsuite/ld-elf/elf.exp: Run it.
:040000 040000 decd212336814caf0562835700a42a8f6d3e5e34 8f7d306bf5df00e27fa208f6dc66e345ca5064e8 M bfd
:040000 040000 c101f8812c1c65893d81807818e3bfb8acd3ae1e decd54f18574d1b7d39c8888ff551cbde3d3cbe0 M ld
Comment #6 by dlang-bugzilla — 2017-05-18T18:35:50Z
(In reply to Martin Nowak from comment #5)
> The PIE (-fPIC) workaround seems a lot simpler.
Sorry, yeah, I meant when modifying the build command is not feasible (e.g. when bisecting / doing regression testing).
Do you think you could submit a PR to fix the Druntime and Phobos Makefiles? I'd also like to make Digger apply that patch automatically so it's possible to run tests of older versions of D with newer binutils.
Comment #8 by dlang-bugzilla — 2017-06-16T23:24:24Z
(In reply to Martin Nowak from comment #7)
> Maybe you had a different git repo, my bisect ended at commit
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;
> h=9acc85a62eb76c270724bba15c889d2d05567b6a.
No idea what you mean; that's the same commit I mentioned in comment 2 above.
Comment #10 by thomas.mader — 2017-07-31T07:48:27Z
Had the same problem with binutils 2.28 and dmd 2.075.0 on NixOS with druntime and phobos.
Working around the problem as suggested with
make -f posix.mak PIC=-fPIC INSTALL_DIR=$out DMD=$DMD
works for phobos.
But for druntime I needed to patch a Makefile,
substituteInPlace druntime/test/common.mak \
--replace "DFLAGS:=" "DFLAGS:=-fPIC "
otherwise the link test in the druntime unittests would fail when running with
make -f posix.mak unittest PIC=-fPIC DMD=$DMD BUILD=release
Comment #11 by github-bugzilla — 2017-09-18T16:16:11Z
If that detection has been removed, does this mean we can revert to compiling without -fPIC again? It's slows down code on x86. I put it in dmd.conf for Gentoo by default, because shared libraries would not load due to this bug. So can we revert to the pre binutils 2.28 procedures now for druntime, Phobos, dmd.conf?
Comment #15 by greeenify — 2017-12-16T15:09:47Z
-fPIC is only the default for x86_64 on Linux and required due to PIE hardening on many distributions.