amd64/127276: ldd invokes linux yes

Kostik Belousov kostikbel at gmail.com
Tue May 4 16:07:06 UTC 2010


On Tue, May 04, 2010 at 04:00:09AM +0000, Shuichi KITAGUCHI wrote:
> The following reply was made to PR amd64/127276; it has been noted by GNATS.
> 
> From: Shuichi KITAGUCHI <ki at hh.iij4u.or.jp>
> To: bug-followup at FreeBSD.org, kamikaze at 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?
No, what you test for is the old branding method. Relatively modern
FreeBSD kernels deduce the ABI of the binary from the .note section.

Also please note that there are hybrid systems like Debian/kFreeBSD,
that also use .note to brand the binary.
>  
>  
>  --
>  Shuichi KITAGUCHI // kit at ysnb.net / ki at 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)----
> _______________________________________________
> freebsd-amd64 at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-amd64
> To unsubscribe, send any mail to "freebsd-amd64-unsubscribe at freebsd.org"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-amd64/attachments/20100504/ad15e78f/attachment.pgp


More information about the freebsd-amd64 mailing list