Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 May 2010 19:06:59 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>
Cc:        freebsd-amd64@freebsd.org
Subject:   Re: amd64/127276: ldd invokes linux yes
Message-ID:  <20100504160659.GO23646@deviant.kiev.zoral.com.ua>
In-Reply-To: <201005040400.o44409pW050045@freefall.freebsd.org>
References:  <201005040400.o44409pW050045@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--JfVplkuTfB13Rsg5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 GNA=
TS.
>=20
> From: Shuichi KITAGUCHI <ki@hh.iij4u.or.jp>
> To: bug-followup@FreeBSD.org, kamikaze@bsdforen.de
> Cc: =20
> Subject: Re: amd64/127276: ldd invokes linux yes
> Date: Tue, 04 May 2010 12:21:45 +0900 (JST)
>=20
>  ----Next_Part(Tue_May_04_12_21_45_2010_795)--
>  Content-Type: Text/Plain; charset=3Dus-ascii
>  Content-Transfer-Encoding: 7bit
> =20
>  Hello,
> =20
>  I investigate this problem today and found that Linux's ld.so
>  accepts "LD_TRACE_LOADED_OBJECTS".
> =20
>  % env LD_TRACE_LOADED_OBJECTS=3Dyes /compat/linux/bin/ls
>          librt.so.1 =3D> /lib/librt.so.1 (0x28087000)
>          libselinux.so.1 =3D> /lib/libselinux.so.1 (0x28092000)
>          libcap.so.2 =3D> /lib/libcap.so.2 (0x280af000)
>          libacl.so.1 =3D> /lib/libacl.so.1 (0x280b4000)
>          libc.so.6 =3D> /lib/libc.so.6 (0x280bc000)
>          libpthread.so.0 =3D> /lib/libpthread.so.0 (0x28234000)
>          /lib/ld-linux.so.2 (0x28063000)
>          libdl.so.2 =3D> /lib/libdl.so.2 (0x2824e000)
>          libattr.so.1 =3D> /lib/libattr.so.1 (0x28254000)
> =20
>  I think environment variable "LD_32_TRACE_LOADED_OBJECTS" is
>  FreeBSD specific, and "LD_TRACE_LOADED_OBJECTS" should be passed
>  to other binaries.
> =20
>  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.
> =20
> =20
>  --
>  Shuichi KITAGUCHI // kit@ysnb.net / ki@hh.iij4u.or.jp
> =20
>  ----Next_Part(Tue_May_04_12_21_45_2010_795)--
>  Content-Type: Text/X-Patch; charset=3Dus-ascii
>  Content-Transfer-Encoding: 7bit
>  Content-Disposition: inline; filename=3D"ldd.c.patch"
> =20
>  --- 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
>  =20
>   static int	is_executable(const char *fname, int fd, int *is_shlib,
>  -		    int *type);
>  +			      int *osabi, int *type);
>   static void	usage(void);
>  =20
>   #define	TYPE_UNKNOWN	0
>  @@ -177,14 +177,14 @@
>  =20
>   	rval =3D 0;
>   	for (; argc > 0; argc--, argv++) {
>  -		int fd, status, is_shlib, rv, type;
>  +		int fd, status, is_shlib, rv, type, osabi;
>  =20
>   		if ((fd =3D open(*argv, O_RDONLY, 0)) < 0) {
>   			warn("%s", *argv);
>   			rval |=3D 1;
>   			continue;
>   		}
>  -		rv =3D is_executable(*argv, fd, &is_shlib, &type);
>  +		rv =3D is_executable(*argv, fd, &is_shlib, &osabi, &type);
>   		close(fd);
>   		if (rv =3D=3D 0) {
>   			rval |=3D 1;
>  @@ -197,6 +197,8 @@
>   			break;
>   #if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED)
>   		case TYPE_ELF32:
>  +			if (osabi !=3D ELFOSABI_FREEBSD)
>  +				break;
>   			rval |=3D execldd32(*argv, fmt1, fmt2, aflag, vflag);
>   			continue;
>   #endif
>  @@ -267,7 +269,7 @@
>   }
>  =20
>   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);
>   	}
>  =20
>  +	*osabi =3D hdr.elf.e_ident[EI_OSABI];
>  +
>   #if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED)
>   	if ((size_t)n >=3D sizeof(hdr.elf32) && IS_ELF(hdr.elf32) &&
>   	    hdr.elf32.e_ident[EI_CLASS] =3D=3D ELFCLASS32) {
> =20
>  ----Next_Part(Tue_May_04_12_21_45_2010_795)----
> _______________________________________________
> freebsd-amd64@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-amd64
> To unsubscribe, send any mail to "freebsd-amd64-unsubscribe@freebsd.org"

--JfVplkuTfB13Rsg5
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEYEARECAAYFAkvgRiIACgkQC3+MBN1Mb4hmFwCfbUscw0p2YAO3+RDAmqQGStVb
r2wAoICIrmgP455BAFlvA694+pw87TZy
=PKxD
-----END PGP SIGNATURE-----

--JfVplkuTfB13Rsg5--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100504160659.GO23646>