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 5B7643857BB6 for ; Wed, 25 May 2022 16:52:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5B7643857BB6 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-320--cRpVhKNMy2G9rf8GYmc8g-1; Wed, 25 May 2022 12:52:41 -0400 X-MC-Unique: -cRpVhKNMy2G9rf8GYmc8g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D06D6908BDA; Wed, 25 May 2022 16:52:30 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.94]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02F9E112131E; Wed, 25 May 2022 16:52:29 +0000 (UTC) From: Florian Weimer To: "H.J. Lu via Libc-alpha" Subject: Re: [PATCH] x86-64: Ignore r_addend for R_X86_64_GLOB_DAT/R_X86_64_JUMP_SLOT References: <20220521022336.2464080-1-hjl.tools@gmail.com> Date: Wed, 25 May 2022 18:52:28 +0200 In-Reply-To: <20220521022336.2464080-1-hjl.tools@gmail.com> (H. J. Lu via Libc-alpha's message of "Fri, 20 May 2022 19:23:36 -0700") Message-ID: <874k1dy2pf.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.8 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, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 May 2022 16:52:46 -0000 * H. J. Lu via Libc-alpha: > According to x86-64 psABI, r_addend should be ignored for R_X86_64_GLOB_D= AT > and R_X86_64_JUMP_SLOT. > --- > sysdeps/x86_64/dl-machine.h | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h > index c70af7ab1e..7f607f6dff 100644 > --- a/sysdeps/x86_64/dl-machine.h > +++ b/sysdeps/x86_64/dl-machine.h > @@ -325,11 +325,13 @@ and creates an unsatisfiable circular dependency.\n= ", > # endif > =09 /* Set to symbol size plus addend. */ > =09 value =3D sym->st_size; > +=09 *reloc_addr =3D value + reloc->r_addend; > +=09 break; > # endif > -=09 /* Fall through. */ > + > =09case R_X86_64_GLOB_DAT: > =09case R_X86_64_JUMP_SLOT: > -=09 *reloc_addr =3D value + reloc->r_addend; > +=09 *reloc_addr =3D value; > =09 break; > =20 > =09case R_X86_64_DTPMOD64: Context: =09{ # ifndef RTLD_BOOTSTRAP # ifdef __ILP32__ =09case R_X86_64_SIZE64: =09 /* Set to symbol size plus addend. */ =09 *(Elf64_Addr *) (uintptr_t) reloc_addr =09 =3D (Elf64_Addr) sym->st_size + reloc->r_addend; =09 break; =09case R_X86_64_SIZE32: # else =09case R_X86_64_SIZE64: # endif =09 /* Set to symbol size plus addend. */ =09 value =3D sym->st_size; # endif =09 /* Fall through. */ =09case R_X86_64_GLOB_DAT: =09case R_X86_64_JUMP_SLOT: =09 *reloc_addr =3D value + reloc->r_addend; =09 break; The new version is: =09{ # ifndef RTLD_BOOTSTRAP # ifdef __ILP32__ =09case R_X86_64_SIZE64: =09 /* Set to symbol size plus addend. */ =09 *(Elf64_Addr *) (uintptr_t) reloc_addr =09 =3D (Elf64_Addr) sym->st_size + reloc->r_addend; =09 break; =09case R_X86_64_SIZE32: # else =09case R_X86_64_SIZE64: # endif =09 /* Set to symbol size plus addend. */ =09 value =3D sym->st_size; =09 *reloc_addr =3D value + reloc->r_addend; =09 break; # endif =09case R_X86_64_GLOB_DAT: =09case R_X86_64_JUMP_SLOT: =09 *reloc_addr =3D value; =09 break; So that =E2=80=9Cbreak=E2=80=9D is actually in the right place. Are there binaries out there with a non-zero addend? I'm a bit worried that this change introduces hard-to-diagnose regressions. Thanks, Florian