From owner-freebsd-amd64@FreeBSD.ORG Tue May 4 04:00:09 2010 Return-Path: Delivered-To: freebsd-amd64@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B2389106566C for ; Tue, 4 May 2010 04:00:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 992248FC22 for ; Tue, 4 May 2010 04:00:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o44409dj050046 for ; Tue, 4 May 2010 04:00:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o44409pW050045; Tue, 4 May 2010 04:00:09 GMT (envelope-from gnats) Date: Tue, 4 May 2010 04:00:09 GMT Message-Id: <201005040400.o44409pW050045@freefall.freebsd.org> To: freebsd-amd64@FreeBSD.org From: Shuichi KITAGUCHI Cc: Subject: Re: amd64/127276: ldd invokes linux yes X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Shuichi KITAGUCHI List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2010 04:00:09 -0000 The following reply was made to PR amd64/127276; it has been noted by GNATS. From: Shuichi KITAGUCHI To: bug-followup@FreeBSD.org, kamikaze@bsdforen.de Cc: Subject: Re: amd64/127276: ldd invokes linux yes Date: Tue, 04 May 2010 12:21:45 +0900 (JST) ----Next_Part(Tue_May_04_12_21_45_2010_795)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello, I investigate this problem today and found that Linux's ld.so accepts "LD_TRACE_LOADED_OBJECTS". % env LD_TRACE_LOADED_OBJECTS=yes /compat/linux/bin/ls librt.so.1 => /lib/librt.so.1 (0x28087000) libselinux.so.1 => /lib/libselinux.so.1 (0x28092000) libcap.so.2 => /lib/libcap.so.2 (0x280af000) libacl.so.1 => /lib/libacl.so.1 (0x280b4000) libc.so.6 => /lib/libc.so.6 (0x280bc000) libpthread.so.0 => /lib/libpthread.so.0 (0x28234000) /lib/ld-linux.so.2 (0x28063000) libdl.so.2 => /lib/libdl.so.2 (0x2824e000) libattr.so.1 => /lib/libattr.so.1 (0x28254000) I think environment variable "LD_32_TRACE_LOADED_OBJECTS" is FreeBSD specific, and "LD_TRACE_LOADED_OBJECTS" should be passed to other binaries. Attached patch is reasonable? -- Shuichi KITAGUCHI // kit@ysnb.net / ki@hh.iij4u.or.jp ----Next_Part(Tue_May_04_12_21_45_2010_795)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ldd.c.patch" --- ldd.c.old 2009-09-19 21:45:17.000000000 +0900 +++ ldd.c 2010-05-04 11:48:42.000000000 +0900 @@ -65,7 +65,7 @@ #endif static int is_executable(const char *fname, int fd, int *is_shlib, - int *type); + int *osabi, int *type); static void usage(void); #define TYPE_UNKNOWN 0 @@ -177,14 +177,14 @@ rval = 0; for (; argc > 0; argc--, argv++) { - int fd, status, is_shlib, rv, type; + int fd, status, is_shlib, rv, type, osabi; if ((fd = open(*argv, O_RDONLY, 0)) < 0) { warn("%s", *argv); rval |= 1; continue; } - rv = is_executable(*argv, fd, &is_shlib, &type); + rv = is_executable(*argv, fd, &is_shlib, &osabi, &type); close(fd); if (rv == 0) { rval |= 1; @@ -197,6 +197,8 @@ break; #if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED) case TYPE_ELF32: + if (osabi != ELFOSABI_FREEBSD) + break; rval |= execldd32(*argv, fmt1, fmt2, aflag, vflag); continue; #endif @@ -267,7 +269,7 @@ } static int -is_executable(const char *fname, int fd, int *is_shlib, int *type) +is_executable(const char *fname, int fd, int *is_shlib, int *osabi, int *type) { union { struct exec aout; @@ -300,6 +302,8 @@ return (1); } + *osabi = hdr.elf.e_ident[EI_OSABI]; + #if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED) if ((size_t)n >= sizeof(hdr.elf32) && IS_ELF(hdr.elf32) && hdr.elf32.e_ident[EI_CLASS] == ELFCLASS32) { ----Next_Part(Tue_May_04_12_21_45_2010_795)----