public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* How to redirect the loader to another directory ?
@ 2010-05-13 11:35 robert song
  2010-05-13 13:46 ` Goswin von Brederlow
  2010-05-19 23:14 ` Mike Frysinger
  0 siblings, 2 replies; 10+ messages in thread
From: robert song @ 2010-05-13 11:35 UTC (permalink / raw)
  To: binutils

Hi, everyone.
Now I use qemu-arm to execute the target command on host.
But it should be executed as follows:
$ qemu-arm -E LD_LIBRARY_PATH=/target/usr/lib:/target/lib
/target/lib/ld-linux.so.3 /target/usr/bin/ls
Here /target/lib/ld-linux.so.3 should be specified, or else the host
one will be searched.

$ readelf -l /target/usr/bin/ls
(snip)
[Requesting program interpreter: /lib/ld-linux.so.3]
(snip)

Is there any method to redirect the loader to the directory I
specified (for exmaple, the root dir should be /target) without the
method above ?

Best Regards,
  robert

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to redirect the loader to another directory ?
  2010-05-13 11:35 How to redirect the loader to another directory ? robert song
@ 2010-05-13 13:46 ` Goswin von Brederlow
  2010-05-13 14:12   ` robert song
  2010-05-19 23:14 ` Mike Frysinger
  1 sibling, 1 reply; 10+ messages in thread
From: Goswin von Brederlow @ 2010-05-13 13:46 UTC (permalink / raw)
  To: robert song; +Cc: binutils

robert song <robertsong.japan@gmail.com> writes:

> Hi, everyone.
> Now I use qemu-arm to execute the target command on host.
> But it should be executed as follows:
> $ qemu-arm -E LD_LIBRARY_PATH=/target/usr/lib:/target/lib
> /target/lib/ld-linux.so.3 /target/usr/bin/ls
> Here /target/lib/ld-linux.so.3 should be specified, or else the host
> one will be searched.
>
> $ readelf -l /target/usr/bin/ls
> (snip)
> [Requesting program interpreter: /lib/ld-linux.so.3]
> (snip)
>
> Is there any method to redirect the loader to the directory I
> specified (for exmaple, the root dir should be /target) without the
> method above ?
>
> Best Regards,
>   robert

chroot

MfG
        Goswin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to redirect the loader to another directory ?
  2010-05-13 13:46 ` Goswin von Brederlow
@ 2010-05-13 14:12   ` robert song
  2010-05-13 18:14     ` Goswin von Brederlow
  0 siblings, 1 reply; 10+ messages in thread
From: robert song @ 2010-05-13 14:12 UTC (permalink / raw)
  To: Goswin von Brederlow; +Cc: binutils

> chroot

hi,Goswin,
it can't work.
$ sudo chroot /target/
chroot: cannot run command `/bin/bash': No such file or directory

/target/bin/bash was built by arm gcc.


Regards,
  robert

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to redirect the loader to another directory ?
  2010-05-13 14:12   ` robert song
@ 2010-05-13 18:14     ` Goswin von Brederlow
  2010-05-14  1:46       ` robert song
  0 siblings, 1 reply; 10+ messages in thread
From: Goswin von Brederlow @ 2010-05-13 18:14 UTC (permalink / raw)
  To: robert song; +Cc: binutils

robert song <robertsong.japan@gmail.com> writes:

>> chroot
>
> hi,Goswin,
> it can't work.
> $ sudo chroot /target/
> chroot: cannot run command `/bin/bash': No such file or directory
>
> /target/bin/bash was built by arm gcc.
>
>
> Regards,
>   robert

You would have to copy qemu and the required libs into the chroot and
call qemu in there or setup binfmt-misc for arm. Chroot on its own won't
work.

The other way I know would be to alter the linker script and recompile
binaries to use /target/lib/... as their dynamic loader. But that is
hardly practical.

MfG
        Goswin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to redirect the loader to another directory ?
  2010-05-13 18:14     ` Goswin von Brederlow
@ 2010-05-14  1:46       ` robert song
  2010-05-14  4:34         ` Goswin von Brederlow
  0 siblings, 1 reply; 10+ messages in thread
From: robert song @ 2010-05-14  1:46 UTC (permalink / raw)
  To: Goswin von Brederlow; +Cc: binutils

Thank you very much, Goswin.

> You would have to copy qemu and the required libs into the chroot and
> call qemu in there or setup binfmt-misc for arm. Chroot on its own won't
> work.

the required libs may conflict with the target file. Now I build a
static qemu-arm.

Host> cd qemu-0.12.3
Host> ./configure --target-list=arm-linux-user --static
Host> make
Host> sudo cp arm-linux-user/qemu-arm /target/bin/qemu-arm
Host> sudo cd /target
Host> sudo chroot . /bin/qemu-arm /bin/sh
Host> /bin/qemu-arm /bin/ls

Now, it can work.
Regarding to binfmt-misc, I don't know it.

>
> The other way I know would be to alter the linker script and recompile
> binaries to use /target/lib/... as their dynamic loader. But that is
> hardly practical.
>

Well, it's not a good idea.

Best Regards,
  robert

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to redirect the loader to another directory ?
  2010-05-14  1:46       ` robert song
@ 2010-05-14  4:34         ` Goswin von Brederlow
  0 siblings, 0 replies; 10+ messages in thread
From: Goswin von Brederlow @ 2010-05-14  4:34 UTC (permalink / raw)
  To: robert song; +Cc: Goswin von Brederlow, binutils

robert song <robertsong.japan@gmail.com> writes:

> Thank you very much, Goswin.
>
>> You would have to copy qemu and the required libs into the chroot and
>> call qemu in there or setup binfmt-misc for arm. Chroot on its own won't
>> work.
>
> the required libs may conflict with the target file. Now I build a
> static qemu-arm.

You can use the multiarch directory ([/usr]/lib/<triplet>/) to place
libraries into a unique location. Under debian this directory is
activated through /etc/ld.so.conf.d/<triplet>.conf provided by libc6.
But static building works too.

> Host> cd qemu-0.12.3
> Host> ./configure --target-list=arm-linux-user --static
> Host> make
> Host> sudo cp arm-linux-user/qemu-arm /target/bin/qemu-arm
> Host> sudo cd /target
> Host> sudo chroot . /bin/qemu-arm /bin/sh
> Host> /bin/qemu-arm /bin/ls
>
> Now, it can work.
> Regarding to binfmt-misc, I don't know it.

http://en.wikipedia.org/wiki/Binfmt_misc

  binfmt_misc is a capability of the Linux kernel which allows arbitrary
  executable file formats to be recognized and passed to certain user
  space applications, such as emulators and virtual machines.
  ...

Under Debian the qemu-arm package automatically registers qemu through
this so executing any arm binary will automatically invoke qemu
transparently.

MfG
        Goswin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to redirect the loader to another directory ?
  2010-05-13 11:35 How to redirect the loader to another directory ? robert song
  2010-05-13 13:46 ` Goswin von Brederlow
@ 2010-05-19 23:14 ` Mike Frysinger
  2010-05-20  3:54   ` robert song
  1 sibling, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2010-05-19 23:14 UTC (permalink / raw)
  To: binutils; +Cc: robert song

[-- Attachment #1: Type: Text/Plain, Size: 227 bytes --]

On Thursday 13 May 2010 07:34:47 robert song wrote:
> Now I use qemu-arm to execute the target command on host.

these questions really should be posted to the qemu list since they have 
nothing to do with binutils
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to redirect the loader to another directory ?
  2010-05-19 23:14 ` Mike Frysinger
@ 2010-05-20  3:54   ` robert song
  2010-05-20  4:08     ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: robert song @ 2010-05-20  3:54 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: binutils

hmm, I posted some topics in QEMU before and without any answer, the
QEMU list isn't active.
Now chroot can slove the QEMU problem.
But in the other way, I also want to know how to modify the other
application which execution loader path is different from the loader
path specified during build.
Because in embedded system, sometimes the dir will changed.

Best Regards,
  robert


On 5/20/10, Mike Frysinger <vapier@gentoo.org> wrote:
> On Thursday 13 May 2010 07:34:47 robert song wrote:
>> Now I use qemu-arm to execute the target command on host.
>
> these questions really should be posted to the qemu list since they have
> nothing to do with binutils
> -mike
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to redirect the loader to another directory ?
  2010-05-20  3:54   ` robert song
@ 2010-05-20  4:08     ` Mike Frysinger
  2010-05-20  4:31       ` robert song
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2010-05-20  4:08 UTC (permalink / raw)
  To: robert song; +Cc: binutils

[-- Attachment #1: Type: Text/Plain, Size: 706 bytes --]

On Wednesday 19 May 2010 23:53:56 robert song wrote:
> hmm, I posted some topics in QEMU before and without any answer, the
> QEMU list isn't active.
> Now chroot can slove the QEMU problem.
> But in the other way, I also want to know how to modify the other
> application which execution loader path is different from the loader
> path specified during build.
> Because in embedded system, sometimes the dir will changed.

telling qemu where to look up alternative paths and such is a qemu issue 
though, not a binutils.  you could relink all your apps with a different ldso 
path, and recompile your C library to use a different prefix, but that isnt 
dynamic like the qemu solution.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to redirect the loader to another directory ?
  2010-05-20  4:08     ` Mike Frysinger
@ 2010-05-20  4:31       ` robert song
  0 siblings, 0 replies; 10+ messages in thread
From: robert song @ 2010-05-20  4:31 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: binutils

Mike, you are correct, thank you very much.

Best Regards,
  robert


On 5/20/10, Mike Frysinger <vapier@gentoo.org> wrote:
> On Wednesday 19 May 2010 23:53:56 robert song wrote:
>> hmm, I posted some topics in QEMU before and without any answer, the
>> QEMU list isn't active.
>> Now chroot can slove the QEMU problem.
>> But in the other way, I also want to know how to modify the other
>> application which execution loader path is different from the loader
>> path specified during build.
>> Because in embedded system, sometimes the dir will changed.
>
> telling qemu where to look up alternative paths and such is a qemu issue
> though, not a binutils.  you could relink all your apps with a different
> ldso
> path, and recompile your C library to use a different prefix, but that isnt
> dynamic like the qemu solution.
> -mike
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-05-20  4:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-13 11:35 How to redirect the loader to another directory ? robert song
2010-05-13 13:46 ` Goswin von Brederlow
2010-05-13 14:12   ` robert song
2010-05-13 18:14     ` Goswin von Brederlow
2010-05-14  1:46       ` robert song
2010-05-14  4:34         ` Goswin von Brederlow
2010-05-19 23:14 ` Mike Frysinger
2010-05-20  3:54   ` robert song
2010-05-20  4:08     ` Mike Frysinger
2010-05-20  4:31       ` robert song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).