From patchwork Mon Oct 30 12:17:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 159721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2165426vqb; Mon, 30 Oct 2023 05:17:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDp62A/VMgzXWgndK54Jr5766jPFedDyVVqzJkMSb+1l0Ja6rgFyrUioEM0O/3ZEGaADoe X-Received: by 2002:a05:6214:d05:b0:670:a7a7:6415 with SMTP id 5-20020a0562140d0500b00670a7a76415mr8804917qvh.19.1698668258544; Mon, 30 Oct 2023 05:17:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698668258; cv=pass; d=google.com; s=arc-20160816; b=J/exCizZCfMeTydZJfTz0FTUbMNV9p9J+DkoHS98/HzIAzhS3bi5GtO70jF2xLz02M uNPKfNZINcqgdjM9HCZAp+9p+DHvM692DKIjB/wgpdhMWjVtKlgkIdeidvwogDW6f1RD 0ABZY783NghzYI5I1VQVTk1+47DE9cEeQb2rUZlikgRv790bQTOgmEYLj3b0a3eKjTIr pvEapIY41Nqlml1iekM7DQPZ29nvahbdwm3Mg4+iUV8pZohoMWOOncppCfDB/XAMNl/G So4lhtwSRC4iL6BFICh0a7CNJtzIFuEvxcaM3k0SC88uQnJTqRcW0VI74u+eCzlOk5qC kv7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date:cc :subject:to:from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=wmiRJjV8rD2llVgo791cq0YM7SAoPvHTmKPw3IpTomo=; fh=LCi4gNSjc47SRsMYjCkGGKszW/ml1vpDU07WJ/eOcaE=; b=hFEsiEa/5nmCpRHaP0CgXVs3SqSSj2zHkqZXm9EQDlZAu0J+owa59Zk3YKRDObE61n 19k6moELIBVbdiV11pUHRMqmX4Ca0j/bzfJUxFTKRiVfbJWhxeYXaj9nYFtUX3O3kG8V 2nwPkxoHmy8xEUpfTmEgZ2V5TuHARA9jVPFB2Ggn/+cAouYV3tjL1X+rFE7qE8SyGbha tIhkHasJ58wbnlwNbPvPPRx5GYPaNdhoTjgvUEHAEclV2w1BI5wq1c7nAOQLlfeTRsoq GPq84Iy2cUbCROnK+6jo9pO0/5jIzaq20cgnvro4bS39TO917tpAXNLwhC2YXv1GD/f+ VxaQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KF0g+tLk; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dz5-20020ad45885000000b0066d212f6b65si5486305qvb.525.2023.10.30.05.17.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 05:17:38 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KF0g+tLk; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2DF7A3858423 for ; Mon, 30 Oct 2023 12:17:38 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 B1C713858D28 for ; Mon, 30 Oct 2023 12:17:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1C713858D28 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 B1C713858D28 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=1698668253; cv=none; b=D6lQbmVJjTrIaI6PpW7tTrvl6BYU+txhdSheCDCEhYoqSi4lm/srkNZyOyxdwiSjYVs3tIbTW7cTovbNnfJmBQ6kvQYxuosdGuRNpbk1bIx2qZUKaVEEa9HB6skx/AhCWFv+9YRFjOqC4Hdp3LCfdeEWOHqIMUNjXWwgJmVnb38= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698668253; c=relaxed/simple; bh=TRVjFtib9CBoYiEQIwnEjfcJAkPWX3/Rz0L09uBx6z8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Znr2qyxBniUEQN+mMu2jo2EXTaTvwdaH+4af+EO/U63OuLF8T1l4B9aDniMtzxRoJ1a0iZAhZlaxLH0YdBLt9NH/nySv3k3RAUn6da2MH+VPdYQ+i4WfEl4eczsg59yFLyK6VwZ22yEPpeTKvg/CpegCAOk+yr/8ai9q0s9liOg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698668251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=wmiRJjV8rD2llVgo791cq0YM7SAoPvHTmKPw3IpTomo=; b=KF0g+tLkXEUJhVGXqbxamICitrjXE18TJNGho+atyljtuN04ASxsMlJOZNtR7TSJhR4c+b R0FM9NoeUG7iIhd4UC17xmv/gNNGmwdYuqjYSdePyL3vaLyuWV15dbpJ2vCtb9o0FyohjR Hdllep1sNMn097tqChwBCjO7/wjNpoc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-38-gSixAW5JNTivi7YBWo70Yw-1; Mon, 30 Oct 2023 08:17:29 -0400 X-MC-Unique: gSixAW5JNTivi7YBWo70Yw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B51F684ACA2; Mon, 30 Oct 2023 12:17:28 +0000 (UTC) Received: from prancer.redhat.com (unknown [10.42.28.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45661492BE0; Mon, 30 Oct 2023 12:17:28 +0000 (UTC) From: Nick Clifton To: cupertino.miranda@oracle.com Subject: Add partial support for R_BPF_64_NODLYD32 reloc CC: binutils@sourceware.org Date: Mon, 30 Oct 2023 12:17:27 +0000 Message-ID: <878r7k719k.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781182768071526879 X-GMAIL-MSGID: 1781182768071526879 Hi Cupertino, A bug report was recently filed with the Fedora binutils about the strip program being unable to handle the R_BPF_64_NODLYD32 relocation: https://bugzilla.redhat.com/show_bug.cgi?id=2245296 It turns out that whilst the GNU tools do not generate this reloc other tools do, and strip complains when it detects its presence. I am going to apply the attached patch as a workaround so that strip will work, but I think that if we want the linker to be able to cope with bpf object files generated by other tools, then we will need a better fix. I am leaving this up to you... :-) Cheers Nick diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 1b9d13add25..2b12eb35d27 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2023-10-30 Nick Clifton + + * bpf-reloc.def (R_BPF_64_NODLD32): Add entry. + 2023-10-16 Nick Clifton PR 28910 diff --git a/bfd/bpf-reloc.def b/bfd/bpf-reloc.def index 31f761d291d..7e7497892fa 100644 --- a/bfd/bpf-reloc.def +++ b/bfd/bpf-reloc.def @@ -87,3 +87,20 @@ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ true) /* pcrel_offset */ + + /* R_BPF_64_NODYLD32 is not used by GNU tools - but it is generated by LLVM. + We provide an entry here so that tools like strip can safely handle BPF + binaries generated by other tools. */ + BPF_HOWTO (R_BPF_64_NODYLD32, /* type */ + 0, /* rightshift */ + 0, /* size */ + 0, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bpf_elf_generic_reloc, /* special_function */ + "R_BPF_64_NODYLD32", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + false) /* pcrel_offset */ diff --git a/include/ChangeLog b/include/ChangeLog index 90ee73650c3..e0f0cb3edf4 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2023-10-30 Nick Clifton + + * elf/bpf.h (R_BPF_64_NODYLD32): Add a note that this reloc is + generated by other tools, eg LLVM. + 2023-09-28 Frederic Cambus * elf/common.h (PT_OPENBSD_NOBTCFI): Define. diff --git a/include/elf/bpf.h b/include/elf/bpf.h index e4d416290a7..1ad074f3d0e 100644 --- a/include/elf/bpf.h +++ b/include/elf/bpf.h @@ -30,8 +30,8 @@ START_RELOC_NUMBERS (elf_bpf_reloc_type) RELOC_NUMBER (R_BPF_64_64, 1) RELOC_NUMBER (R_BPF_64_ABS64, 2) RELOC_NUMBER (R_BPF_64_ABS32, 3) -/* R_BPF_64_NODYLD32 is not used by GNU tools. - * It is kept in this file to remind that the value is already taken. */ +/* R_BPF_64_NODYLD32 is not used by GNU tools - but it is generated by LLVM. + It is kept in this file to remind that the value is already taken. */ RELOC_NUMBER (R_BPF_64_NODYLD32, 4) RELOC_NUMBER (R_BPF_64_32, 10) RELOC_NUMBER (R_BPF_GNU_64_16, 256)