add 'ldd' to cross-tools ?

2012-01-04 Thread Luigi Rizzo
Hi,
in doing cross-builds of picobsd, i found i need a cross-version
of ldd so i can run it on the host to detect which shared libraries
are used by binaries on the target architecture
(for amd64-i386 there is a partial workaround, but don't know
if it works in other cases)

Is there any concern in adding usr.bin/ldd to the list of cross-tools
in Makefile.inc1 ? It is a small program and should not increase
the build time in any significant way.

Otherwise, does anyone know the magic to build a cross-arch
version of a program in the FreeBSD source tree ?

cheers
luigi
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: add 'ldd' to cross-tools ?

2012-01-04 Thread Garrett Cooper
On Wed, Jan 4, 2012 at 2:23 PM, Luigi Rizzo ri...@iet.unipi.it wrote:
 Hi,
 in doing cross-builds of picobsd, i found i need a cross-version
 of ldd so i can run it on the host to detect which shared libraries
 are used by binaries on the target architecture
 (for amd64-i386 there is a partial workaround, but don't know
 if it works in other cases)

 Is there any concern in adding usr.bin/ldd to the list of cross-tools
 in Makefile.inc1 ? It is a small program and should not increase
 the build time in any significant way.

 Otherwise, does anyone know the magic to build a cross-arch
 version of a program in the FreeBSD source tree ?

objdump IMO is a lot easier to parse and it's already built via cross-tools:

$ objdump -x `which tar` | awk '$1 == NEEDED { print $2 }'
libarchive.so.5
libbz2.so.4
libz.so.6
liblzma.so.5
libbsdxml.so.4
libcrypto.so.6
libc.so.7

Thanks,
-Garrett
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: add 'ldd' to cross-tools ?

2012-01-04 Thread Garrett Cooper
On Wed, Jan 4, 2012 at 2:29 PM, Luigi Rizzo ri...@iet.unipi.it wrote:
 On Wed, Jan 04, 2012 at 02:10:36PM -0800, Garrett Cooper wrote:
 On Wed, Jan 4, 2012 at 2:23 PM, Luigi Rizzo ri...@iet.unipi.it wrote:
  Hi,
  in doing cross-builds of picobsd, i found i need a cross-version
  of ldd so i can run it on the host to detect which shared libraries
  are used by binaries on the target architecture
  (for amd64-i386 there is a partial workaround, but don't know
  if it works in other cases)
 
  Is there any concern in adding usr.bin/ldd to the list of cross-tools
  in Makefile.inc1 ? It is a small program and should not increase
  the build time in any significant way.
 
  Otherwise, does anyone know the magic to build a cross-arch
  version of a program in the FreeBSD source tree ?

 objdump IMO is a lot easier to parse and it's already built via cross-tools:

 $ objdump -x `which tar` | awk '$1 == NEEDED { print $2 }'
 libarchive.so.5
 libbz2.so.4
 libz.so.6
 liblzma.so.5
 libbsdxml.so.4
 libcrypto.so.6
 libc.so.7

 wonderful, thanks!

Np! The only gap with both of these tools is that you have to
watch out for dl_open'ed binaries as they won't show up in ldd/objdump
-x. If I could figure out how to detect these with a command line
tool, I would be set for life :).
Thanks,
-Garrett
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: add 'ldd' to cross-tools ?

2012-01-04 Thread Luigi Rizzo
On Wed, Jan 04, 2012 at 02:30:27PM -0800, Garrett Cooper wrote:
 On Wed, Jan 4, 2012 at 2:29 PM, Luigi Rizzo ri...@iet.unipi.it wrote:
...
  $ objdump -x `which tar` | awk '$1 == NEEDED { print $2 }'
  libarchive.so.5
  libbz2.so.4
  libz.so.6
  liblzma.so.5
  libbsdxml.so.4
  libcrypto.so.6
  libc.so.7
 
  wonderful, thanks!
 
 Np! The only gap with both of these tools is that you have to
 watch out for dl_open'ed binaries as they won't show up in ldd/objdump
 -x. If I could figure out how to detect these with a command line
 tool, I would be set for life :).

and the other thing, i just realized, is that once you locate
the libraries you should run objdump recursively to find
out further dependencies. Perhaps ldd sorts this out by itself ?

cheers
luigi
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: add 'ldd' to cross-tools ?

2012-01-04 Thread Oleksandr Tymoshenko

On 04/01/2012 2:23 PM, Luigi Rizzo wrote:

Hi,
in doing cross-builds of picobsd, i found i need a cross-version
of ldd so i can run it on the host to detect which shared libraries
are used by binaries on the target architecture
(for amd64-i386 there is a partial workaround, but don't know
if it works in other cases)

Is there any concern in adding usr.bin/ldd to the list of cross-tools
in Makefile.inc1 ? It is a small program and should not increase
the build time in any significant way.

Otherwise, does anyone know the magic to build a cross-arch
version of a program in the FreeBSD source tree ?


AFAIK ldd can't be used as a cross-tool. It sets some env
variables for loader (e.g. ld-elf.so), calls execve
or dlopen and relies on ld.so to print all the required data.
You might get away with it on amd64/i386 host-target pair
but it's not going to work for i386/arm or i386/mips pair.


___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: add 'ldd' to cross-tools ?

2012-01-04 Thread Jilles Tjoelker
On Wed, Jan 04, 2012 at 11:58:15PM +0100, Luigi Rizzo wrote:
 On Wed, Jan 04, 2012 at 02:30:27PM -0800, Garrett Cooper wrote:
  On Wed, Jan 4, 2012 at 2:29 PM, Luigi Rizzo ri...@iet.unipi.it wrote:
 ...
   $ objdump -x `which tar` | awk '$1 == NEEDED { print $2 }'
   libarchive.so.5
   libbz2.so.4
   libz.so.6
   liblzma.so.5
   libbsdxml.so.4
   libcrypto.so.6
   libc.so.7

   wonderful, thanks!

  Np! The only gap with both of these tools is that you have to
  watch out for dl_open'ed binaries as they won't show up in ldd/objdump
  -x. If I could figure out how to detect these with a command line
  tool, I would be set for life :).

 and the other thing, i just realized, is that once you locate
 the libraries you should run objdump recursively to find
 out further dependencies. Perhaps ldd sorts this out by itself ?

ldd basically sets LD_TRACE_LOADED_OBJECTS=yes and runs the program
(after having checked it is a dynamic executable). This means it will
not work as a cross tool. Upsides are that it is simple and it shows
exactly what rtld would do (because it is rtld), handling things like
/var/run/ld-elf.so.hints, LD_LIBRARY_PATH and pathnames hardcoded into
objects.

You will have to run objdump (or readelf) recursively. (Note that there
are also use cases where just the non-recursive NEEDED tags are
appropriate, not all objects that happen to be loaded.)

-- 
Jilles Tjoelker
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org