Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Weird ldd problem
On Sun, 18 Jul 2021 at 10:26, RVP <rvp%sdf.org@localhost> wrote:
>
> On Sun, 18 Jul 2021, Chavdar Ivanov wrote:
>
> > # file ksh93
> > ksh93: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
> > dynamically linked, interpreter /usr/libexec/ld.elf_so, for NetBSD
> > 9.99.45, with debug_info, not stripped
> > # ldd ./ksh93
> > ./ksh93:
> > -lm.0 => /usr/lib/libm.so.0
> > -lc.12 => /usr/lib/libc.so.12
> > -lexecinfo.0 => /usr/lib/libexecinfo.so.0
> > -lelf.2 => /usr/lib/libelf.so.2
> > -lgcc_s.1 => /usr/lib/libgcc_s.so.1
> > # ldd ksh93
> > ldd: bad execname `ksh93' in AUX vector: No such file or directory
> >
>
> That's coming from the run-time linker:
>
> function expand() in src/libexec/ld.elf_so/expand.c when it tries
> to expand $ORIGIN. You can create such a binary yourself like this:
>
> ---
> $ cat foo.c
> #include <stdio.h>
>
> int
> main(int argc, char* argv[])
> {
> printf("%s\n", *argv);
> return 0;
> }
> $ cc -o foo foo.c -Wl,-rpath='$ORIGIN'
> $ ldd ./foo
> ./foo:
> -lc.12 => /usr/lib/libc.so.12
> $ ldd foo
> ldd: bad execname `foo' in AUX vector: Undefined error: 0
> $ readelf -d foo
>
> Dynamic section at offset 0xbb8 contains 18 entries:
> Tag Type Name/Value
> 0x0000000000000001 (NEEDED) Shared library: [libc.so.12]
> 0x000000000000000f (RPATH) Library rpath: [$ORIGIN]
> 0x000000000000000c (INIT) 0x400530
> 0x000000000000000d (FINI) 0x4009b0
> 0x0000000000000004 (HASH) 0x400210
> 0x0000000000000005 (STRTAB) 0x4003c8
> 0x0000000000000006 (SYMTAB) 0x400260
> 0x000000000000000a (STRSZ) 158 (bytes)
> 0x000000000000000b (SYMENT) 24 (bytes)
> 0x0000000000000015 (DEBUG) 0x0
> 0x0000000000000003 (PLTGOT) 0x600d48
> 0x0000000000000002 (PLTRELSZ) 120 (bytes)
> 0x0000000000000014 (PLTREL) RELA
> 0x0000000000000017 (JMPREL) 0x4004b0
> 0x0000000000000007 (RELA) 0x400468
> 0x0000000000000008 (RELASZ) 72 (bytes)
> 0x0000000000000009 (RELAENT) 24 (bytes)
> 0x0000000000000000 (NULL) 0x0
> ---
>
> Do a `readelf -d' on both ksh93s. You'll see the difference.
The main difference is indeed
... (RPATH) Library rpath:
[$ORIGIN/:$ORIGIN/../../lib/libast:$ORIGIN/cmds:$ORIGIN/../../lib/libdll]
I have to read more to understand it though...
>
> -RVP
>
Thanks,
Chavdar
--
----
Home |
Main Index |
Thread Index |
Old Index