Bug 1289812 - ld.so fails to load go binary when using LD_BIND_NOW=1
ld.so fails to load go binary when using LD_BIND_NOW=1
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
All Linux
unspecified Severity low
: ---
: ---
Assigned To: Carlos O'Donell
Fedora Extras Quality Assurance
: Patch
Depends On:
  Show dependency treegraph
Reported: 2015-12-08 21:24 EST by Carlos O'Donell
Modified: 2016-11-24 09:34 EST (History)
8 users (show)

See Also:
Fixed In Version: glibc-2.23
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-11-24 09:34:07 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Sourceware 14341 None None None Never

  None (edit)
Description Carlos O'Donell 2015-12-08 21:24:52 EST
Create a go program that uses cgo to reference external API's like those core glibc API's which in turn use NSS. This causes the the go runtime to create a real dynamic binary, but this binary has a gap between .rela and .rela.plt, which F23's version of ld.so does not support.

cat >> print-user-home.go <<EOF
package main

import "fmt"
import "os/user"
import "log"

func main() {
    myself, err := user.Current()
    if (err != nil) {
        log.Fatal (err)

go build print-user-home.go 


ldd print-user-home
	linux-vdso.so.1 (0x00007ffdac7f4000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdf4f197000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fdf4edd6000)
	/lib64/ld-linux-x86-64.so.2 (0x0000555c63c7d000)

LD_BIND_NOW=1 ./print-user-home 
./print-user-home: error while loading shared libraries: unexpected reloc type 0x005a4018

This is upstream bug 14341, adding here for posterity, but without any real user reports we'll park it here for documentation purposes.

From fa19d5c48a6b36518ce68412e3bdde6bfa8aa4a6 Mon Sep 17 00:00:00 2001
From: Petar Jovanovic <petar.jovanovic@rt-rk.com>
Date: Wed, 20 Aug 2014 00:50:54 +0200
Subject: [PATCH] Fix dynamic linker issue with bind-now

Fix the bind-now case when DT_REL and DT_JMPREL sections are separate
and there is a gap between them.

	[BZ #14341]
	* elf/dynamic-link.h (elf_machine_lazy_rel): Properly handle the
	case when there is a gap between DT_REL and DT_JMPREL sections.
	* sysdeps/x86_64/Makefile (tests): Add tst-split-dynreloc.
	(LDFLAGS-tst-split-dynreloc): New.
	(tst-split-dynreloc-ENV): Likewise.
	* sysdeps/x86_64/tst-split-dynreloc.c: New file.
	* sysdeps/x86_64/tst-split-dynreloc.lds: Likewise.
Comment 1 Carlos O'Donell 2015-12-08 21:30:55 EST
The code is question is generic, so marking "All" hardware.
Comment 2 Jakub Jelinek 2015-12-09 02:28:39 EST
Why change glibc?  IMNSHO that is clearly a bug in the tool that generated the binary/library.
Comment 3 Florian Weimer 2015-12-09 04:28:00 EST
(In reply to Jakub Jelinek from comment #2)
> Why change glibc?  IMNSHO that is clearly a bug in the tool that generated
> the binary/library.

There is a pre-existing comment in the glibc source code that this layout has to be supported:

/* On some machines, notably SPARC, DT_REL* includes DT_JMPREL in its
   range.  Note that according to the ELF spec, this is completely legal!

   We are guarenteed that we have one of three situations.  Either DT_JMPREL
   comes immediately after DT_REL*, or there is overlap and DT_JMPREL
   consumes precisely the very end of the DT_REL*, or DT_JMPREL and DT_REL*
   are completely separate and there is a gap between them.  */
Comment 4 Fedora End Of Life 2016-11-24 09:05:00 EST
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 5 Florian Weimer 2016-11-24 09:34:07 EST
This was fixed in Fedora 24.

Note You need to log in before you can comment on or make changes to this bug.