From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) by sourceware.org (Postfix) with ESMTPS id 0A5163858C27 for ; Sun, 28 Nov 2021 15:10:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0A5163858C27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kegel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-f171.google.com with SMTP id 84so9253207vkc.6 for ; Sun, 28 Nov 2021 07:10:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jpAx2azmKo0cBcBkBo5Z5Vqnc+V2N5MVXzQObv4DkhY=; b=zJD6I0aH/BkiydOck++BV9Rc/yFsov3ahcKtKDL68bEFsmQbdqNLoCKV1sUsUU2tkm 7C4kjWHykkIHFvVxEymOJxp+j1TGBFmPn4PPWtOGa/oCKo9oJnqeVolV40zjnSRJFPm4 NLUeZmLt9ps+kAJGvn8BdupcHN+EQ7Xgu7a1WupXWjz1JV9Cga9zt8nKGOB7JmYJa6pW oQ1zkUJ+kIPi4CFFjXlt5y2CyTd78BnrUsp1zcpX6hcGNli01UpNY3rZf7cCt4ZCiep0 NFr0KrCIfMomXy3quDOh6EkJHERQDsOMR+U60pKQZ6r/IxeTTnPLUMOVEgheUd2Ch7jf qnAA== X-Gm-Message-State: AOAM532eb9xvghWJftQnUM4xD6fl6gzHpM0qHepPmfRGlns+7XOUdNRc y+Z/4cFmT6zYXJAqEMbP+cRn7+bHWz3HH1y1dh4= X-Google-Smtp-Source: ABdhPJwwx/ROGMeY/oUcPVI8lCaazSJDxeH+MlCfRZC3wtaLnoqGZMuD0NDzW4cqLxpvLro8LSmhiJBNgb9y5C0yCXg= X-Received: by 2002:ac5:ccb8:: with SMTP id p24mr30783218vkm.31.1638112210485; Sun, 28 Nov 2021 07:10:10 -0800 (PST) MIME-Version: 1.0 References: <09012276-6b9c-18a1-2e28-e4b7a42e6e22@gmail.com> <87o864h5c4.fsf@oldenburg.str.redhat.com> <1e0cb18e-e0fd-9f20-1037-84604a090a22@gmail.com> In-Reply-To: <1e0cb18e-e0fd-9f20-1037-84604a090a22@gmail.com> From: Dan Kegel Date: Sun, 28 Nov 2021 07:09:58 -0800 Message-ID: Subject: Re: Reserving specified size of RUNPATH entry in the dynamic section during linking To: Jacob Kroon Cc: Florian Weimer , Jacob Kroon via Gcc-help X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Nov 2021 15:10:12 -0000 I used to do this by padding initially with extra dots and slashes. (On Mac, the linker had a flag -headerpad_max_install_names that did something similar.) On Sun, Nov 28, 2021, 06:32 Jacob Kroon via Gcc-help wrote: > On 11/28/21 12:44, Florian Weimer wrote: > > * Jacob Kroon via Gcc-help: > > > >> As part of an effort to make binaries reproducible regardless of their > >> build path, I need to enforce the same size of the RUNPATH entry in the > >> dynamic section during linking, even though I don't fill it completely. > >> Is it possible to give some flag to gnu ld that allows me to set it to a > >> specific size ? Or is there a way to patch the elf file after linking, > >> so that the entry has a specified size ? > > > > Do you want to allocate specific size so that you can patch in a > > different value later? > > > > Yes exactly, but see below. > > > The RUNPATH strings are in the string table, so it's necessary to > > allocate space there, and be able to find it during patching. > > > > Solaris offers this mechanism: > > > > | DT_SUNW_STRPAD > > | > > | The total size, in bytes, of the unused reserved space at the end > of > > | the dynamic string table. If DT_SUNW_STRPAD is not present in an > > | object, no reserved space is available. > > > > Would that help in your case as well? > > > > The problem is that for two different build I pass two different > -Wl,--rpath=, and they are of different length. So I'd like to > reserve a maximum size, at link-time, which becomes the same in both > builds, so that when I later remove the rpath's, the binaries become > identical. > > Jacob >