From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46638 invoked by alias); 17 Jun 2019 18:06:55 -0000 Mailing-List: contact libc-help-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: libc-help-owner@sourceware.org Received: (qmail 46625 invoked by uid 89); 17 Jun 2019 18:06:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=3042, H*Ad:U*libc-help, HTo:U*libc-help, I*:omitted X-HELO: mail-wm1-f41.google.com Received: from mail-wm1-f41.google.com (HELO mail-wm1-f41.google.com) (209.85.128.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Jun 2019 18:06:51 +0000 Received: by mail-wm1-f41.google.com with SMTP id c66so400715wmf.0 for ; Mon, 17 Jun 2019 11:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=OBQ9yDMQC7NIgeSNnkUq48XPS9L48UH0/A9rZBWX1l0=; b=Un28xrDADeXL8Ct6nBMvykz0RGuMwJNM54/usoRQiSJP2NQDBOd+eI5iyntdL52aY4 DxhEEg/VwDiYDZjEA9JxLH2OMhX38gMuDgbbCd12HH+kg6rOGQsInugDYUoNJ5fIQB6H DPqTsg41puIo+R2ghiQEvtnRQMXb5TUXvbbsopeKx5HdASZATRVl3BnnD+0xKpIfyp5s hOAv2P94CR05wTLupCYj0h86vsszxxMuO9Ewoi1uty6n0B5CrQKe/htWa92oY59ta9gb W1Ly0iqJmBvQlwcoXUM1zC+9TbG/q+ve8plOF73terHIKOYyGPokUHIS9Cy/t6nZR6wq Rf6A== MIME-Version: 1.0 From: Baojun Wang Date: Mon, 17 Jun 2019 18:06:00 -0000 Message-ID: Subject: dlmopen in LD_PRELOAD To: libc-help@sourceware.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-06/txt/msg00026.txt.bz2 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