From patchwork Fri Apr 3 22:26:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 132671 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 782204BA23FF for ; Fri, 3 Apr 2026 22:27:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 782204BA23FF Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=PNcrvdVc X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 127804BA23CF for ; Fri, 3 Apr 2026 22:26:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 127804BA23CF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 127804BA23CF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775255211; cv=none; b=ioBcN9379u7JkKgvy07Av2eTchE9uknCakV0CmRYeOnpRKFjh70jfwgnlTOsuabzO7QEhvfswXRAkATcaATfF17pOrmDF0XwFUl78Epp1t7GojCqqvVZztSemBan5dr+/QJ76LrJ5O5Uu+wqcrP2C238y+xPyWf/IWBunfYX498= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775255211; c=relaxed/simple; bh=bPUT0qaKWROawende3Zn4JJ2ObgYIsVDUjztpTO+/OQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=xLElyHTeSdl1AE8Jdi+bxs2DXBgJrlujS+KGH8itddSyRSU1Zhhz1MjRI7UEyp655B/km79gkho4r5/+mSPF8FPwUVU66Hj6bjYcwAljFNE/vkg6wH86gSEylkGrzByi28FcPnW5HSrM1sYJC3xWRmUiKIWNHa6fqzu+3bRr5cg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 127804BA23CF Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-82748257f5fso2046948b3a.1 for ; Fri, 03 Apr 2026 15:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775255210; x=1775860010; darn=sourceware.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=hCoWfS8SuJJK7jjVGhWNDP5He5IgDzjUBWrgzFL5Evs=; b=PNcrvdVco7iTneF0EFA123ECB3w+UTGsQ/eZQqX+a6885rJfTc9NuquZKRbWT1rnfE 7YRcw1ECDxjQMkVTilENlGnaOS+vyuHffJKG9k53JG2LbKO5gYoRbiOfpP8LsgIUFNTd 0CbzFFGvFZgnNZKUS5nyS0e4+vaZNdITEnT67Hl32pbSx38UaQMEKZZnhHMD/5woVc/h QVeZtkpmzczh4wc8AIrIAuegD/qthxRs8kin8XWFvfWRY47bPKML3B4p19ZSLmjJ9aTN oGwpd1NLthwl9QJ/bYomdYS/deLRBiQNowrMU6Dw3gcZQc4lBGTGa6YDuxggeCovNhbj dpXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775255210; x=1775860010; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hCoWfS8SuJJK7jjVGhWNDP5He5IgDzjUBWrgzFL5Evs=; b=BkgCbMgpug2lzb8diBZN+t+cb5zcwKdDTzb1AEXGDt1kfhmmyI1PZLlWOwBHK/SFF3 7Y6kmzcD60LG/Z4zKS7wE0narq5h+3nvC+iGKx8DuDfkYGauuEjauh+cbrFueWHHhW8v zt/RY5thBXMub68dli3E8nIQ3VUvK5Ly19IYamChrrr+afQIbCLyXvyzKL68s/b4o83O GqopRcYJtXJg2uP0ng+gbQNQR3uH69NGMDghSusgfyjiLK7rLbe1SvppazQp8HGm8Fd7 q/y5uGa9OK3AADDH4Jrz0E/P5M7Z5SxfxqZBVpiwMPoUgVtcQWlXs5PibFk9lbLyDYeT fB3g== X-Gm-Message-State: AOJu0YxqP/aDE18gUx+Uj5TK99nxK5+zm4dHU48ngAE5sw8wAquNA8Yj YC4xBA+Fd1HbyTH9zegp0ugIWLpZAmspcDM9orqjhnINKGqnpFKNCAF6gGkLIw== X-Gm-Gg: ATEYQzyxl00C2d/teKQfyDb5CWdCfvDmlYR8kEmG4Ldi7hDO6u7AufIJm3tj7carMIN GRvZ50/hmzbKfENOwwopiIuTrvwxDeLQoauNKvRkzMfUoQOtyDA5SK2r6LAcOoOQ2hroqyk6ga8 W6OlgzgOzOjeyYnLn/isLAbATSRBFg4CxMe6BJdRtqdtfzFLbqDLX9HcagvP/jK6umuXrl5x3mN YyZeto6ULMrKBTQ1yz5w9cn2Hh55Xo0T177Kiniw+VTPZq7p03H4MS9YGE2qVVokVXs260R0e45 spLk1SMppODcCZ96v0MlF0WK80ijQCoW5XLXPdZHShIRLlMuO8u/akZc4+uXS7rbxHUyQGhi90J DiIlwtoXIHgoR5k/vGTyIngE+yxR1qgY+o3B+W2GyA38wFUt2+B0/Rg0J/09nULTBpuksXZTCYy 5R3x4KNMVEH8kT7ADE8LWsu3/whbtYPL+NU3YB X-Received: by 2002:a05:6a20:12c5:b0:39f:1e5a:e26 with SMTP id adf61e73a8af0-39f2d64d977mr4383697637.0.1775255209619; Fri, 03 Apr 2026 15:26:49 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:2c41:6d0c:b814:fbde]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9a24039sm6861978b3a.0.2026.04.03.15.26.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 15:26:49 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 88B941140900; Sat, 04 Apr 2026 08:56:45 +1030 (ACDT) Date: Sat, 4 Apr 2026 08:56:45 +1030 From: Alan Modra To: binutils@sourceware.org Subject: bfd_perform_relocation and howto special_function bfd params Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3030.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Describe the output_bfd parameter of bfd_perform_relocation, in pariticular that it is NULL when final linking. It would be nicer if these functions had access to link_info. * reloc.c (bfd_perform_relocation): Comment on abfd and output_bfd parameters in the function description. (reloc_howto_struct ): Refer to above. diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 38021d51c16..e18e36b7591 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -3264,7 +3264,8 @@ struct reloc_howto_struct /* If this field is non null, then the supplied function is called rather than the normal function. This allows really - strange relocation methods to be accommodated. */ + strange relocation methods to be accommodated. See + bfd_perform_relocation. */ bfd_reloc_status_type (*special_function) (bfd *, arelent *, struct bfd_symbol *, void *, asection *, bfd *, char **); diff --git a/bfd/reloc.c b/bfd/reloc.c index b7e114f4d2f..4938d46d0c2 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -358,7 +358,8 @@ CODE_FRAGMENT . . {* If this field is non null, then the supplied function is . called rather than the normal function. This allows really -. strange relocation methods to be accommodated. *} +. strange relocation methods to be accommodated. See +. bfd_perform_relocation. *} . bfd_reloc_status_type (*special_function) . (bfd *, arelent *, struct bfd_symbol *, void *, asection *, . bfd *, char **); @@ -637,21 +638,24 @@ SYNOPSIS char **error_message); DESCRIPTION - If @var{output_bfd} is supplied to this function, the - generated image will be relocatable; the relocations are - copied to the output file after they have been changed to - reflect the new state of the world. There are two ways of - reflecting the results of partial linkage in an output file: - by modifying the output data in place, and by modifying the - relocation record. Some native formats (e.g., basic a.out and - basic coff) have no way of specifying an addend in the - relocation type, so the addend has to go in the output data. - This is no big deal since in these formats the output data - slot will always be big enough for the addend. Complex reloc - types with addends were invented to solve just this problem. + @var{abfd} is the input bfd. If @var{output_bfd} is equal to + @var{abfd} then this function (well, bfd_install_relocation) + is being called from gas. If @var{output_bfd} is NULL then + this function is being called for final linking. Otherwise, + with @var{output_bfd} being non-NULL and not equal to + @var{abfd}, this function is being called for relocatable + linking. + There are two ways of reflecting the results of relocatable + linking in an output file: by modifying the output data in + place, and by modifying the relocation record. Some native + formats (e.g., basic a.out and basic coff) have no way of + specifying an addend in the relocation type, so the addend has + to go in the output data. This is no big deal since in these + formats the output data field will always be big enough for + the addend. Relocation types with addends were invented to + solve the problem of fields not large enough for all addends. The @var{error_message} argument is set to an error message if - this return @code{bfd_reloc_dangerous}. - + this function returns @code{bfd_reloc_dangerous}. */ bfd_reloc_status_type