The following reply was made to PR amd64/127276; it has been noted by GNATS.

From: Shuichi KITAGUCHI <k...@hh.iij4u.or.jp>
To: bug-follo...@freebsd.org, kamik...@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 // k...@ysnb.net / k...@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@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-amd64
To unsubscribe, send any mail to "freebsd-amd64-unsubscr...@freebsd.org"

Reply via email to