From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 857D71F4B4 for ; Thu, 8 Oct 2020 12:10:05 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B77A03857C6F; Thu, 8 Oct 2020 12:10:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B77A03857C6F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1602159003; bh=73MfDSMZORlW+XRCEsMV89MTuck2LP3CB9PiMthuCEY=; h=To:References:Subject:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=kIm5EmGEECATk2h5SrjgKH8Fr+tfqklv8DOkhGUZ0OryZj1F/IcawZqoJ/z4qMdkk aAR2ysgBJLV/6khmZxzJen3Kbapxc1MmGXjW/m3f0KxOy7dL3xMCtwEnI+j3SvCJwY POBBB0FsqNsiOr7HdLS7IEjmfBfJaoh6JV0wgADY= Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id E5D2E3857C6F for ; Thu, 8 Oct 2020 12:10:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E5D2E3857C6F Received: by mail-qt1-x841.google.com with SMTP id d1so4822040qtr.6 for ; Thu, 08 Oct 2020 05:10:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:autocrypt:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=73MfDSMZORlW+XRCEsMV89MTuck2LP3CB9PiMthuCEY=; b=oLvhW3iNc2NiSFaLr0LHprkFaQcMxuZxfb959eI1gaoe+T6t+7AwHYZxsflGbqAVLI yIoEBlnTxgiWbwdV526sAkW+KREknnJwY+gcj9L41qdpZTIP1qR7rBYFh2UwpHVMVZWJ iJKY8Bdk7eyypFrwFfhE9VHUzJ5x2bVZGC2WA4erI30aPaOffbSnRlw+D+kNtTB8SCDM 6WniVQsZFHMygRZdbkovh8xHh0kVrJ8WpBy95ToHG6ZdbaMrNd5NflSsuxe80jR65amI 0BhBoNEjKq6OP3QdV8Rm6auEP6Nj9+NZs3vByOdATjDaQDAtULfcvK22x+gc9kYTZXlO YF6Q== X-Gm-Message-State: AOAM530Pqw58UN0HmkUMPll9WbgN36PTG2nGNJ9GfR7Wggv9JfAbdVsZ yZu1o9sG/2fOK8KQ10BEM9SKSA== X-Google-Smtp-Source: ABdhPJzhPHoAFGV2I2XDlbBxR81p2TVTKQwZy84X6ZvoaToOqIShYwNMetWV9IHJDoAIM8rFn6DU9g== X-Received: by 2002:ac8:96d:: with SMTP id z42mr8036924qth.123.1602159000216; Thu, 08 Oct 2020 05:10:00 -0700 (PDT) Received: from [192.168.1.4] ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id y77sm3677106qkb.57.2020.10.08.05.09.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Oct 2020 05:09:59 -0700 (PDT) To: Michael Clark , libc-alpha@sourceware.org References: <20201006054255.1676065-1-michaeljclark@mac.com> <20201006235648.1811725-1-michaeljclark@mac.com> Autocrypt: addr=adhemerval.zanella@linaro.org; prefer-encrypt=mutual; keydata= mQINBFcVGkoBEADiQU2x/cBBmAVf5C2d1xgz6zCnlCefbqaflUBw4hB/bEME40QsrVzWZ5Nq 8kxkEczZzAOKkkvv4pRVLlLn/zDtFXhlcvQRJ3yFMGqzBjofucOrmdYkOGo0uCaoJKPT186L NWp53SACXguFJpnw4ODI64ziInzXQs/rUJqrFoVIlrPDmNv/LUv1OVPKz20ETjgfpg8MNwG6 iMizMefCl+RbtXbIEZ3TE/IaDT/jcOirjv96lBKrc/pAL0h/O71Kwbbp43fimW80GhjiaN2y WGByepnkAVP7FyNarhdDpJhoDmUk9yfwNuIuESaCQtfd3vgKKuo6grcKZ8bHy7IXX1XJj2X/ BgRVhVgMHAnDPFIkXtP+SiarkUaLjGzCz7XkUn4XAGDskBNfbizFqYUQCaL2FdbW3DeZqNIa nSzKAZK7Dm9+0VVSRZXP89w71Y7JUV56xL/PlOE+YKKFdEw+gQjQi0e+DZILAtFjJLoCrkEX w4LluMhYX/X8XP6/C3xW0yOZhvHYyn72sV4yJ1uyc/qz3OY32CRy+bwPzAMAkhdwcORA3JPb kPTlimhQqVgvca8m+MQ/JFZ6D+K7QPyvEv7bQ7M+IzFmTkOCwCJ3xqOD6GjX3aphk8Sr0dq3 4Awlf5xFDAG8dn8Uuutb7naGBd/fEv6t8dfkNyzj6yvc4jpVxwARAQABtElBZGhlbWVydmFs IFphbmVsbGEgTmV0dG8gKExpbmFybyBWUE4gS2V5KSA8YWRoZW1lcnZhbC56YW5lbGxhQGxp bmFyby5vcmc+iQI3BBMBCAAhBQJXFRpKAhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4BAheAAAoJ EKqx7BSnlIjv0e8P/1YOYoNkvJ+AJcNUaM5a2SA9oAKjSJ/M/EN4Id5Ow41ZJS4lUA0apSXW NjQg3VeVc2RiHab2LIB4MxdJhaWTuzfLkYnBeoy4u6nj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97iUgDV5mlNef77lWE8vxmlY0FBWIXuZ yv0XYxf1WF6dRizwFFbxvUZzIJp3spAao7jLsQj1DbD2s5+S1BW09A0mI/1DjB6EhNN+4bDB SJCOv/ReK3tFJXuj/HbyDrOdoMt8aIFbe7YFLEExHpSk+HgN05Lg5TyTro8oW7TSMTk+8a5M kzaH4UGXTTBDP/g5cfL3RFPl79ubXwARAQABiQIfBBgBCAAJBQJXFRpKAhsMAAoJEKqx7BSn lIjvI/8P/jg0jl4Tbvg3B5kT6PxJOXHYu9OoyaHLcay6Cd+ZrOd1VQQCbOcgLFbf4Yr+rE9l mYsY67AUgq2QKmVVbn9pjvGsEaz8UmfDnz5epUhDxC6yRRvY4hreMXZhPZ1pbMa6A0a/WOSt AgFj5V6Z4dXGTM/lNManr0HjXxbUYv2WfbNt3/07Db9T+GZkpUotC6iknsTA4rJi6u2ls0W9 1UIvW4o01vb4nZRCj4rni0g6eWoQCGoVDk/xFfy7ZliR5B+3Z3EWRJcQskip/QAHjbLa3pml xAZ484fVxgeESOoaeC9TiBIp0NfH8akWOI0HpBCiBD5xaCTvR7ujUWMvhsX2n881r/hNlR9g fcE6q00qHSPAEgGr1bnFv74/1vbKtjeXLCcRKk3Ulw0bY1OoDxWQr86T2fZGJ/HIZuVVBf3+ gaYJF92GXFynHnea14nFFuFgOni0Mi1zDxYH/8yGGBXvo14KWd8JOW0NJPaCDFJkdS5hu0VY 7vJwKcyHJGxsCLU+Et0mryX8qZwqibJIzu7kUJQdQDljbRPDFd/xmGUFCQiQAncSilYOcxNU EMVCXPAQTteqkvA+gNqSaK1NM9tY0eQ4iJpo+aoX8HAcn4sZzt2pfUB9vQMTBJ2d4+m/qO6+ cFTAceXmIoFsN8+gFN3i8Is3u12u8xGudcBPvpoy4OoG Subject: Re: [PATCH v2] ldd: revise trace output for left-aligned relative addresses Message-ID: Date: Thu, 8 Oct 2020 09:09:56 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Adhemerval Zanella via Libc-alpha Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On 08/10/2020 02:44, Michael Clark wrote: > > > On 10/8/20 10:01 AM, Adhemerval Zanella wrote: >> On 06/10/2020 20:56, Michael Clark via Libc-alpha wrote: >>> This change updates ld.so trace for left-aligned relative addresses. >>> The primary goal of this change is to increase `ldd` readability by: >> >> I am not sure if we want to extend the loader to expose debug format >> printing where it could be archive by extending the elf/ldd.bash.in >> itself to handle it.  In fact, I would like to avoid such extra >> complexity on a core component of the program loading. >> >>> >>>   - modifying trace output to use relative addresses by default. >> >> You can get similar information with setarch -R, which disable ASLR. >> >>>   - adding an alternative trace output mode with left-aligned addresses. >> >> And you can do it with some pos-processing tool (elf/ldd.bash.in, although >> I give you it might be cumbersome to accomplish with sheel script). >> >>> >>> The relative addresses are composed by subtracting the ELF ehdr address >>> which makes the output constant under address space layout randomization. >>> This should be a safe change because the default format is preserved. >>> >>> The intention is to make `ldd` easier to cross reference with objdump. >>> Also, log files including `ldd` output will contain less differences as >>> the vdso is the only address that changes when using relative addresses. >>> >> >> Which information exactly are you trying to match from what you read reading >> the ELF information through objdump? Afaik without prelink sections, it does >> not give any information whether loader might place the DSO segments. > > Precisely the linked run-time relative offsets of DSOs. > > I have spent countless hours reading and cross referencing words and numbers from command line tools. For me it's a use case of trace output from a simulator (e.g. qemu -d in_asm, op_opt, out_asm) and a window beside me with objdump and ldd there. Time and cognitive load. An addend would be useful too, but one should be able to pipe cut to bc for that. But this relative offset only make sense with ALSR disabled, which you can do by forcing it with a personality call. What I am trying to understand is why exactly you need to use a base address (__ehdr_start) and present the offset relative address (since this will be also subject to ASLR). > > So more words around whether to adopt "left-aligned relative addresses". > > I completely understand why it is difficult to change existing formats which is why the patch does not change the default. There is also musl ldd and freebsd ldd that also have adopted that brain damaged format. > >>> * Aligned output * >>> >>> The new trace format is enabled with `LD_TRACE_ADDR_ALIGN=1`, otherwise >>> the default `ldd` trace format is selected by default for compatibility. >>> >>> * Relative addresses * >>> >>> `ldd` load addresses are displayed relative to the ld.so executable header >>> address. Relative addresses are enabled by default, given the output mimics >>> systems without ASLR, thus there should be minimal compatibility issues. >>> There is also an option to negate addresses as an aid in interpreting them, >>> seeing library addresses relative to the loader with negative offsets. >>> >>> The changes adds three new ld.so flags accessible via environment variables: >>> >>>   - `LD_TRACE_ADDR_ALIGN=1` - Show addresses left-aligned >>>   - `LD_TRACE_ADDR_ABSOLUTE=1` - Show absolute addresses (backwards compat) >>>   - `LD_TRACE_ADDR_NEGATE=1` - Show negated addresses (combination option) >> >> What I would like is in fact to move lld support *out* of the loader, where >> it would require to process anything more the strictly required and without >> commit any system resource (such as mmap).  It will result in slight less >> complex code and attack surfac > That's kind of irrespective to this patch though. Kerckhoff's principle. The rationale is not to hide ASLR. It's to reduce diffs in CI logs where we run ldd to check which lib our build system decided to link us to. Not really because I also want to avoid make the loader code *more* complex and move all this format complexity on how to present the information to a helper script. This is similar to multiple traces/profile utilities on Linux, where the interface to *obtain* the information is concise as possible. My rationale is this could be accomplish by changing ldd script itself (by either using python if this makes it easier). > > Making output more difficult for humans to read is not a good rationale. Backwards compatibility on the other hand is completely reasonable. > >> Carlos O'Donnel has stated a project to accomplish it some time ago [1], >> but I haven't heard yet if it has been released. Maybe it something we >> can work on glibc side as well. > > No worries. I didn't expect that anyone would pick up the patch. It just occurred to me how brain damaged the present layout is. Not that I also wouldn't make brain damaged layouts myself. If logging something for trace purposes, one probably does not think too much about column order. There is also the field separator and potentially spaces in filenames, which is not addressed. QEMU has good trace infra btw. > > On windows we have process hacker which has an easy to read scrollable table view but it has an ugly color scheme. There is another tool I use for dependency analysis on windows. depends.exe iirc. > > It might be a bad idea to make the Linux tools look good. Again, I am not against a better tracing output of lld and I do agree with you that presenting the information in different ways might help users in parse the information. What I think is we should move this to helper program/script/tool and make the loader as concise as possible. > >>> Changelog >>> >>> * v1 - initial version >>> * v2 - change address alignment variable name to LD_TRACE_ADDR_ALIGN=1 >>> >>> Signed-off-by: Michael Clark >> >> We do not use DCO, but rather Copyright assignment. And for the size of the >> proposed change I think we you will need proper paper sorted out (I am not >> sure if you already have done it). >> >> [1] https://pagure.io/eu-ldd >>