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

Bug#155779: mklibs can't find dynamic linker


The reason that we aren't currently finding the dynamic linker in this
case is that no pic libs are installed for libc, and it is the line
around 407:
                if not ldlib:
                    ldlib = "ld-" + re.match("libc-(.*).so", so_file_name).group(1) + ".so"

that sets ldlib if not already set. That line is only executed when
actually making reduced libs (that is, not a simple copy).

Can we figure out the dynamic linker automatically, every time?  The
above line could be moved to be executed unconditionally, but it is
depending on a mapping between libc's name and the name of the dynamic
linker that doesn't always hold (not for uClibc, for example).  The
included patch works for i386 glibc and uClibc, FWIW.  I don't know if
the INTERP header (where the message I am grabbing comes from) is a
portable way of getting this information either, but it looks better
than assuming the linker has a specific name based on the name of the
C library.


Index: mklibs.py
RCS file: /cvs/debian-boot/mklibs/mklibs.py,v
retrieving revision 1.10
diff -u -p -r1.10 mklibs.py
--- mklibs.py	2002/08/07 17:14:47	1.10
+++ mklibs.py	2002/08/07 19:47:17
@@ -274,6 +274,22 @@ for prog in proglist:
         objects[inode] = prog
+if ldlib == None:
+    pattern = re.compile(".*Requesting program interpreter:.*/([^\]/]+).*")
+    for obj in objects.values():
+        output = command(target + "readelf", "--program-headers", obj)
+	for x in output:
+	    match = pattern.match(x)
+	    if match:
+	        ldlib = match.group(1)
+                debug(DEBUG_NORMAL, "I: Using", ldlib, "as dynamic linker.")
+	        break
+	if ldlib:
+	    break
+if ldlib == None:
+    sys.exit("E: Dynamic linker not found, aborting.")
 passnr = 1
 while 1:
     debug(DEBUG_NORMAL, "I: library reduction pass", `passnr`)

Reply to: