From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by sourceware.org (Postfix) with ESMTPS id 7BA933858292 for ; Fri, 16 Feb 2024 11:59:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BA933858292 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 7BA933858292 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708084793; cv=none; b=wPp/Cz/HV3/mgEfN9ISJmI8QOHSk2wT6FlUY85JdWA3hdpRZek6SWSra3E9lu9TA7pr3/IZN28kqyeYBvvwme8TIgjnUmkSgZA4FwuHhhmQh470fS6HfQAZdhojcQAyecCXdpnHkwzlwUx0mKvEPMBLoK53kULrFFSQlduqWumg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708084793; c=relaxed/simple; bh=IqNvJkD7rg9a+RdORWZM6IYWQirdFuZvhf2bNOhb58I=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=IX6Jd/InVSwfErJ5vu/mqvXtbXa4ZWzk1vKEbqqpIiULZjm5RhSg8bvBJPdIHttUJ6ee5D677QNNwADsrBvVrNLNWQ7bUE2iS0RxiQEWtkjdO82z2VDjG1lg4hlXnz88Px0FjSxVMHGuZsM6gBNojMPhrFxUkwt4rwGoUhB2hpY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-607e705f745so12197747b3.2 for ; Fri, 16 Feb 2024 03:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708084791; x=1708689591; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mS65UogXhUbRD+etby7UGEPxCa4q2I8ibUtXRd5m4Dg=; b=H0avy86ir09C7eWOS5yOcBwt7rScvkTi5482Zvl/7RKg62cy60jh500sumDvtsSK5a UIzEo8n7IFPUsobzt0fxpfk1QHNFm5J40eWU1FxLdOn99Md6o7OHuKr7tFmLTzVk6uPQ ZFP+fIwL47IXUAsUhTNbHSl/vtzw9GFT9tq5Vi3EveTmjKh8J2Ag5vXXjzciHDMK3x8p 8g+PFxuFOLu3yi5KC2JDUXATxZsvsRm7qVAO62Cd8E35coM0/ljSDaGiu1e7yUg8ExdD 9bdsAFwU1ITTMA1p8cuooKqIPguigmFKRuBEUAfleceD7ww+IsEio8STjaZ1kJSWh5ty ti/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708084791; x=1708689591; h=content-transfer-encoding:cc: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=mS65UogXhUbRD+etby7UGEPxCa4q2I8ibUtXRd5m4Dg=; b=Wx+Oo8RV5e4B5UVeGBjiA2CcVcoJmAJhTjnc14qz4Gp7CWdG4iP4xIWmqykrFk4gRx 02UgNaenG3G/LSXS8LgxMkdPtfv7PTVw6aDVKcaGlRK3WUIWt1i65kWJUWGZpCAW/VBE N/35BuGwx1zg8aPtMQOswNlBmYgHelFn3XsAVw1drAspwrgXJt3WcV0l/aINtPcLJ5Dd vEvgqogQArtoenzZgRnkIBkXHspSfhku2nAs4vA2cTVol9A437MXb6kjZN6xLaeMByhi yL1A6MsZd8v/pY77kyujAmuaN6pbJYE2oyxwNAmY2reowrpQAwfuATzC6G3NwJjpxPxo dgYg== X-Forwarded-Encrypted: i=1; AJvYcCXV6xb8SDsUR1Jjm2MtiFbeSt1oiO4Ba4i5nEBB4sEIsLlVefSIMHSMYEcyvvJ8kljvXU5849i9rowblxmhYkhkedQ2NHI7Y916 X-Gm-Message-State: AOJu0YyjC14OZ6rnVEo2eH8PIsEz7eI/fCOi7R67+zT9fTTyEOWEHmg4 5gdRX+PAaWFjNBfZKdiuYCUQdQvocxqxmw87vKkPnKpYVQq/t7+TOXRwBgqe7mdbCTsoIEU73Yn sF9SZUbU5N2szNczFl2ZL3scPt5s= X-Google-Smtp-Source: AGHT+IEBir7bBrqetMkqSVAULqg0d5ozi/9bpLmryENYWU7hvcWGkaiXDQsxMsMR207U/k9aPtz/D8AWubmNainm75g= X-Received: by 2002:a0d:e243:0:b0:607:a30d:8b3 with SMTP id l64-20020a0de243000000b00607a30d08b3mr4783401ywe.18.1708084790802; Fri, 16 Feb 2024 03:59:50 -0800 (PST) MIME-Version: 1.0 References: <20240213041501.2494232-1-hjl.tools@gmail.com> <20240213041501.2494232-3-hjl.tools@gmail.com> <871q9d7wra.fsf@oldenburg.str.redhat.com> In-Reply-To: <871q9d7wra.fsf@oldenburg.str.redhat.com> From: "H.J. Lu" Date: Fri, 16 Feb 2024 03:59:14 -0800 Message-ID: Subject: Re: [PATCH v4 2/2] x86: Update _dl_tlsdesc_dynamic to preserve caller-saved registers To: Florian Weimer Cc: Adhemerval Zanella Netto , libc-alpha@sourceware.org, Fangrui Song , "Carlos O'Donell" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3020.6 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,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: 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=3D0x7ffff7bfee8= 0) 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", &version= ); malloc in malloc-for-test.so must have the same version. Otherwise, it won't be used in the test. --=20 H.J.