From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7A3E43858C98 for ; Wed, 28 Feb 2024 14:02:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A3E43858C98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7A3E43858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709128970; cv=none; b=bPGkmySdv0DrUQp05SwJ5MRPVHIm6zSX2p5qcWscaxXcql8hcZXd98aNxabS+tWVlFJ2EangtIBgbA+zK+WP2bvOwQ7hl5uK+f9jLlIYy7+YS8FuAT7Q861C31wvcQIgnhiWVCsAs2uoER1CNsRlg5BUyM3j7lUEMNUR7lJRhuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709128970; c=relaxed/simple; bh=ppNN/0t/Ud0WFrEdeqX9w0a/N5nggkZF6zyO1kG6sGA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=BzyeoHFuCesKrUAPDrYGHT2whLI/IskodmyruTpkW1w6Dy5ErLfZQrF6Cb1rOW1+a/a08u0QU9qb2Fq+38fCGZIlXP3bEu9kmDlaxLIx0EMDtA8h0g53JRY5h+BaCWro/IAc5eX734QoqFQyE8LJayFp1yWqiKe9eYgxGvLj1LA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709128962; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=ApcIDjhAiPDRiyPhJzRdc4WsrCPnGauv0RV2EOANC0E=; b=FPWTJ856bDK+Z0bjjgI7jJYeU6I4P5YI2HPkoDmCO1r2EgQrV6uXUKmWxKzKhx3DdLTajQ cui28rBKljfULJGx1Mp1FJNKX7PmAJTZJjf7Mkhnueoe7B8/f1cAwdAYdAGDBSHZZ1eUbH YclqFqiXqmsyf4eJezOVOdFh7ek6Kkk= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-nbPvoqoIOGil9O-lACmBJw-1; Wed, 28 Feb 2024 09:02:40 -0500 X-MC-Unique: nbPvoqoIOGil9O-lACmBJw-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-787a9726c13so558850085a.1 for ; Wed, 28 Feb 2024 06:02:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709128960; x=1709733760; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ApcIDjhAiPDRiyPhJzRdc4WsrCPnGauv0RV2EOANC0E=; b=DMbUCjewKDYRP7mikkUIsYnO9/b6Jc66wO2qoKBstKryS2vToT3rI7+wGDpKAyrpd0 HxIIuMcKcJB/cyOF4OpGGWsSCwZqDxHwgt8wk6pWF+MRw2NnrSMq2p5aHFwMXV+Y8R6y uQetU37BKJ0HnK2fyv/CIeF5nz6ghjaclIl3VhN99/NzRlybno6Ky0O2XcVV9HOp2grd +uiAGBI+6zgqErPj3XqWiEINX1g3+7+ObLZMKq3SDT8yzS+SUKTzVhnCgrAwSCJNT8QL CE3kING00U5ub/JQxlSwM4u5/GtnHmIVyt6BvJawlkWd+uoGkd86DwMlnQvh1KLjY8VG Y7MA== X-Forwarded-Encrypted: i=1; AJvYcCVWnELoFxhKIcdezdsNNtXRE77Y25byWRGn7TzH6i0JZd9HU1G8MIEqi1E8cd5LxyJIbc9plfJPutieQQUBS1kCNkOvGI4ffQ== X-Gm-Message-State: AOJu0YyiuH8q4Qu1nUIjd3LtlfV4fxFDOeRuDS33znMIFmWyaQ8n7we5 tcm53ZlrSdt0l5xzaOCYQOGaV1zAgg5amQNtAUzfyhs0a8HSsuHYVtYsBhftBViqKDz9Jx9ZZtg 90o7FeFrm6Z0jAzVSjioOvo0XhNF0WSTVbxf/oWsp8l1fYykKVo+1PuC8P+9iROM= X-Received: by 2002:ae9:f712:0:b0:783:ae0c:5e8f with SMTP id s18-20020ae9f712000000b00783ae0c5e8fmr4888927qkg.71.1709128959679; Wed, 28 Feb 2024 06:02:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+KKB6WKyUoGTYRMfUnK2BafQfb2VNau9ehKG+3K6QqkOKD5iMhITv899JYM/OyD/xZMuRpw== X-Received: by 2002:ae9:f712:0:b0:783:ae0c:5e8f with SMTP id s18-20020ae9f712000000b00783ae0c5e8fmr4888895qkg.71.1709128959311; Wed, 28 Feb 2024 06:02:39 -0800 (PST) Received: from [192.168.1.18] ([79.123.79.31]) by smtp.gmail.com with ESMTPSA id vz2-20020a05620a494200b00787af8b5c02sm4590137qkn.39.2024.02.28.06.02.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Feb 2024 06:02:38 -0800 (PST) Message-ID: <57185ecb-ce34-42d0-9023-6af36d49b697@redhat.com> Date: Wed, 28 Feb 2024 14:02:37 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: ld: document static libraries when performing static linking To: Christian Tramnitz , binutils@sourceware.org References: From: Nick Clifton Autocrypt: addr=nickc@redhat.com; keydata= xsFNBFm/2cUBEADkvRqMWfAryJ52T4J/640Av5cam9ojdFih9MjcX7QWFxIzJfTFYq2z+nb4 omdfZos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ag02b+1yfABEBAAHCwV8EGAECAAkFAlm/2cUCGwwACgkQE/zvid2ePE/dqQ/6ApUwgsZz tps0MOdRddjPwz44pWXS5MG45irMQXELGQyxkrafc8lwHeABYstoK8dpopTcJGE3dZGL3JNz 1YWxQ5AV4uyqBn5N8RubcA8NzR6DQP+OGPIwzMketvVC/cbbKDZqf0uTDy3jP65OFhSkTEIy nYv1Mb4JJl3Sq+haUbfWLAV5nboSuHmiZE6Bz2+TjdoVkNwHBfpqxu6MlWka+P98SUcmY8iV hPy9QC1XFOGdFDFf1kYgHW27mFwds35NQhNARgftAVz9FZXruW6tFIIfisjr3rVjD9R8VgL7 l5vMr9ylOFpepnI6+wd2X1566HW7F1Zw1DIrY2NHL7kL5635bHrJY4n7o/n7Elk/Ca/MAqzd IZxz6orfXeImsqZ6ODn4Y47PToS3Tr3bMNN9N6tmOPQZkJGHDBExbhAi/Jp8fpWxMmpVCUl6 c85cOBCR4s8tZsvGYOjR3CvqKrX4bb8GElrhOvAJa6DdmZXc7AyoVMaTvhpq3gJYKmC64oqt 7zwIHwaCxTbP6C6oUp9ENRV7nHnXN3BlvIgCo4QEs6HkDzkmgYlCEOKBiDyVMSkPDZdsspa+ K4GlU2Swi/BDJMjtDxyo+K0M81LXXxOeRfEIfPtZ3ddxBKPva1uSsuz+pbN9d1JY8Ko5T/h1 6susi2ReUyNJEJaSnjO5z13TQ1U= In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-GB Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Christian, > For statically linked binaries one wants to keep track of external > libraries that were pulled in at link time. I haven't found any > initiatives or standards trying to achieve this yet, so I would like > to make a proposal. > > ld already supports the `--depedency-file=` option to create a > depfile, to some degree, documenting dependencies in Makefile format. > While it's a good starting point, it's not sufficient. > > Would it be feasible to create another option, that > a) just records dependencies to external, static-libs (within the > depfile this could be achieved by looking for path names outside the > build dir and having an .a file extension - but this is not > neccessarily exhaustive). This doesn't need to be unique, > post-processing is expected to take place anyway. If post-processing is an option, then how about using the linker map file and parsing that ? Ie link with -Map=foo.map and then post-link scan foo.map. That would give you full details of which libraries were used, and which components from inside those libraries if they are archives. It might take a bit of work to get a reasonably robust scanner, but it would mean that it would work with any version of the linker, and you would not have the hassle of maintaining a linker plugin. > b) documents the actual objects (enhanced: down to function level if > information exists from compiling with -ffunction-sections and > -fdata-sections) that were pulled in from the library archive, similar > to the output from `--verbose` The linker map idea above should let you do this. > c) outputs this in some sort of structured format for later > processing, e.g. as simple as > ,, > my-obj,/usr/lib64/libc.a,stpcpy-avx2.o > my-obj,/usr/lib64/libc.a,stpcpy-avx2-rtm.o > my-obj,/usr/lib64/libc.a,getsrvbynm.o > my-obj,/usr/lib64/libc.a,stpcpy-evex.o If you do not like the map idea then maybe adding some code to the linker at the places where it generates its map output, but this time in a format you like, would work ? > d) - if ld doesn't support this already (couldn't find looking through > man) - ld had some sort of no-op/pretend option that doesn't actually > produce a linked output but only pretends it would? It doesn't. Although of course you can always throw away any files it creates and start again. > Purpose: > The consumer of this information might be a distributor, keeping track > of things in the distribution specific packaging database format. Or > it could even be embedded into the resulting binary itself. There is another possibility... Check out the annobin project: https://sourceware.org/annobin/ The compiler plugins that are part of this project record notes that include the filename associated with each compilation unit. These notes are aggregated together during a link and end up in the resulting binary. So you could scan the binary for these notes, extract the filenames and you would end up with a list of (main) sources for the program. If your static libraries are also compiled with annobin enabled then they will contain notes of their own that will also contribute to the final binary. Cheers Nick