From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by sourceware.org (Postfix) with ESMTPS id 1A04F3858298 for ; Fri, 16 Feb 2024 12:38:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A04F3858298 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 1A04F3858298 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708087107; cv=none; b=s+iKryJAZGSD0a8S3+vHsooqq78ub1EWjKtpVG6Auq6V5VlnBEz0bMXETrnJd0tdU/pvbAjTqBVaK7I7OW2tkQ1wl3uMZOJGXCjszJiWo3DrdryNioD5Qz0o3vasjOKmzAVMSLWxMdQCrSb2OtEweXa4Z34jEAVOo2BywZjeFho= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708087107; c=relaxed/simple; bh=Ofq14tpVlWCvwDWfZ7aulHLXLrZQwphwHdbfFDdUdiQ=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=cTrMIKBxlNdvNE/RRyeZza73y3dVA+SGGYWABRQjr6yvveFemeXhbCTaAgPtidNOZubr8/RTKLqXY35LfYz5bDgErzhyj8eDVLESh62L02MH/IRNaq0m6GbshZDZCf1rn4huP+q3QeZpQrKGdA3dzxEcxkjXSNmK8pOAZ6J0pk4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-607c5679842so20721757b3.2 for ; Fri, 16 Feb 2024 04:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708087105; x=1708691905; 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=+zefuSxe3cUOFcFT1YBIelAbBJgL3wPnKOExugBpntA=; b=Q+WKkx0WD501Z1WJ8l4Qz7yk//EW8hqceDMF4a2Mg9PcEYin3fFdHXn9vkIDCXHdIJ PVZ38waOFOdCU2rjPtm9fdhr5Oa220ysmIMdF9hDROQyV4E212zrGGTE65nRw5xpBmK7 WX5F2E0XaxNhNzfBt47rG4fIHRFFo3dTUPC6mxKPgMccN4luygKvM3+0oCUxG+OxW/gZ wAKGFlDyNATgg0e3Nt+elJMoMeQlnzvAU8ZIXKQ+QywrmHMPbQZ3nYRX4WdMat2B25Da iyG2tmsPCZWjR1135V5lm9YWoUXrygWXOtJzrTH5XF5tIKfpAqfqCUozZV5BrZzcMN2O Ge+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708087105; x=1708691905; 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=+zefuSxe3cUOFcFT1YBIelAbBJgL3wPnKOExugBpntA=; b=gh9e/kj3+Fhqi74adN2djm9qqz6DF8JhIYpWOLXh/AIPh3m8x0BilEg6yup04m+ESu iCrv6mYts5I6k4gaChqp+rU0k7/KZj7hAWNhf87ETzcZ5dvM5bh3l94nU3QWnfOXth+H ki2EEtTZl4mVyqqKEF6OM4ZGlWAux/Z6PdYfgLVa5xUwu0zbsy3SrA7PGCT1KDm1MNRD h4dgoX09pxvMZ/NpWAL501c6NUi7gOC7wkUcVMIjqwXd3kkQA7WN5BXwlwjzuZLj0HDL dQSlo/OWaNu2N5cS36NBtx/hp0K4DovaJS8C6v2h66iWN10e4hkgfLhGJRObufzgf7H8 cy+w== X-Forwarded-Encrypted: i=1; AJvYcCUwhvP1ZWQi+cx2zvzFyYD34qKy/UxPUErN/Q7ToBAABjD1+N+MBiLxl2wKB9TziT6O7JBKJmye7NcakqLszFy1clgCGMO7OyTG X-Gm-Message-State: AOJu0Yxa3b355fnaOTPAZ6MXqCESMX/yv60pURAkNVHRsARcoUHgJfW/ U6smpcKL6xYK2AQecVwIVrJHQM9lYGpdBlddVJpU86dUXfjlI2DzpJFh70RASBYFMGTc8H78H/B 0CnRZYT/zBYWYvYLPWuecjF7lmdM= X-Google-Smtp-Source: AGHT+IH8dFo5M450L8LqvqxR/PkN+Res0kLMFqggBPihowbMtMYH7NizQaCVMqDo9X7JkSrIK3IAJS/Gp5Jz4EPXgt0= X-Received: by 2002:a81:ac57:0:b0:5e7:c9de:1ae3 with SMTP id z23-20020a81ac57000000b005e7c9de1ae3mr3907720ywj.47.1708087105366; Fri, 16 Feb 2024 04:38:25 -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> <87mss061s0.fsf@oldenburg.str.redhat.com> In-Reply-To: From: "H.J. Lu" Date: Fri, 16 Feb 2024 04:37:49 -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.3 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 Fri, Feb 16, 2024 at 4:20=E2=80=AFAM H.J. Lu wrote= : > > On Fri, Feb 16, 2024 at 4:18=E2=80=AFAM Florian Weimer wrote: > > > > * 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=3D0x7ffff7= bfee80) 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", &ver= sion); > > > void *new_free =3D lookup_malloc_symbol (main_map, "free", &version= ); > > > void *new_malloc =3D lookup_malloc_symbol (main_map, "malloc", &ver= sion); > > > void *new_realloc =3D lookup_malloc_symbol (main_map, "realloc", &v= ersion); > > > > > > 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. Ha= s > > this changed in the dynamic linker? > > Only for this case. > I was wrong. Version isn't needed. Will fix it. Thanks. --=20 H.J.