From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) by sourceware.org (Postfix) with ESMTPS id 9351D3858D39 for ; Wed, 28 Feb 2024 23:50:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9351D3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=tramnitz.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tramnitz.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9351D3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c30 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709164242; cv=none; b=WRTRnxnvlWRnkOElnvkgflUHsQ/9Z38kpPW/vtuV3/xlPZpsz2FdZc678ipOAKQUJExyHJdGGc3CCp3tZe/sPtk8jn4bAAtEfqAzX2+afHUYZoubiWLTEGPVpIl9Jw/qih4z+6d97TPorfpvOkpc+s+sDpYVii0HLUcK+nHfhQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709164242; c=relaxed/simple; bh=lTY4oXMn8K0QLctfsMWsHetgB6FcUJ50MuEG5KRlrEQ=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Y8g8+APzHZnnMoq8IKU1E7M9VRiBQoIAI30F8CXR8AvVh7bE0f8iza8+zXqnfC79+Dfnw7NS8e+XcSW9E/rSuKQMFR+RLrgcuMH2e5/7jzQITMAf1Z+vmdDZlIaaENUELM8CQOkzTfJGgAu+v13eNIp9EwObTiC6qDpFYGKTePc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5a027fda5aeso165974eaf.1 for ; Wed, 28 Feb 2024 15:50:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tramnitz-com.20230601.gappssmtp.com; s=20230601; t=1709164240; x=1709769040; darn=sourceware.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=HZmHu1soREmQHnsCPuSkhNTuJrXmTF1KeeT5EojZrvk=; b=s8Q9bN2nlANhCJXd00frRoE/rZ77NhdKZRRidcn0oySSudTKqqwNvwHD+HLdAqCfR+ WQSH+lP9M+3wNkky2OSFrHKm8HNlp4KkHNmZRA/dJ7MKr8MXDJVkaRmZTr2Pybro47Xg /0RvmoUhg/8wDd2dydKVq+0i+fmJmSPrZj/WjTJjCtMbu3lqtXgHjB6S5G0WgiVSEhxT aTEHaJs1mI0ptw1jBWkuPWesubU6FVms+ba1OEw4vPZm8dq7Bduw/4JFWX42tah+SPlK 20g4Lv0lXoHWn23FC7+u6/0n2CnKXiA0F3JuTmTTK8nsx1A7CByjtptJuCG2onp9THp+ /xxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709164240; x=1709769040; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HZmHu1soREmQHnsCPuSkhNTuJrXmTF1KeeT5EojZrvk=; b=JtEkfQujy9aufyM4kKlu6CIALrsehlER1UeGPXhoUo/TCKGR/apkO9/046qxv3B9Y1 qhj/ZPW2e0PNGMfi8q5rI/tQokYhnd4OUkXSNA5pCk/XE42cSGp99PpTDh4NiTzFDWdF 0ywyLYdhYim2nFW3hz4es6G8sLRFXTm4/bfzF9AXUo3xI7YB3YVhraITh1oNhRkQ3qDp LJ1BCfPwGMDA4koCWu0SO3nOXfSi71EDLeiDRK2v+3yeA8dgYbSd7qfqxZJSUAmjgiNU x8XhlPAMX10RVqajO9zoFxAdVurU/nl8j8oJ3oRo+vBh8bdTk5YtAYrfZznYBrUxeFUo TgUg== X-Forwarded-Encrypted: i=1; AJvYcCUtLvwHqkC0Myu+vo2CfLizJzsr6hCJ8c7DMg429Y3HvYvAXJ472+mNRK0aQ6UrL5wYMWowUuVL2RD0d767nWQSYC1qURaKxQ== X-Gm-Message-State: AOJu0YxKMz/n1KVwPgvSjmgZY9c9BW9WASbiQzEFvEUvaCllqlX4fE50 DFLHaWyo6J3wbDwJV1iRM/D3KbXgK6UeX5QvuY9DkO+NGhayWBDyqb3Cm7i9gGi4gPt9S5/P+b7 MD6yso/9KEDZhIWhU6UZ9FgxTNNbcoA3sYVRscChXb7v3ECyRXRE= X-Google-Smtp-Source: AGHT+IHLA/wUIcHQYCu0J80inmithesuECr8ydQJgMrEzko135jV6nbaQkvohNCg2e9dGzanZ2S5DC++lXB7mAlX+bQ= X-Received: by 2002:a4a:6245:0:b0:5a0:d2d1:519 with SMTP id y5-20020a4a6245000000b005a0d2d10519mr607447oog.4.1709164239931; Wed, 28 Feb 2024 15:50:39 -0800 (PST) MIME-Version: 1.0 References: <57185ecb-ce34-42d0-9023-6af36d49b697@redhat.com> In-Reply-To: <57185ecb-ce34-42d0-9023-6af36d49b697@redhat.com> From: Christian Tramnitz Date: Thu, 29 Feb 2024 00:50:03 +0100 Message-ID: Subject: Re: ld: document static libraries when performing static linking To: Nick Clifton , binutils@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 Nick, thanks for your detailed response! > 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. -Map does indeed provide the required information - thanks a lot for the hint, that is already much better than parsing through verbose build logs or the dependency-file. However, like --depedency-file, it has one major drawback: when multiple targets exist, the "last" action overwrites the output file. I haven't seen an option to use a dynamic file names (foo-$$.map doesn't seem to work). > 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. I indeed looked into annobin initially, but did not get that the notes also contain references to the sources/archive/library (only compile options as per https://sourceware.org/annobin/annobin.html/Plugins.html). But since you're the author, you know better for sure. Will have a look again as it may cover large parts of what I'm trying to achieve already. Except for the lookup which package owns that file of course. But that could be a post-processing step again. Best regards, Christian