This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

dlmopen in LD_PRELOAD


Hi libc,

Can `dlmopen` be called in a DSO being `LD_PRELOAD`-ed? The idea is to
create a minimal DSO used for `LD_PRELOAD`, then inside the DSO
(.init_array), call `dlmopen` to open the DSO that I'm really interested
in. hence the DSO being `LD_PRELOAD` acts like a mini loader only.

I did exactly above, but ran into issue (segfault) with stack overflow:

```
       ... 47539 frames omitted...

    frame #47540: 0x00007ffff73cd1b0
libc.so.6`__GI___libc_malloc(bytes=160) at malloc.c:3042

    frame #47541: 0x00007ffff7de7b90 ld-linux-x86-64.so.2`tls_get_addr_tail
at dl-tls.c:594

    frame #47542: 0x00007ffff7de7b6c ld-linux-x86-64.so.2`tls_get_addr_tail
at dl-tls.c:607

    frame #47543: 0x00007ffff7de7b5e
ld-linux-x86-64.so.2`tls_get_addr_tail(ti=0x00007ffff6f14940,
dtv=0x0000000000608330, the_map=0x0000000000602330) at dl-tls.c:787

    frame #47544: 0x00007ffff7deea28 ld-linux-x86-64.so.2`__tls_get_addr at
tls_get_addr.S:55

    frame #47545: 0x00007ffff6ce800c

    frame #47546: 0x00007ffff73c790a libc.so.6`arena_get2(size=576,
avoid_arena=0x00007ffff609e0d0) at arena.c:888

    frame #47547: 0x00007ffff73cc54d libc.so.6`tcache_init at arena.c:879

    frame #47548: 0x00007ffff73cc530 libc.so.6`tcache_init at malloc.c:2986

    frame #47549: 0x00007ffff73cd1cb libc.so.6`__GI___libc_malloc at
malloc.c:2983

    frame #47550: 0x00007ffff73cd1b0
libc.so.6`__GI___libc_malloc(bytes=160) at malloc.c:3042

    frame #47551: 0x00007ffff7de7b90 ld-linux-x86-64.so.2`tls_get_addr_tail
at dl-tls.c:594

    frame #47552: 0x00007ffff7de7b6c ld-linux-x86-64.so.2`tls_get_addr_tail
at dl-tls.c:607

    frame #47553: 0x00007ffff7de7b5e
ld-linux-x86-64.so.2`tls_get_addr_tail(ti=0x00007ffff6f14940,
dtv=0x0000000000608330, the_map=0x0000000000602330) at dl-tls.c:787

    frame #47554: 0x00007ffff7deea28 ld-linux-x86-64.so.2`__tls_get_addr at
tls_get_addr.S:55
```

Is this an ideal use case for `dlmopen`? What (went wrong) caused the stack
overflow?

Thanks
Baojun


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]