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.129.124]) by sourceware.org (Postfix) with ESMTPS id E58B338582A2 for ; Fri, 16 Feb 2024 12:18:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E58B338582A2 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 E58B338582A2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708085905; cv=none; b=P8eBjjzrh4jKCKkOR/0GrA4p1vQ1g6JEPjT6FU13OoMumSrKkAQPecmIhZAUgvAscPzPYKwmrYzl0tqthdqgcrsWfVF1TfBheLV+CajYcpWi9qe9MqAk6kjxnloVPr2VjvGuIUhs8sz8igy3Q9AWmHpqqdMD+D/m3hZrfFgIF+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708085905; c=relaxed/simple; bh=g1los5d6InabEjKqmuTxyy0YR9QJSI+WtRFXnVKAfKA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=I0u/v7TOm0HQuElTfxCq33vs6q744fmY0CDBm54f/QfAf4F0la2dsQceF4C/rN5GF5HMmMwh1s3YpLy1if/JPiKHj6RbAFyybSTqtUjQkxg6+3wpfsfcsMmL0seVYV0ab+/1gKwy4xlgMG0yvvF5fCNXErbuXpL3mkKotEjoMbM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708085894; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9wWRGuQ9iFXabYgXZpJgRZiK+4ENF28pSNuTtNBC0jo=; b=RDzZWd0CkeAujrxTCvGtLU8M/IRJVtPojvDk3ukbdypxmPxRyEVVr5QBvbJH00UNt1LAWw fK3VUh1rUCM/njQVOfmN5A24FlZm0skbutiiiz57brGeji5GCABUprKUVRfGGK6viYsQNO 5/hOVtHsd2AdP0TRtS4MReY6gHauUzw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-231-i1ADxcDAPx64koLjGmD7eQ-1; Fri, 16 Feb 2024 07:18:11 -0500 X-MC-Unique: i1ADxcDAPx64koLjGmD7eQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 C7267381258C; Fri, 16 Feb 2024 12:18:10 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C4A2040C9444; Fri, 16 Feb 2024 12:18:09 +0000 (UTC) From: Florian Weimer To: "H.J. Lu" Cc: Adhemerval Zanella Netto , libc-alpha@sourceware.org, Fangrui Song , "Carlos O'Donell" Subject: Re: [PATCH v4 2/2] x86: Update _dl_tlsdesc_dynamic to preserve caller-saved registers References: <20240213041501.2494232-1-hjl.tools@gmail.com> <20240213041501.2494232-3-hjl.tools@gmail.com> <871q9d7wra.fsf@oldenburg.str.redhat.com> Date: Fri, 16 Feb 2024 13:18:07 +0100 In-Reply-To: (H. J. Lu's message of "Fri, 16 Feb 2024 03:59:14 -0800") Message-ID: <87mss061s0.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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=-11.0 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_H2,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: * H. J. Lu: > On Thu, Feb 15, 2024 at 10:23=E2=80=AFPM Florian Weimer wrote: >> >> * Adhemerval Zanella Netto: >> >> >> diff --git a/elf/malloc-for-test.map b/elf/malloc-for-test.map >> >> new file mode 100644 >> >> index 0000000000..8437cf4346 >> >> --- /dev/null >> >> +++ b/elf/malloc-for-test.map >> >> @@ -0,0 +1,6 @@ >> >> +GLIBC_2.0 { >> > >> > You need to use the correct version to override the malloc: >> > >> > $ gdb --args tst-gnu2-tls2 --direct >> > [...] >> > (gdb) b apply_tls >> > (gdb) r >> > Thread 2 "tst-gnu2-tls2" hit Breakpoint 1, apply_tls (p=3D0x7ffff7bfee= 80) at tst-gnu2-tls2mod1.c:25 >> > 25 { >> > (gdb) b malloc >> > Breakpoint 2 at 0x7ffff7ca8ad0: malloc. (3 locations) >> > (gdb) c >> > Continuing. >> >> Why do we need to set a symbol version here? I think this can be >> removed. > > malloc-for-test.so provides a fake malloc to clobber caller-save > registers. Since malloc in ld.so has a symbol version, > > struct r_found_version version; > version.name =3D symbol_version_string (libc, GLIBC_2_0); > version.hidden =3D 0; > version.hash =3D _dl_elf_hash (version.name); > version.filename =3D NULL; > > void *new_calloc =3D lookup_malloc_symbol (main_map, "calloc", &version= ); > void *new_free =3D lookup_malloc_symbol (main_map, "free", &version); > void *new_malloc =3D lookup_malloc_symbol (main_map, "malloc", &version= ); > void *new_realloc =3D lookup_malloc_symbol (main_map, "realloc", &versi= on); > > malloc in malloc-for-test.so must have the same version. Otherwise, > it won't be used in the test. I thought that unversioned symbols interpose all versioned symbols. Has this changed in the dynamic linker? Thanks, Florian