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

Bug#698007: mklibs: Fix undefined reference to __dso_handle problem encountered with librt.so



Package: mklibs
Tags: patch

----- Forwarded message from Joe Seymour <jseymour@codesourcery.com> -----

Date: Sat, 12 Jan 2013 13:13:56 +0000
From: Joe Seymour <jseymour@codesourcery.com>
To: debian-boot@lists.debian.org
Subject: [PATCH] Fix undefined reference to __dso_handle problem encountered with librt.so
X-Mailing-List: <debian-boot@lists.debian.org> archive/latest/170862
X-CRM114-Status: Good  ( pR: 18.8078 )

[Please CC me on any responses]

When using mklibs on a simple test application I encountered the following error
when mklibs attempts to build a reduced librt.so:

/usr/lib64/libpthread_nonshared.a(pthread_atfork.oS): relocation R_X86_64_PC32
against undefined hidden symbol `__dso_handle' can not be used when making a
shared object
ld: final link failed: Bad value

Examining the link map for librt.so, when built by EGLIBC, I see the
__dso_handle definition used by it comes from crtbeginS.o, which isn't included
in the link because mklibs passes -nostartfiles.

In order to create a reduced librt.so that as closely as possible resembles the
original, it makes sense to include crtbeginS.o when dealing with librt.so.1.
This patch does that. crtendS.o is included as a requisite of crtbeginS.o.

Joe

diff --git a/src/mklibs b/src/mklibs
index 14ca02a..0b62136 100755
--- a/src/mklibs
+++ b/src/mklibs
@@ -617,6 +617,17 @@ while 1:
                 extra_post_obj.append(sysroot + libc_extras_dir + "/sofini.o")
                 symbols.add(ProvidedSymbol('__dso_handle', None, None, True))

+            if soname in ("librt.so.1"):
+                crtbegin = command(target + "gcc",
+                                   " ".join(gcc_options),
+                                   "-print-file-name=crtbeginS.o");
+                crtend = command(target + "gcc",
+                                 " ".join(gcc_options),
+                                 "-print-file-name=crtendS.o");
+                extra_pre_obj.append(" ".join(crtbegin))
+                extra_post_obj.append(" ".join(crtend))
+                symbols.add(ProvidedSymbol('__dso_handle', None, None, True))
+
             map_file = find_pic_map(library)
             if map_file:
                 extra_flags.append("-Wl,--version-script=" + map_file)


-- 
To UNSUBSCRIBE, email to debian-boot-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: [🔎] 50F16194.2090208@codesourcery.com">http://lists.debian.org/[🔎] 50F16194.2090208@codesourcery.com


----- End forwarded message -----

-- 


Attachment: signature.asc
Description: Digital signature


Reply to: